diff --git a/enums.py b/enums.py
index 19bbed8b0d..bfb1b53e19 100755
--- a/enums.py
+++ b/enums.py
@@ -4,7 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
-import math
import os
ENUMS = {
@@ -34,6 +33,7 @@
"PositionType": ["Static", "Relative", "Absolute"],
"Display": ["Flex", "None"],
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
+ "BoxSizing": ["ContentBox", "BorderBox"],
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
"Dimension": ["Width", "Height"],
"Edge": [
diff --git a/gentest/fixtures/YGBoxSizingTest.html b/gentest/fixtures/YGBoxSizingTest.html
new file mode 100644
index 0000000000..a0a57185e4
--- /dev/null
+++ b/gentest/fixtures/YGBoxSizingTest.html
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js
index b29b8bfe1d..4dde81776f 100644
--- a/gentest/gentest-cpp.js
+++ b/gentest/gentest-cpp.js
@@ -136,6 +136,9 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGWrapWrap: {value: 'YGWrapWrap'},
YGWrapWrapReverse: {value: 'YGWrapWrapReverse'},
+ YGBoxSizingBorderBox: {value: 'YGBoxSizingBorderBox'},
+ YGBoxSizingContentBox: {value: 'YGBoxSizingContentBox'},
+
YGUndefined: {value: 'YGUndefined'},
YGDisplayFlex: {value: 'YGDisplayFlex'},
@@ -512,6 +515,14 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
+ YGNodeStyleSetBoxSizing: {
+ value: function (nodeName, value) {
+ this.push(
+ 'YGNodeStyleSetBoxSizing(' + nodeName + ', ' + toValueCpp(value) + ');',
+ );
+ },
+ },
+
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js
index ac0ce0f6ed..020d98e3a5 100644
--- a/gentest/gentest-java.js
+++ b/gentest/gentest-java.js
@@ -184,6 +184,9 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGWrapWrap: {value: 'YogaWrap.WRAP'},
YGWrapWrapReverse: {value: 'YogaWrap.WRAP_REVERSE'},
+ YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'},
+ YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'},
+
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
this.push(node + '.setDirection(' + dir + ');');
@@ -473,6 +476,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
+ YGNodeStyleSetBoxSizing: {
+ value: function (nodeName, value) {
+ this.push(nodeName + '.setBoxSizing(' + toValueJava(value) + ');');
+ },
+ },
+
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(`${nodeName}.setData("${innerText}");`);
diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js
index c36cee6bf4..f79b76e5dd 100644
--- a/gentest/gentest-javascript.js
+++ b/gentest/gentest-javascript.js
@@ -30,6 +30,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
this.push('import {');
this.pushIndent();
this.push('Align,');
+ this.push('BoxSizing,');
this.push('Direction,');
this.push('Display,');
this.push('Edge,');
@@ -171,6 +172,9 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex: {value: 'Display.Flex'},
YGDisplayNone: {value: 'Display.None'},
+ YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
+ YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
+
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
this.push(node + '.calculateLayout(undefined, undefined, ' + dir + ');');
@@ -410,6 +414,12 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
},
},
+ YGNodeStyleSetBoxSizing: {
+ value: function (nodeName, value) {
+ this.push(nodeName + '.setBoxSizing(' + toValueJavascript(value) + ');');
+ },
+ },
+
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(
diff --git a/gentest/gentest.js b/gentest/gentest.js
index 39408b6af0..52fdca473d 100755
--- a/gentest/gentest.js
+++ b/gentest/gentest.js
@@ -175,6 +175,7 @@ function checkDefaultValues() {
{style: 'right', value: 'undefined'},
{style: 'bottom', value: 'undefined'},
{style: 'display', value: 'flex'},
+ {style: 'box-sizing', value: 'border-box'},
].forEach(item => {
assert(
isDefaultStyleValue(item.style, item.value),
@@ -193,7 +194,6 @@ function setupTestTree(
index,
) {
e.emitTestTreePrologue(nodeName);
-
for (const style in node.style) {
// Skip position info for root as it messes up tests
if (
@@ -207,7 +207,6 @@ function setupTestTree(
) {
continue;
}
-
if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) {
case 'aspect-ratio':
@@ -520,6 +519,11 @@ function setupTestTree(
case 'display':
e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]));
break;
+ case 'box-sizing':
+ e.YGNodeStyleSetBoxSizing(
+ nodeName,
+ boxSizingValue(e, node.style[style]),
+ );
}
}
}
@@ -664,6 +668,15 @@ function displayValue(e, value) {
}
}
+function boxSizingValue(e, value) {
+ switch (value) {
+ case 'border-box':
+ return e.YGBoxSizingBorderBox;
+ case 'content-box':
+ return e.YGBoxSizingContentBox;
+ }
+}
+
const DEFAULT_STYLES = new Map();
function isDefaultStyleValue(style, value) {
@@ -782,6 +795,7 @@ function getYogaStyle(node) {
'row-gap',
'display',
'aspect-ratio',
+ 'box-sizing',
].reduce((map, key) => {
map[key] =
node.style[key] || getComputedStyle(node, null).getPropertyValue(key);
diff --git a/java/com/facebook/yoga/YogaBoxSizing.java b/java/com/facebook/yoga/YogaBoxSizing.java
new file mode 100644
index 0000000000..a8c08f6543
--- /dev/null
+++ b/java/com/facebook/yoga/YogaBoxSizing.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+// @generated by enums.py
+
+package com.facebook.yoga;
+
+public enum YogaBoxSizing {
+ CONTENT_BOX(0),
+ BORDER_BOX(1);
+
+ private final int mIntValue;
+
+ YogaBoxSizing(int intValue) {
+ mIntValue = intValue;
+ }
+
+ public int intValue() {
+ return mIntValue;
+ }
+
+ public static YogaBoxSizing fromInt(int value) {
+ switch (value) {
+ case 0: return CONTENT_BOX;
+ case 1: return BORDER_BOX;
+ default: throw new IllegalArgumentException("Unknown enum value: " + value);
+ }
+ }
+}
diff --git a/java/com/facebook/yoga/YogaNative.java b/java/com/facebook/yoga/YogaNative.java
index 0ab5391331..89ef5ef16f 100644
--- a/java/com/facebook/yoga/YogaNative.java
+++ b/java/com/facebook/yoga/YogaNative.java
@@ -56,6 +56,8 @@ public class YogaNative {
static native void jni_YGNodeStyleSetAlignContentJNI(long nativePointer, int alignContent);
static native int jni_YGNodeStyleGetPositionTypeJNI(long nativePointer);
static native void jni_YGNodeStyleSetPositionTypeJNI(long nativePointer, int positionType);
+ static native int jni_YGNodeStyleGetBoxSizingJNI(long nativePointer);
+ static native void jni_YGNodeStyleSetBoxSizingJNI(long nativePointer, int boxSizing);
static native int jni_YGNodeStyleGetFlexWrapJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexWrapJNI(long nativePointer, int wrapType);
static native int jni_YGNodeStyleGetOverflowJNI(long nativePointer);
diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java
index c83b577880..ba07684675 100644
--- a/java/com/facebook/yoga/YogaNode.java
+++ b/java/com/facebook/yoga/YogaNode.java
@@ -88,6 +88,10 @@ public interface Inputs {
public abstract void setPositionType(YogaPositionType positionType);
+ public abstract YogaBoxSizing getBoxSizing();
+
+ public abstract void setBoxSizing(YogaBoxSizing boxSizing);
+
public abstract YogaWrap getWrap();
public abstract void setWrap(YogaWrap flexWrap);
diff --git a/java/com/facebook/yoga/YogaNodeJNIBase.java b/java/com/facebook/yoga/YogaNodeJNIBase.java
index 75a318984e..6e4f96982a 100644
--- a/java/com/facebook/yoga/YogaNodeJNIBase.java
+++ b/java/com/facebook/yoga/YogaNodeJNIBase.java
@@ -299,6 +299,14 @@ public void setPositionType(YogaPositionType positionType) {
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
}
+ public YogaBoxSizing getBoxSizing() {
+ return YogaBoxSizing.fromInt(YogaNative.jni_YGNodeStyleGetBoxSizingJNI(mNativePointer));
+ }
+
+ public void setBoxSizing(YogaBoxSizing boxSizing) {
+ YogaNative.jni_YGNodeStyleSetBoxSizingJNI(mNativePointer, boxSizing.intValue());
+ }
+
public YogaWrap getWrap() {
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer));
}
diff --git a/java/com/facebook/yoga/YogaProps.java b/java/com/facebook/yoga/YogaProps.java
index 398bc8f026..c596c6a7c1 100644
--- a/java/com/facebook/yoga/YogaProps.java
+++ b/java/com/facebook/yoga/YogaProps.java
@@ -105,6 +105,8 @@ public interface YogaProps {
void setBaselineFunction(YogaBaselineFunction yogaBaselineFunction);
+ void setBoxSizing(YogaBoxSizing boxSizing);
+
/* Getters */
YogaValue getWidth();
@@ -148,4 +150,6 @@ public interface YogaProps {
YogaValue getPosition(YogaEdge edge);
float getBorder(YogaEdge edge);
+
+ YogaBoxSizing getBoxSizing();
}
diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp
index 9f4e211bd0..6b8ed14bd6 100644
--- a/java/jni/YGJNIVanilla.cpp
+++ b/java/jni/YGJNIVanilla.cpp
@@ -475,6 +475,7 @@ YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
+YG_NODE_JNI_STYLE_PROP(jint, YGBoxSizing, BoxSizing);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
@@ -819,6 +820,12 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionTypeJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionTypeJNI},
+ {"jni_YGNodeStyleGetBoxSizingJNI",
+ "(J)I",
+ (void*)jni_YGNodeStyleGetBoxSizingJNI},
+ {"jni_YGNodeStyleSetBoxSizingJNI",
+ "(JI)V",
+ (void*)jni_YGNodeStyleSetBoxSizingJNI},
{"jni_YGNodeStyleGetFlexWrapJNI",
"(J)I",
(void*)jni_YGNodeStyleGetFlexWrapJNI},
diff --git a/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java
new file mode 100644
index 0000000000..2cffa0a957
--- /dev/null
+++ b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java
@@ -0,0 +1,1627 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @generated SignedSource<<84bb16d1a7ae39fb8f159ee58baef4c2>>
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
+ */
+
+package com.facebook.yoga;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import com.facebook.yoga.utils.TestUtils;
+
+@RunWith(Parameterized.class)
+public class YGBoxSizingTest {
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable nodeFactories() {
+ return TestParametrization.nodeFactories();
+ }
+
+ @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(130f, root.getLayoutWidth(), 0.0f);
+ assertEquals(130f, root.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(130f, root.getLayoutWidth(), 0.0f);
+ assertEquals(130f, root.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ 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);
+
+ 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);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_padding_only() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
+ assertEquals(110f, root.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(110f, root.getLayoutWidth(), 0.0f);
+ assertEquals(110f, root.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_padding_only() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ 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);
+
+ 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);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_border_only() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(120f, root.getLayoutWidth(), 0.0f);
+ assertEquals(120f, root.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(120f, root.getLayoutWidth(), 0.0f);
+ assertEquals(120f, root.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_border_only() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ 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);
+
+ 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);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_no_padding_no_border() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ 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);
+
+ 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);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_no_padding_no_border() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ 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);
+
+ 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);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_children() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidth(25f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidth(25f);
+ root_child2.setHeight(25f);
+ root.addChildAt(root_child2, 2);
+
+ final YogaNode root_child3 = createNode(config);
+ root_child3.setWidth(25f);
+ root_child3.setHeight(25f);
+ root.addChildAt(root_child3, 3);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(130f, root.getLayoutWidth(), 0.0f);
+ assertEquals(130f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(15f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.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(130f, root.getLayoutWidth(), 0.0f);
+ assertEquals(130f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(90f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(15f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(90f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(90f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(90f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_children() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 5);
+ root.setPadding(YogaEdge.TOP, 5);
+ root.setPadding(YogaEdge.RIGHT, 5);
+ root.setPadding(YogaEdge.BOTTOM, 5);
+ root.setBorder(YogaEdge.LEFT, 10f);
+ root.setBorder(YogaEdge.TOP, 10f);
+ root.setBorder(YogaEdge.RIGHT, 10f);
+ root.setBorder(YogaEdge.BOTTOM, 10f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidth(25f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidth(25f);
+ root_child2.setHeight(25f);
+ root.addChildAt(root_child2, 2);
+
+ final YogaNode root_child3 = createNode(config);
+ root_child3.setWidth(25f);
+ root_child3.setHeight(25f);
+ root.addChildAt(root_child3, 3);
+ 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(15f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(15f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(15f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.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(60f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(15f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_siblings() {
+ 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.setWidth(25f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setPadding(YogaEdge.LEFT, 10);
+ root_child1.setPadding(YogaEdge.TOP, 10);
+ root_child1.setPadding(YogaEdge.RIGHT, 10);
+ root_child1.setPadding(YogaEdge.BOTTOM, 10);
+ root_child1.setBorder(YogaEdge.LEFT, 10f);
+ root_child1.setBorder(YogaEdge.TOP, 10f);
+ root_child1.setBorder(YogaEdge.RIGHT, 10f);
+ root_child1.setBorder(YogaEdge.BOTTOM, 10f);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root_child1.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidth(25f);
+ root_child2.setHeight(25f);
+ root.addChildAt(root_child2, 2);
+
+ final YogaNode root_child3 = createNode(config);
+ root_child3.setWidth(25f);
+ root_child3.setHeight(25f);
+ root.addChildAt(root_child3, 3);
+ 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(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(115f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.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(75f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(35f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(115f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_siblings() {
+ 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.setWidth(25f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setPadding(YogaEdge.LEFT, 10);
+ root_child1.setPadding(YogaEdge.TOP, 10);
+ root_child1.setPadding(YogaEdge.RIGHT, 10);
+ root_child1.setPadding(YogaEdge.BOTTOM, 10);
+ root_child1.setBorder(YogaEdge.LEFT, 10f);
+ root_child1.setBorder(YogaEdge.TOP, 10f);
+ root_child1.setBorder(YogaEdge.RIGHT, 10f);
+ root_child1.setBorder(YogaEdge.BOTTOM, 10f);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidth(25f);
+ root_child2.setHeight(25f);
+ root.addChildAt(root_child2, 2);
+
+ final YogaNode root_child3 = createNode(config);
+ root_child3.setWidth(25f);
+ root_child3.setHeight(25f);
+ root.addChildAt(root_child3, 3);
+ 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(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.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(75f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_max_width() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setMaxWidth(50f);
+ root_child0.setHeight(25f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_max_width() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setMaxWidth(50f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(50f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_max_height() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setWidth(50f);
+ root_child0.setMaxHeight(50f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_max_height() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setWidth(50f);
+ root_child0.setMaxHeight(50f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(50f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_min_width() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setMinWidth(50f);
+ root_child0.setHeight(25f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(65f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_min_width() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setMinWidth(50f);
+ root_child0.setHeight(25f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_min_height() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setWidth(50f);
+ root_child0.setMinHeight(50f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(90f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(90f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_min_height() {
+ 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.setPadding(YogaEdge.LEFT, 5);
+ root_child0.setPadding(YogaEdge.TOP, 5);
+ root_child0.setPadding(YogaEdge.RIGHT, 5);
+ root_child0.setPadding(YogaEdge.BOTTOM, 5);
+ root_child0.setBorder(YogaEdge.LEFT, 15f);
+ root_child0.setBorder(YogaEdge.TOP, 15f);
+ root_child0.setBorder(YogaEdge.RIGHT, 15f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 15f);
+ root_child0.setWidth(50f);
+ root_child0.setMinHeight(50f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(25f);
+ root_child1.setHeight(25f);
+ root.addChildAt(root_child1, 1);
+ 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(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.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(50f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(75f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_no_height_no_width() {
+ 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.setPadding(YogaEdge.LEFT, 2);
+ root_child0.setPadding(YogaEdge.TOP, 2);
+ root_child0.setPadding(YogaEdge.RIGHT, 2);
+ root_child0.setPadding(YogaEdge.BOTTOM, 2);
+ root_child0.setBorder(YogaEdge.LEFT, 7f);
+ root_child0.setBorder(YogaEdge.TOP, 7f);
+ root_child0.setBorder(YogaEdge.RIGHT, 7f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 7f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(18f, 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(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_no_height_no_width() {
+ 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.setPadding(YogaEdge.LEFT, 2);
+ root_child0.setPadding(YogaEdge.TOP, 2);
+ root_child0.setPadding(YogaEdge.RIGHT, 2);
+ root_child0.setPadding(YogaEdge.BOTTOM, 2);
+ root_child0.setBorder(YogaEdge.LEFT, 7f);
+ root_child0.setBorder(YogaEdge.TOP, 7f);
+ root_child0.setBorder(YogaEdge.RIGHT, 7f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 7f);
+ 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(18f, 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(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_nested() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 15);
+ root.setPadding(YogaEdge.TOP, 15);
+ root.setPadding(YogaEdge.RIGHT, 15);
+ root.setPadding(YogaEdge.BOTTOM, 15);
+ root.setBorder(YogaEdge.LEFT, 3f);
+ root.setBorder(YogaEdge.TOP, 3f);
+ root.setBorder(YogaEdge.RIGHT, 3f);
+ root.setBorder(YogaEdge.BOTTOM, 3f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setPadding(YogaEdge.LEFT, 2);
+ root_child0.setPadding(YogaEdge.TOP, 2);
+ root_child0.setPadding(YogaEdge.RIGHT, 2);
+ root_child0.setPadding(YogaEdge.BOTTOM, 2);
+ root_child0.setBorder(YogaEdge.LEFT, 7f);
+ root_child0.setBorder(YogaEdge.TOP, 7f);
+ root_child0.setBorder(YogaEdge.RIGHT, 7f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 7f);
+ root_child0.setWidth(20f);
+ root_child0.setHeight(20f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = createNode(config);
+ root_child0_child0.setPadding(YogaEdge.LEFT, 1);
+ root_child0_child0.setPadding(YogaEdge.TOP, 1);
+ root_child0_child0.setPadding(YogaEdge.RIGHT, 1);
+ root_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
+ root_child0_child0.setBorder(YogaEdge.LEFT, 2f);
+ root_child0_child0.setBorder(YogaEdge.TOP, 2f);
+ root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
+ root_child0_child0.setBorder(YogaEdge.BOTTOM, 2f);
+ root_child0_child0.setWidth(10f);
+ root_child0_child0.setHeight(5f);
+ root_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root_child0.addChildAt(root_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(136f, root.getLayoutWidth(), 0.0f);
+ assertEquals(136f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(18f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(38f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(38f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(9f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(16f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(11f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(136f, root.getLayoutWidth(), 0.0f);
+ assertEquals(136f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(38f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(38f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(13f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(16f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(11f, root_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_box_sizing_border_box_nested() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 15);
+ root.setPadding(YogaEdge.TOP, 15);
+ root.setPadding(YogaEdge.RIGHT, 15);
+ root.setPadding(YogaEdge.BOTTOM, 15);
+ root.setBorder(YogaEdge.LEFT, 3f);
+ root.setBorder(YogaEdge.TOP, 3f);
+ root.setBorder(YogaEdge.RIGHT, 3f);
+ root.setBorder(YogaEdge.BOTTOM, 3f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setPadding(YogaEdge.LEFT, 2);
+ root_child0.setPadding(YogaEdge.TOP, 2);
+ root_child0.setPadding(YogaEdge.RIGHT, 2);
+ root_child0.setPadding(YogaEdge.BOTTOM, 2);
+ root_child0.setBorder(YogaEdge.LEFT, 7f);
+ root_child0.setBorder(YogaEdge.TOP, 7f);
+ root_child0.setBorder(YogaEdge.RIGHT, 7f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 7f);
+ root_child0.setWidth(20f);
+ root_child0.setHeight(20f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = createNode(config);
+ root_child0_child0.setPadding(YogaEdge.LEFT, 1);
+ root_child0_child0.setPadding(YogaEdge.TOP, 1);
+ root_child0_child0.setPadding(YogaEdge.RIGHT, 1);
+ root_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
+ root_child0_child0.setBorder(YogaEdge.LEFT, 2f);
+ root_child0_child0.setBorder(YogaEdge.TOP, 2f);
+ root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
+ root_child0_child0.setBorder(YogaEdge.BOTTOM, 2f);
+ root_child0_child0.setWidth(10f);
+ root_child0_child0.setHeight(5f);
+ root_child0.addChildAt(root_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(18f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(9f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(6f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(62f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(18f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(1f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(6f, root_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_content_box_nested_alternating() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 3);
+ root.setPadding(YogaEdge.TOP, 3);
+ root.setPadding(YogaEdge.RIGHT, 3);
+ root.setPadding(YogaEdge.BOTTOM, 3);
+ root.setBorder(YogaEdge.LEFT, 2f);
+ root.setBorder(YogaEdge.TOP, 2f);
+ root.setBorder(YogaEdge.RIGHT, 2f);
+ root.setBorder(YogaEdge.BOTTOM, 2f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+ root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setPadding(YogaEdge.LEFT, 8);
+ root_child0.setPadding(YogaEdge.TOP, 8);
+ root_child0.setPadding(YogaEdge.RIGHT, 8);
+ root_child0.setPadding(YogaEdge.BOTTOM, 8);
+ root_child0.setBorder(YogaEdge.LEFT, 2f);
+ root_child0.setBorder(YogaEdge.TOP, 2f);
+ root_child0.setBorder(YogaEdge.RIGHT, 2f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 2f);
+ root_child0.setWidth(40f);
+ root_child0.setHeight(40f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = createNode(config);
+ root_child0_child0.setPadding(YogaEdge.LEFT, 3);
+ root_child0_child0.setPadding(YogaEdge.TOP, 3);
+ root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
+ root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
+ root_child0_child0.setBorder(YogaEdge.LEFT, 6f);
+ root_child0_child0.setBorder(YogaEdge.TOP, 6f);
+ root_child0_child0.setBorder(YogaEdge.RIGHT, 6f);
+ root_child0_child0.setBorder(YogaEdge.BOTTOM, 6f);
+ root_child0_child0.setWidth(20f);
+ root_child0_child0.setHeight(25f);
+ root_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child0_child0 = createNode(config);
+ root_child0_child0_child0.setPadding(YogaEdge.LEFT, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.TOP, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
+ root_child0_child0_child0.setBorder(YogaEdge.LEFT, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
+ root_child0_child0_child0.setWidth(10f);
+ root_child0_child0_child0.setHeight(5f);
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
+ assertEquals(110f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(38f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(43f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(5f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
+ assertEquals(110f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(65f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(-8f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(38f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(43f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(19f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(5f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_box_sizing_border_box_nested_alternating() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setPadding(YogaEdge.LEFT, 3);
+ root.setPadding(YogaEdge.TOP, 3);
+ root.setPadding(YogaEdge.RIGHT, 3);
+ root.setPadding(YogaEdge.BOTTOM, 3);
+ root.setBorder(YogaEdge.LEFT, 2f);
+ root.setBorder(YogaEdge.TOP, 2f);
+ root.setBorder(YogaEdge.RIGHT, 2f);
+ root.setBorder(YogaEdge.BOTTOM, 2f);
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setPadding(YogaEdge.LEFT, 8);
+ root_child0.setPadding(YogaEdge.TOP, 8);
+ root_child0.setPadding(YogaEdge.RIGHT, 8);
+ root_child0.setPadding(YogaEdge.BOTTOM, 8);
+ root_child0.setBorder(YogaEdge.LEFT, 2f);
+ root_child0.setBorder(YogaEdge.TOP, 2f);
+ root_child0.setBorder(YogaEdge.RIGHT, 2f);
+ root_child0.setBorder(YogaEdge.BOTTOM, 2f);
+ root_child0.setWidth(40f);
+ root_child0.setHeight(40f);
+ root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = createNode(config);
+ root_child0_child0.setPadding(YogaEdge.LEFT, 3);
+ root_child0_child0.setPadding(YogaEdge.TOP, 3);
+ root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
+ root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
+ root_child0_child0.setBorder(YogaEdge.LEFT, 6f);
+ root_child0_child0.setBorder(YogaEdge.TOP, 6f);
+ root_child0_child0.setBorder(YogaEdge.RIGHT, 6f);
+ root_child0_child0.setBorder(YogaEdge.BOTTOM, 6f);
+ root_child0_child0.setWidth(20f);
+ root_child0_child0.setHeight(25f);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child0_child0 = createNode(config);
+ root_child0_child0_child0.setPadding(YogaEdge.LEFT, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.TOP, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 1);
+ root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
+ root_child0_child0_child0.setBorder(YogaEdge.LEFT, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 1f);
+ root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
+ root_child0_child0_child0.setWidth(10f);
+ root_child0_child0_child0.setHeight(5f);
+ root_child0_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(14f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(35f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(-3f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(14f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(9f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ private YogaNode createNode(YogaConfig config) {
+ return mNodeFactory.create(config);
+ }
+}
diff --git a/javascript/src/Node.cpp b/javascript/src/Node.cpp
index 57aac36c4e..f5c6a86651 100644
--- a/javascript/src/Node.cpp
+++ b/javascript/src/Node.cpp
@@ -75,6 +75,10 @@ void Node::copyStyle(Node const& other) {
YGNodeCopyStyle(m_node, other.m_node);
}
+void Node::setBoxSizing(int boxSizing) {
+ YGNodeStyleSetBoxSizing(m_node, static_cast(boxSizing));
+}
+
void Node::setPositionType(int positionType) {
YGNodeStyleSetPositionType(m_node, static_cast(positionType));
}
@@ -248,6 +252,10 @@ void Node::setGapPercent(int gutter, double gapLength) {
YGNodeStyleSetGapPercent(m_node, static_cast(gutter), gapLength);
}
+int Node::getBoxSizing(void) const {
+ return YGNodeStyleGetBoxSizing(m_node);
+}
+
int Node::getPositionType(void) const {
return YGNodeStyleGetPositionType(m_node);
}
diff --git a/javascript/src/Node.h b/javascript/src/Node.h
index b55b1dfdb3..c30f1d2ded 100644
--- a/javascript/src/Node.h
+++ b/javascript/src/Node.h
@@ -127,6 +127,8 @@ class Node {
void setGap(int gutter, double gapLength);
void setGapPercent(int gutter, double gapLength);
+ void setBoxSizing(int boxSizing);
+
public: // Style getters
int getPositionType(void) const;
Value getPosition(int edge) const;
@@ -165,6 +167,8 @@ class Node {
float getGap(int gutter);
+ int getBoxSizing(void) const;
+
public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index);
void removeChild(Node* child);
diff --git a/javascript/src/embind.cpp b/javascript/src/embind.cpp
index d37ce1b74f..d1789788cf 100644
--- a/javascript/src/embind.cpp
+++ b/javascript/src/embind.cpp
@@ -110,6 +110,8 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setMaxHeight", &Node::setMaxHeight)
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
+ .function("setBoxSizing", &Node::setBoxSizing)
+
.function("setAspectRatio", &Node::setAspectRatio)
.function("setBorder", &Node::setBorder)
@@ -146,6 +148,8 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("getMaxWidth", &Node::getMaxWidth)
.function("getMaxHeight", &Node::getMaxHeight)
+ .function("getBoxSizing", &Node::getBoxSizing)
+
.function("getAspectRatio", &Node::getAspectRatio)
.function("getBorder", &Node::getBorder)
diff --git a/javascript/src/generated/YGEnums.ts b/javascript/src/generated/YGEnums.ts
index b4dcaa337d..e3e1f0e787 100644
--- a/javascript/src/generated/YGEnums.ts
+++ b/javascript/src/generated/YGEnums.ts
@@ -19,6 +19,11 @@ export enum Align {
SpaceEvenly = 8,
}
+export enum BoxSizing {
+ ContentBox = 0,
+ BorderBox = 1,
+}
+
export enum Dimension {
Width = 0,
Height = 1,
@@ -137,6 +142,8 @@ const constants = {
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
ALIGN_SPACE_AROUND: Align.SpaceAround,
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
+ BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
+ BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
DIMENSION_WIDTH: Dimension.Width,
DIMENSION_HEIGHT: Dimension.Height,
DIRECTION_INHERIT: Direction.Inherit,
diff --git a/javascript/src/wrapAssembly.ts b/javascript/src/wrapAssembly.ts
index eacecfbfa5..3f91c160bf 100644
--- a/javascript/src/wrapAssembly.ts
+++ b/javascript/src/wrapAssembly.ts
@@ -14,6 +14,7 @@ import YGEnums from './generated/YGEnums.ts';
import type {
Align,
+ BoxSizing,
Display,
Edge,
Errata,
@@ -115,6 +116,7 @@ export type Node = {
getParent(): Node | null;
getPosition(edge: Edge): Value;
getPositionType(): PositionType;
+ getBoxSizing(): BoxSizing;
getWidth(): Value;
insertChild(child: Node, index: number): void;
isDirty(): boolean;
@@ -169,6 +171,7 @@ export type Node = {
setPositionPercent(edge: Edge, position: number | undefined): void;
setPositionType(positionType: PositionType): void;
setPositionAuto(edge: Edge): void;
+ setBoxSizing(boxSizing: BoxSizing): void;
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
setWidthAuto(): void;
setWidthPercent(width: number | undefined): void;
diff --git a/javascript/tests/generated/YGAbsolutePositionTest.test.ts b/javascript/tests/generated/YGAbsolutePositionTest.test.ts
index c21771bced..694086e23c 100644
--- a/javascript/tests/generated/YGAbsolutePositionTest.test.ts
+++ b/javascript/tests/generated/YGAbsolutePositionTest.test.ts
@@ -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<<3ac965030750351f007587f3ae1dec10>>
+ * @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGAlignContentTest.test.ts b/javascript/tests/generated/YGAlignContentTest.test.ts
index 32d1108174..dbe41b6a70 100644
--- a/javascript/tests/generated/YGAlignContentTest.test.ts
+++ b/javascript/tests/generated/YGAlignContentTest.test.ts
@@ -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<>
+ * @generated SignedSource<<25f4cf395ff39619966d6f0ff993e99d>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGAlignItemsTest.test.ts b/javascript/tests/generated/YGAlignItemsTest.test.ts
index f9921c25af..39c013a3e5 100644
--- a/javascript/tests/generated/YGAlignItemsTest.test.ts
+++ b/javascript/tests/generated/YGAlignItemsTest.test.ts
@@ -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<>
+ * @generated SignedSource<<075a0b67003e5c4a1f51bd99da71c700>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGAlignSelfTest.test.ts b/javascript/tests/generated/YGAlignSelfTest.test.ts
index c631969ebe..5d2e49ecc9 100644
--- a/javascript/tests/generated/YGAlignSelfTest.test.ts
+++ b/javascript/tests/generated/YGAlignSelfTest.test.ts
@@ -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<>
+ * @generated SignedSource<<1badc9ed5a0cb8d9a4a1b23653cfbe58>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGAndroidNewsFeed.test.ts b/javascript/tests/generated/YGAndroidNewsFeed.test.ts
index e6050cf039..488ed8d531 100644
--- a/javascript/tests/generated/YGAndroidNewsFeed.test.ts
+++ b/javascript/tests/generated/YGAndroidNewsFeed.test.ts
@@ -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<<8f3c045b0df6a23f1d2fa54a255cb6f3>>
+ * @generated SignedSource<>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGAspectRatioTest.test.ts b/javascript/tests/generated/YGAspectRatioTest.test.ts
index 7dda850bee..69a7427809 100644
--- a/javascript/tests/generated/YGAspectRatioTest.test.ts
+++ b/javascript/tests/generated/YGAspectRatioTest.test.ts
@@ -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<>
+ * @generated SignedSource<<57064c3213fc22e0637ae5768ce6fea5>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGBorderTest.test.ts b/javascript/tests/generated/YGBorderTest.test.ts
index 5e3368470a..ddbdd2aad1 100644
--- a/javascript/tests/generated/YGBorderTest.test.ts
+++ b/javascript/tests/generated/YGBorderTest.test.ts
@@ -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<<675d8bdccff33c46128330c9bd6c9b87>>
+ * @generated SignedSource<>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGBoxSizingTest.test.ts b/javascript/tests/generated/YGBoxSizingTest.test.ts
new file mode 100644
index 0000000000..4fd75be153
--- /dev/null
+++ b/javascript/tests/generated/YGBoxSizingTest.test.ts
@@ -0,0 +1,1740 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @generated SignedSource<<40a2a45449f152b9c1f91adfc46ac6df>>
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
+ */
+
+import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
+import Yoga from 'yoga-layout';
+import {
+ Align,
+ BoxSizing,
+ Direction,
+ Display,
+ Edge,
+ Errata,
+ ExperimentalFeature,
+ FlexDirection,
+ Gutter,
+ Justify,
+ MeasureMode,
+ Overflow,
+ PositionType,
+ Unit,
+ Wrap,
+} from 'yoga-layout';
+
+test.skip('box_sizing_content_box', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(130);
+ expect(root.getComputedHeight()).toBe(130);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(130);
+ expect(root.getComputedHeight()).toBe(130);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+ 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);
+
+ 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);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_padding_only', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(110);
+ expect(root.getComputedHeight()).toBe(110);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(110);
+ expect(root.getComputedHeight()).toBe(110);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_padding_only', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setWidth(100);
+ root.setHeight(100);
+ 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);
+
+ 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);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_border_only', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(120);
+ expect(root.getComputedHeight()).toBe(120);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(120);
+ expect(root.getComputedHeight()).toBe(120);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_border_only', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+ 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);
+
+ 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);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_no_padding_no_border', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+ 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);
+
+ 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);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_no_padding_no_border', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setWidth(100);
+ root.setHeight(100);
+ 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);
+
+ 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);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_children', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth(25);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+
+ const root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth(25);
+ root_child2.setHeight(25);
+ root.insertChild(root_child2, 2);
+
+ const root_child3 = Yoga.Node.create(config);
+ root_child3.setWidth(25);
+ root_child3.setHeight(25);
+ root.insertChild(root_child3, 3);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(130);
+ expect(root.getComputedHeight()).toBe(130);
+
+ expect(root_child0.getComputedLeft()).toBe(15);
+ expect(root_child0.getComputedTop()).toBe(15);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(15);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ expect(root_child2.getComputedLeft()).toBe(15);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(15);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(130);
+ expect(root.getComputedHeight()).toBe(130);
+
+ expect(root_child0.getComputedLeft()).toBe(90);
+ expect(root_child0.getComputedTop()).toBe(15);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(90);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ expect(root_child2.getComputedLeft()).toBe(90);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(90);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_children', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 5);
+ root.setPadding(Edge.Top, 5);
+ root.setPadding(Edge.Right, 5);
+ root.setPadding(Edge.Bottom, 5);
+ root.setBorder(Edge.Left, 10);
+ root.setBorder(Edge.Top, 10);
+ root.setBorder(Edge.Right, 10);
+ root.setBorder(Edge.Bottom, 10);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth(25);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+
+ const root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth(25);
+ root_child2.setHeight(25);
+ root.insertChild(root_child2, 2);
+
+ const root_child3 = Yoga.Node.create(config);
+ root_child3.setWidth(25);
+ root_child3.setHeight(25);
+ root.insertChild(root_child3, 3);
+ 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(15);
+ expect(root_child0.getComputedTop()).toBe(15);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(15);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ expect(root_child2.getComputedLeft()).toBe(15);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(15);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+
+ 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(60);
+ expect(root_child0.getComputedTop()).toBe(15);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(60);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ expect(root_child2.getComputedLeft()).toBe(60);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(60);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_siblings', () => {
+ 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.setWidth(25);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setPadding(Edge.Left, 10);
+ root_child1.setPadding(Edge.Top, 10);
+ root_child1.setPadding(Edge.Right, 10);
+ root_child1.setPadding(Edge.Bottom, 10);
+ root_child1.setBorder(Edge.Left, 10);
+ root_child1.setBorder(Edge.Top, 10);
+ root_child1.setBorder(Edge.Right, 10);
+ root_child1.setBorder(Edge.Bottom, 10);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root_child1.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child1, 1);
+
+ const root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth(25);
+ root_child2.setHeight(25);
+ root.insertChild(root_child2, 2);
+
+ const root_child3 = Yoga.Node.create(config);
+ root_child3.setWidth(25);
+ root_child3.setHeight(25);
+ root.insertChild(root_child3, 3);
+ 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(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(25);
+ expect(root_child1.getComputedWidth()).toBe(65);
+ expect(root_child1.getComputedHeight()).toBe(65);
+
+ expect(root_child2.getComputedLeft()).toBe(0);
+ expect(root_child2.getComputedTop()).toBe(90);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(0);
+ expect(root_child3.getComputedTop()).toBe(115);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+
+ 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(75);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(35);
+ expect(root_child1.getComputedTop()).toBe(25);
+ expect(root_child1.getComputedWidth()).toBe(65);
+ expect(root_child1.getComputedHeight()).toBe(65);
+
+ expect(root_child2.getComputedLeft()).toBe(75);
+ expect(root_child2.getComputedTop()).toBe(90);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(75);
+ expect(root_child3.getComputedTop()).toBe(115);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_siblings', () => {
+ 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.setWidth(25);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setPadding(Edge.Left, 10);
+ root_child1.setPadding(Edge.Top, 10);
+ root_child1.setPadding(Edge.Right, 10);
+ root_child1.setPadding(Edge.Bottom, 10);
+ root_child1.setBorder(Edge.Left, 10);
+ root_child1.setBorder(Edge.Top, 10);
+ root_child1.setBorder(Edge.Right, 10);
+ root_child1.setBorder(Edge.Bottom, 10);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+
+ const root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth(25);
+ root_child2.setHeight(25);
+ root.insertChild(root_child2, 2);
+
+ const root_child3 = Yoga.Node.create(config);
+ root_child3.setWidth(25);
+ root_child3.setHeight(25);
+ root.insertChild(root_child3, 3);
+ 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(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(25);
+ expect(root_child1.getComputedWidth()).toBe(40);
+ expect(root_child1.getComputedHeight()).toBe(40);
+
+ expect(root_child2.getComputedLeft()).toBe(0);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(0);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+
+ 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(75);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(25);
+ expect(root_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child1.getComputedLeft()).toBe(60);
+ expect(root_child1.getComputedTop()).toBe(25);
+ expect(root_child1.getComputedWidth()).toBe(40);
+ expect(root_child1.getComputedHeight()).toBe(40);
+
+ expect(root_child2.getComputedLeft()).toBe(75);
+ expect(root_child2.getComputedTop()).toBe(65);
+ expect(root_child2.getComputedWidth()).toBe(25);
+ expect(root_child2.getComputedHeight()).toBe(25);
+
+ expect(root_child3.getComputedLeft()).toBe(75);
+ expect(root_child3.getComputedTop()).toBe(90);
+ expect(root_child3.getComputedWidth()).toBe(25);
+ expect(root_child3.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_max_width', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setMaxWidth(50);
+ root_child0.setHeight(25);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(65);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(65);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(65);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(65);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_max_width', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setMaxWidth(50);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(50);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(50);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(50);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_max_height', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setWidth(50);
+ root_child0.setMaxHeight(50);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_max_height', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setWidth(50);
+ root_child0.setMaxHeight(50);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(50);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(50);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(50);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_min_width', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setMinWidth(50);
+ root_child0.setHeight(25);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(100);
+ expect(root_child0.getComputedHeight()).toBe(65);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(65);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(100);
+ expect(root_child0.getComputedHeight()).toBe(65);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(65);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_min_width', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setMinWidth(50);
+ root_child0.setHeight(25);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(100);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(100);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(40);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_min_height', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setWidth(50);
+ root_child0.setMinHeight(50);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(90);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(90);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(90);
+ expect(root_child0.getComputedHeight()).toBe(90);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(90);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_min_height', () => {
+ 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.setPadding(Edge.Left, 5);
+ root_child0.setPadding(Edge.Top, 5);
+ root_child0.setPadding(Edge.Right, 5);
+ root_child0.setPadding(Edge.Bottom, 5);
+ root_child0.setBorder(Edge.Left, 15);
+ root_child0.setBorder(Edge.Top, 15);
+ root_child0.setBorder(Edge.Right, 15);
+ root_child0.setBorder(Edge.Bottom, 15);
+ root_child0.setWidth(50);
+ root_child0.setMinHeight(50);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(25);
+ root_child1.setHeight(25);
+ root.insertChild(root_child1, 1);
+ 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(50);
+ expect(root_child0.getComputedHeight()).toBe(50);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(50);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+
+ 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(50);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(50);
+ expect(root_child0.getComputedHeight()).toBe(50);
+
+ expect(root_child1.getComputedLeft()).toBe(75);
+ expect(root_child1.getComputedTop()).toBe(50);
+ expect(root_child1.getComputedWidth()).toBe(25);
+ expect(root_child1.getComputedHeight()).toBe(25);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_no_height_no_width', () => {
+ 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.setPadding(Edge.Left, 2);
+ root_child0.setPadding(Edge.Top, 2);
+ root_child0.setPadding(Edge.Right, 2);
+ root_child0.setPadding(Edge.Bottom, 2);
+ root_child0.setBorder(Edge.Left, 7);
+ root_child0.setBorder(Edge.Top, 7);
+ root_child0.setBorder(Edge.Right, 7);
+ root_child0.setBorder(Edge.Bottom, 7);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ 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(100);
+ expect(root_child0.getComputedHeight()).toBe(18);
+
+ 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(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(100);
+ expect(root_child0.getComputedHeight()).toBe(18);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_no_height_no_width', () => {
+ 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.setPadding(Edge.Left, 2);
+ root_child0.setPadding(Edge.Top, 2);
+ root_child0.setPadding(Edge.Right, 2);
+ root_child0.setPadding(Edge.Bottom, 2);
+ root_child0.setBorder(Edge.Left, 7);
+ root_child0.setBorder(Edge.Top, 7);
+ root_child0.setBorder(Edge.Right, 7);
+ root_child0.setBorder(Edge.Bottom, 7);
+ 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(100);
+ expect(root_child0.getComputedHeight()).toBe(18);
+
+ 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(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(100);
+ expect(root_child0.getComputedHeight()).toBe(18);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_nested', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 15);
+ root.setPadding(Edge.Top, 15);
+ root.setPadding(Edge.Right, 15);
+ root.setPadding(Edge.Bottom, 15);
+ root.setBorder(Edge.Left, 3);
+ root.setBorder(Edge.Top, 3);
+ root.setBorder(Edge.Right, 3);
+ root.setBorder(Edge.Bottom, 3);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setPadding(Edge.Left, 2);
+ root_child0.setPadding(Edge.Top, 2);
+ root_child0.setPadding(Edge.Right, 2);
+ root_child0.setPadding(Edge.Bottom, 2);
+ root_child0.setBorder(Edge.Left, 7);
+ root_child0.setBorder(Edge.Top, 7);
+ root_child0.setBorder(Edge.Right, 7);
+ root_child0.setBorder(Edge.Bottom, 7);
+ root_child0.setWidth(20);
+ root_child0.setHeight(20);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setPadding(Edge.Left, 1);
+ root_child0_child0.setPadding(Edge.Top, 1);
+ root_child0_child0.setPadding(Edge.Right, 1);
+ root_child0_child0.setPadding(Edge.Bottom, 1);
+ root_child0_child0.setBorder(Edge.Left, 2);
+ root_child0_child0.setBorder(Edge.Top, 2);
+ root_child0_child0.setBorder(Edge.Right, 2);
+ root_child0_child0.setBorder(Edge.Bottom, 2);
+ root_child0_child0.setWidth(10);
+ root_child0_child0.setHeight(5);
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox);
+ root_child0.insertChild(root_child0_child0, 0);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(136);
+ expect(root.getComputedHeight()).toBe(136);
+
+ expect(root_child0.getComputedLeft()).toBe(18);
+ expect(root_child0.getComputedTop()).toBe(18);
+ expect(root_child0.getComputedWidth()).toBe(38);
+ expect(root_child0.getComputedHeight()).toBe(38);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(9);
+ expect(root_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0.getComputedWidth()).toBe(16);
+ expect(root_child0_child0.getComputedHeight()).toBe(11);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(136);
+ expect(root.getComputedHeight()).toBe(136);
+
+ expect(root_child0.getComputedLeft()).toBe(80);
+ expect(root_child0.getComputedTop()).toBe(18);
+ expect(root_child0.getComputedWidth()).toBe(38);
+ expect(root_child0.getComputedHeight()).toBe(38);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(13);
+ expect(root_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0.getComputedWidth()).toBe(16);
+ expect(root_child0_child0.getComputedHeight()).toBe(11);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('box_sizing_border_box_nested', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 15);
+ root.setPadding(Edge.Top, 15);
+ root.setPadding(Edge.Right, 15);
+ root.setPadding(Edge.Bottom, 15);
+ root.setBorder(Edge.Left, 3);
+ root.setBorder(Edge.Top, 3);
+ root.setBorder(Edge.Right, 3);
+ root.setBorder(Edge.Bottom, 3);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setPadding(Edge.Left, 2);
+ root_child0.setPadding(Edge.Top, 2);
+ root_child0.setPadding(Edge.Right, 2);
+ root_child0.setPadding(Edge.Bottom, 2);
+ root_child0.setBorder(Edge.Left, 7);
+ root_child0.setBorder(Edge.Top, 7);
+ root_child0.setBorder(Edge.Right, 7);
+ root_child0.setBorder(Edge.Bottom, 7);
+ root_child0.setWidth(20);
+ root_child0.setHeight(20);
+ root.insertChild(root_child0, 0);
+
+ const root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setPadding(Edge.Left, 1);
+ root_child0_child0.setPadding(Edge.Top, 1);
+ root_child0_child0.setPadding(Edge.Right, 1);
+ root_child0_child0.setPadding(Edge.Bottom, 1);
+ root_child0_child0.setBorder(Edge.Left, 2);
+ root_child0_child0.setBorder(Edge.Top, 2);
+ root_child0_child0.setBorder(Edge.Right, 2);
+ root_child0_child0.setBorder(Edge.Bottom, 2);
+ root_child0_child0.setWidth(10);
+ root_child0_child0.setHeight(5);
+ root_child0.insertChild(root_child0_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(18);
+ expect(root_child0.getComputedTop()).toBe(18);
+ expect(root_child0.getComputedWidth()).toBe(20);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(9);
+ expect(root_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0.getComputedWidth()).toBe(10);
+ expect(root_child0_child0.getComputedHeight()).toBe(6);
+
+ 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(62);
+ expect(root_child0.getComputedTop()).toBe(18);
+ expect(root_child0.getComputedWidth()).toBe(20);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(1);
+ expect(root_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0.getComputedWidth()).toBe(10);
+ expect(root_child0_child0.getComputedHeight()).toBe(6);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_content_box_nested_alternating', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 3);
+ root.setPadding(Edge.Top, 3);
+ root.setPadding(Edge.Right, 3);
+ root.setPadding(Edge.Bottom, 3);
+ root.setBorder(Edge.Left, 2);
+ root.setBorder(Edge.Top, 2);
+ root.setBorder(Edge.Right, 2);
+ root.setBorder(Edge.Bottom, 2);
+ root.setWidth(100);
+ root.setHeight(100);
+ root.setBoxSizing(BoxSizing.ContentBox);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setPadding(Edge.Left, 8);
+ root_child0.setPadding(Edge.Top, 8);
+ root_child0.setPadding(Edge.Right, 8);
+ root_child0.setPadding(Edge.Bottom, 8);
+ root_child0.setBorder(Edge.Left, 2);
+ root_child0.setBorder(Edge.Top, 2);
+ root_child0.setBorder(Edge.Right, 2);
+ root_child0.setBorder(Edge.Bottom, 2);
+ root_child0.setWidth(40);
+ root_child0.setHeight(40);
+ root.insertChild(root_child0, 0);
+
+ const root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setPadding(Edge.Left, 3);
+ root_child0_child0.setPadding(Edge.Top, 3);
+ root_child0_child0.setPadding(Edge.Right, 3);
+ root_child0_child0.setPadding(Edge.Bottom, 3);
+ root_child0_child0.setBorder(Edge.Left, 6);
+ root_child0_child0.setBorder(Edge.Top, 6);
+ root_child0_child0.setBorder(Edge.Right, 6);
+ root_child0_child0.setBorder(Edge.Bottom, 6);
+ root_child0_child0.setWidth(20);
+ root_child0_child0.setHeight(25);
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox);
+ root_child0.insertChild(root_child0_child0, 0);
+
+ const root_child0_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0_child0.setPadding(Edge.Left, 1);
+ root_child0_child0_child0.setPadding(Edge.Top, 1);
+ root_child0_child0_child0.setPadding(Edge.Right, 1);
+ root_child0_child0_child0.setPadding(Edge.Bottom, 1);
+ root_child0_child0_child0.setBorder(Edge.Left, 1);
+ root_child0_child0_child0.setBorder(Edge.Top, 1);
+ root_child0_child0_child0.setBorder(Edge.Right, 1);
+ root_child0_child0_child0.setBorder(Edge.Bottom, 1);
+ root_child0_child0_child0.setWidth(10);
+ root_child0_child0_child0.setHeight(5);
+ root_child0_child0.insertChild(root_child0_child0_child0, 0);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(110);
+ expect(root.getComputedHeight()).toBe(110);
+
+ expect(root_child0.getComputedLeft()).toBe(5);
+ expect(root_child0.getComputedTop()).toBe(5);
+ expect(root_child0.getComputedWidth()).toBe(40);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(10);
+ expect(root_child0_child0.getComputedTop()).toBe(10);
+ expect(root_child0_child0.getComputedWidth()).toBe(38);
+ expect(root_child0_child0.getComputedHeight()).toBe(43);
+
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10);
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(110);
+ expect(root.getComputedHeight()).toBe(110);
+
+ expect(root_child0.getComputedLeft()).toBe(65);
+ expect(root_child0.getComputedTop()).toBe(5);
+ expect(root_child0.getComputedWidth()).toBe(40);
+ expect(root_child0.getComputedHeight()).toBe(40);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(-8);
+ expect(root_child0_child0.getComputedTop()).toBe(10);
+ expect(root_child0_child0.getComputedWidth()).toBe(38);
+ expect(root_child0_child0.getComputedHeight()).toBe(43);
+
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(19);
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10);
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('box_sizing_border_box_nested_alternating', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setPadding(Edge.Left, 3);
+ root.setPadding(Edge.Top, 3);
+ root.setPadding(Edge.Right, 3);
+ root.setPadding(Edge.Bottom, 3);
+ root.setBorder(Edge.Left, 2);
+ root.setBorder(Edge.Top, 2);
+ root.setBorder(Edge.Right, 2);
+ root.setBorder(Edge.Bottom, 2);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setPadding(Edge.Left, 8);
+ root_child0.setPadding(Edge.Top, 8);
+ root_child0.setPadding(Edge.Right, 8);
+ root_child0.setPadding(Edge.Bottom, 8);
+ root_child0.setBorder(Edge.Left, 2);
+ root_child0.setBorder(Edge.Top, 2);
+ root_child0.setBorder(Edge.Right, 2);
+ root_child0.setBorder(Edge.Bottom, 2);
+ root_child0.setWidth(40);
+ root_child0.setHeight(40);
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
+ root.insertChild(root_child0, 0);
+
+ const root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setPadding(Edge.Left, 3);
+ root_child0_child0.setPadding(Edge.Top, 3);
+ root_child0_child0.setPadding(Edge.Right, 3);
+ root_child0_child0.setPadding(Edge.Bottom, 3);
+ root_child0_child0.setBorder(Edge.Left, 6);
+ root_child0_child0.setBorder(Edge.Top, 6);
+ root_child0_child0.setBorder(Edge.Right, 6);
+ root_child0_child0.setBorder(Edge.Bottom, 6);
+ root_child0_child0.setWidth(20);
+ root_child0_child0.setHeight(25);
+ root_child0.insertChild(root_child0_child0, 0);
+
+ const root_child0_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0_child0.setPadding(Edge.Left, 1);
+ root_child0_child0_child0.setPadding(Edge.Top, 1);
+ root_child0_child0_child0.setPadding(Edge.Right, 1);
+ root_child0_child0_child0.setPadding(Edge.Bottom, 1);
+ root_child0_child0_child0.setBorder(Edge.Left, 1);
+ root_child0_child0_child0.setBorder(Edge.Top, 1);
+ root_child0_child0_child0.setBorder(Edge.Right, 1);
+ root_child0_child0_child0.setBorder(Edge.Bottom, 1);
+ root_child0_child0_child0.setWidth(10);
+ root_child0_child0_child0.setHeight(5);
+ root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox);
+ root_child0_child0.insertChild(root_child0_child0_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(5);
+ expect(root_child0.getComputedTop()).toBe(5);
+ expect(root_child0.getComputedWidth()).toBe(60);
+ expect(root_child0.getComputedHeight()).toBe(60);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(10);
+ expect(root_child0_child0.getComputedTop()).toBe(10);
+ expect(root_child0_child0.getComputedWidth()).toBe(20);
+ expect(root_child0_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14);
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9);
+
+ 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(35);
+ expect(root_child0.getComputedTop()).toBe(5);
+ expect(root_child0.getComputedWidth()).toBe(60);
+ expect(root_child0.getComputedHeight()).toBe(60);
+
+ expect(root_child0_child0.getComputedLeft()).toBe(30);
+ expect(root_child0_child0.getComputedTop()).toBe(10);
+ expect(root_child0_child0.getComputedWidth()).toBe(20);
+ expect(root_child0_child0.getComputedHeight()).toBe(25);
+
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(-3);
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14);
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
diff --git a/javascript/tests/generated/YGDimensionTest.test.ts b/javascript/tests/generated/YGDimensionTest.test.ts
index 76cd571653..39c140df0e 100644
--- a/javascript/tests/generated/YGDimensionTest.test.ts
+++ b/javascript/tests/generated/YGDimensionTest.test.ts
@@ -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<<51018ace00a5b85422b92cec7acc9f4d>>
+ * @generated SignedSource<<719c8f3b9fea672881a47f593f4aabd0>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGDisplayTest.test.ts b/javascript/tests/generated/YGDisplayTest.test.ts
index a35c7498ae..fa2f0b41fe 100644
--- a/javascript/tests/generated/YGDisplayTest.test.ts
+++ b/javascript/tests/generated/YGDisplayTest.test.ts
@@ -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<>
+ * @generated SignedSource<<1f15f9628f43eed206466695ec6e683c>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGFlexDirectionTest.test.ts b/javascript/tests/generated/YGFlexDirectionTest.test.ts
index cbc5aa07d2..2999befc5e 100644
--- a/javascript/tests/generated/YGFlexDirectionTest.test.ts
+++ b/javascript/tests/generated/YGFlexDirectionTest.test.ts
@@ -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<<5cc8e03bdba27ff2003afbde3b5ed0b7>>
+ * @generated SignedSource<<285a0c9dd4b646e7b1af77658fc41d99>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGFlexTest.test.ts b/javascript/tests/generated/YGFlexTest.test.ts
index 65c9525814..6eee8e8640 100644
--- a/javascript/tests/generated/YGFlexTest.test.ts
+++ b/javascript/tests/generated/YGFlexTest.test.ts
@@ -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<<0b2282a5a0b35e95e7e27417e6b25ff6>>
+ * @generated SignedSource<<60e19ea0b6b108cd6b0d4062c0b0316d>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGFlexWrapTest.test.ts b/javascript/tests/generated/YGFlexWrapTest.test.ts
index 85994ff78e..28ee4cee2e 100644
--- a/javascript/tests/generated/YGFlexWrapTest.test.ts
+++ b/javascript/tests/generated/YGFlexWrapTest.test.ts
@@ -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<<11f5ca827ba97151a67ab3f05cf48f53>>
+ * @generated SignedSource<<5c4e3faf7c401d359b341c41a3055313>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGGapTest.test.ts b/javascript/tests/generated/YGGapTest.test.ts
index 54bb085fcc..d38f592eaa 100644
--- a/javascript/tests/generated/YGGapTest.test.ts
+++ b/javascript/tests/generated/YGGapTest.test.ts
@@ -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<>
+ * @generated SignedSource<<3fad56933a314f0a81b6ed504040ffae>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts
index d272ceff80..b0f27c05f1 100644
--- a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts
+++ b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts
@@ -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<<63249d156daefb8d7d536b57c7d8cb70>>
+ * @generated SignedSource<>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGJustifyContentTest.test.ts b/javascript/tests/generated/YGJustifyContentTest.test.ts
index 22f8d3e973..97869b22a3 100644
--- a/javascript/tests/generated/YGJustifyContentTest.test.ts
+++ b/javascript/tests/generated/YGJustifyContentTest.test.ts
@@ -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<>
+ * @generated SignedSource<<4d367d399575872c385f254588d91fb5>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGMarginTest.test.ts b/javascript/tests/generated/YGMarginTest.test.ts
index d5d655fdf3..8046de55d0 100644
--- a/javascript/tests/generated/YGMarginTest.test.ts
+++ b/javascript/tests/generated/YGMarginTest.test.ts
@@ -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<<910ea7258ef002557289f475dc74f3dc>>
+ * @generated SignedSource<<3a4aaa192f950239104218a9666654c1>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts
index 936ee3c484..dfe3773f5e 100644
--- a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts
+++ b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts
@@ -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<>
+ * @generated SignedSource<<1bd782301afbab34ed3c9a296c3ecaa6>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGPaddingTest.test.ts b/javascript/tests/generated/YGPaddingTest.test.ts
index 7262148eed..474a80821e 100644
--- a/javascript/tests/generated/YGPaddingTest.test.ts
+++ b/javascript/tests/generated/YGPaddingTest.test.ts
@@ -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<<2e4b35c2408710c0aabaa82e43e157cb>>
+ * @generated SignedSource<<07e65137c3055db0090d46067ec69d5e>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGPercentageTest.test.ts b/javascript/tests/generated/YGPercentageTest.test.ts
index 587b93b32f..4f95fb28cb 100644
--- a/javascript/tests/generated/YGPercentageTest.test.ts
+++ b/javascript/tests/generated/YGPercentageTest.test.ts
@@ -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<<6af8e434b1131c83b7feb6ff04a2dffd>>
+ * @generated SignedSource<<091fb5c6d9004e40211bba58ac19d686>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGRoundingTest.test.ts b/javascript/tests/generated/YGRoundingTest.test.ts
index fa18597da9..ca653f138c 100644
--- a/javascript/tests/generated/YGRoundingTest.test.ts
+++ b/javascript/tests/generated/YGRoundingTest.test.ts
@@ -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<<203f3aa8922cb3fa03e7946f91a6ed2d>>
+ * @generated SignedSource<<8119d2703019b25513720167cb4dea4e>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGSizeOverflowTest.test.ts b/javascript/tests/generated/YGSizeOverflowTest.test.ts
index c11b26847c..325dd26db1 100644
--- a/javascript/tests/generated/YGSizeOverflowTest.test.ts
+++ b/javascript/tests/generated/YGSizeOverflowTest.test.ts
@@ -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<>
+ * @generated SignedSource<>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/javascript/tests/generated/YGStaticPositionTest.test.ts b/javascript/tests/generated/YGStaticPositionTest.test.ts
index 3c1e48512a..0c2bd37327 100644
--- a/javascript/tests/generated/YGStaticPositionTest.test.ts
+++ b/javascript/tests/generated/YGStaticPositionTest.test.ts
@@ -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<>
+ * @generated SignedSource<>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
*/
@@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
+ BoxSizing,
Direction,
Display,
Edge,
diff --git a/tests/generated/YGBoxSizingTest.cpp b/tests/generated/YGBoxSizingTest.cpp
new file mode 100644
index 0000000000..1728a7a7a1
--- /dev/null
+++ b/tests/generated/YGBoxSizingTest.cpp
@@ -0,0 +1,1648 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * clang-format off
+ * @generated SignedSource<<38c0ba6ef126d3453c7e0b56da131566>>
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
+ */
+
+#include
+#include
+#include "../util/TestUtil.h"
+
+TEST(YogaTest, box_sizing_content_box) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ 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));
+
+ 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));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_padding_only) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_padding_only) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ 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));
+
+ 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));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_border_only) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_border_only) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ 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));
+
+ 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));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_no_padding_no_border) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+ 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));
+
+ 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));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_no_padding_no_border) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ 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));
+
+ 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));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_children) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0, 25);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child2, 25);
+ YGNodeStyleSetHeight(root_child2, 25);
+ YGNodeInsertChild(root, root_child2, 2);
+
+ YGNodeRef root_child3 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child3, 25);
+ YGNodeStyleSetHeight(root_child3, 25);
+ YGNodeInsertChild(root, root_child3, 3);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_children) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0, 25);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child2, 25);
+ YGNodeStyleSetHeight(root_child2, 25);
+ YGNodeInsertChild(root, root_child2, 2);
+
+ YGNodeRef root_child3 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child3, 25);
+ YGNodeStyleSetHeight(root_child3, 25);
+ YGNodeInsertChild(root, root_child3, 3);
+ 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(15, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ 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(60, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_siblings) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0, 25);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeStyleSetBoxSizing(root_child1, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child2, 25);
+ YGNodeStyleSetHeight(root_child2, 25);
+ YGNodeInsertChild(root, root_child2, 2);
+
+ YGNodeRef root_child3 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child3, 25);
+ YGNodeStyleSetHeight(root_child3, 25);
+ YGNodeInsertChild(root, root_child3, 3);
+ 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(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ 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(75, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(35, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_siblings) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0, 25);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10);
+ YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeTop, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeRight, 10);
+ YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child2, 25);
+ YGNodeStyleSetHeight(root_child2, 25);
+ YGNodeInsertChild(root, root_child2, 2);
+
+ YGNodeRef root_child3 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child3, 25);
+ YGNodeStyleSetHeight(root_child3, 25);
+ YGNodeInsertChild(root, root_child3, 3);
+ 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(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ 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(75, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_max_width) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetMaxWidth(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_max_width) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetMaxWidth(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(50, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_max_height) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetWidth(root_child0, 50);
+ YGNodeStyleSetMaxHeight(root_child0, 50);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_max_height) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetWidth(root_child0, 50);
+ YGNodeStyleSetMaxHeight(root_child0, 50);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(50, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_min_width) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetMinWidth(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_min_width) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetMinWidth(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 25);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_min_height) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetWidth(root_child0, 50);
+ YGNodeStyleSetMinHeight(root_child0, 50);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(90, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_min_height) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15);
+ YGNodeStyleSetWidth(root_child0, 50);
+ YGNodeStyleSetMinHeight(root_child0, 50);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 25);
+ YGNodeStyleSetHeight(root_child1, 25);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ 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(50, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_no_height_no_width) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ 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(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(18, 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(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_no_height_no_width) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7);
+ 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(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(18, 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(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_nested) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 15);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 15);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 15);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 15);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 3);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 3);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 3);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 3);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7);
+ YGNodeStyleSetWidth(root_child0, 20);
+ YGNodeStyleSetHeight(root_child0, 20);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root_child0_child0, 10);
+ YGNodeStyleSetHeight(root_child0_child0, 5);
+ YGNodeStyleSetBoxSizing(root_child0_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(136, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(16, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(136, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(16, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_nested) {
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 15);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 15);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 15);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 15);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 3);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 3);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 3);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 3);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7);
+ YGNodeStyleSetWidth(root_child0, 20);
+ YGNodeStyleSetHeight(root_child0, 20);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root_child0_child0, 10);
+ YGNodeStyleSetHeight(root_child0_child0, 5);
+ YGNodeInsertChild(root_child0, root_child0_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(18, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_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(62, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_content_box_nested_alternating) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 3);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 3);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 3);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 3);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 8);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root_child0, 40);
+ YGNodeStyleSetHeight(root_child0, 40);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 3);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 6);
+ YGNodeStyleSetWidth(root_child0_child0, 20);
+ YGNodeStyleSetHeight(root_child0_child0, 25);
+ YGNodeStyleSetBoxSizing(root_child0_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetWidth(root_child0_child0_child0, 10);
+ YGNodeStyleSetHeight(root_child0_child0_child0, 5);
+ YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(43, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child0_child0_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(65, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(-8, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(43, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(19, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child0_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, box_sizing_border_box_nested_alternating) {
+ GTEST_SKIP();
+
+ YGConfigRef config = YGConfigNew();
+
+ YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetPadding(root, YGEdgeLeft, 3);
+ YGNodeStyleSetPadding(root, YGEdgeTop, 3);
+ YGNodeStyleSetPadding(root, YGEdgeRight, 3);
+ YGNodeStyleSetPadding(root, YGEdgeBottom, 3);
+ YGNodeStyleSetBorder(root, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeTop, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeRight, 8);
+ YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 8);
+ YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeTop, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeRight, 2);
+ YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 2);
+ YGNodeStyleSetWidth(root_child0, 40);
+ YGNodeStyleSetHeight(root_child0, 40);
+ YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 3);
+ YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 3);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 6);
+ YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 6);
+ YGNodeStyleSetWidth(root_child0_child0, 20);
+ YGNodeStyleSetHeight(root_child0_child0, 25);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 1);
+ YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 1);
+ YGNodeStyleSetWidth(root_child0_child0_child0, 10);
+ YGNodeStyleSetHeight(root_child0_child0_child0, 5);
+ YGNodeStyleSetBoxSizing(root_child0_child0_child0, YGBoxSizingContentBox);
+ YGNodeInsertChild(root_child0_child0, root_child0_child0_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(5, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(14, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetHeight(root_child0_child0_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(35, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(-3, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(14, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(9, YGNodeLayoutGetHeight(root_child0_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
diff --git a/yoga/YGEnums.cpp b/yoga/YGEnums.cpp
index 222a5d12a4..1d4975b138 100644
--- a/yoga/YGEnums.cpp
+++ b/yoga/YGEnums.cpp
@@ -33,6 +33,16 @@ const char* YGAlignToString(const YGAlign value) {
return "unknown";
}
+const char* YGBoxSizingToString(const YGBoxSizing value) {
+ switch (value) {
+ case YGBoxSizingContentBox:
+ return "content-box";
+ case YGBoxSizingBorderBox:
+ return "border-box";
+ }
+ return "unknown";
+}
+
const char* YGDimensionToString(const YGDimension value) {
switch (value) {
case YGDimensionWidth:
diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h
index 44335277fc..8a2161a907 100644
--- a/yoga/YGEnums.h
+++ b/yoga/YGEnums.h
@@ -24,6 +24,11 @@ YG_ENUM_DECL(
YGAlignSpaceAround,
YGAlignSpaceEvenly)
+YG_ENUM_DECL(
+ YGBoxSizing,
+ YGBoxSizingContentBox,
+ YGBoxSizingBorderBox)
+
YG_ENUM_DECL(
YGDimension,
YGDimensionWidth,
diff --git a/yoga/YGNodeStyle.cpp b/yoga/YGNodeStyle.cpp
index 67e6e42e77..d2a10b0591 100644
--- a/yoga/YGNodeStyle.cpp
+++ b/yoga/YGNodeStyle.cpp
@@ -296,6 +296,15 @@ float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
return op.isUndefined() ? YGUndefined : op.unwrap();
}
+void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing) {
+ updateStyle<&Style::boxSizing, &Style::setBoxSizing>(
+ node, scopedEnum(boxSizing));
+}
+
+YGBoxSizing YGNodeStyleGetBoxSizing(const YGNodeConstRef node) {
+ return unscopedEnum(resolveRef(node)->style().boxSizing());
+}
+
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
updateStyle<&Style::dimension, &Style::setDimension>(
node, Dimension::Width, value::points(points));
diff --git a/yoga/YGNodeStyle.h b/yoga/YGNodeStyle.h
index fad71e4f07..2746a4a00a 100644
--- a/yoga/YGNodeStyle.h
+++ b/yoga/YGNodeStyle.h
@@ -95,6 +95,9 @@ YG_EXPORT void
YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength);
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
+YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
+YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
+
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width);
YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
diff --git a/yoga/enums/BoxSizing.h b/yoga/enums/BoxSizing.h
new file mode 100644
index 0000000000..1b6b9a7cd2
--- /dev/null
+++ b/yoga/enums/BoxSizing.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+// @generated by enums.py
+// clang-format off
+#pragma once
+
+#include
+#include
+#include
+
+namespace facebook::yoga {
+
+enum class BoxSizing : uint8_t {
+ ContentBox = YGBoxSizingContentBox,
+ BorderBox = YGBoxSizingBorderBox,
+};
+
+template <>
+constexpr int32_t ordinalCount() {
+ return 2;
+}
+
+constexpr BoxSizing scopedEnum(YGBoxSizing unscoped) {
+ return static_cast(unscoped);
+}
+
+constexpr YGBoxSizing unscopedEnum(BoxSizing scoped) {
+ return static_cast(scoped);
+}
+
+inline const char* toString(BoxSizing e) {
+ return YGBoxSizingToString(unscopedEnum(e));
+}
+
+} // namespace facebook::yoga
diff --git a/yoga/style/Style.h b/yoga/style/Style.h
index 141540cf5e..f1600ce070 100644
--- a/yoga/style/Style.h
+++ b/yoga/style/Style.h
@@ -15,6 +15,7 @@
#include
#include
+#include
#include
#include
#include
@@ -206,6 +207,13 @@ class YG_EXPORT Style {
value == 0.0f || std::isinf(value.unwrap()) ? FloatOptional{} : value);
}
+ BoxSizing boxSizing() const {
+ return boxSizing_;
+ }
+ void setBoxSizing(BoxSizing value) {
+ boxSizing_ = value;
+ }
+
bool horizontalInsetsDefined() const {
return position_[yoga::to_underlying(Edge::Left)].isDefined() ||
position_[yoga::to_underlying(Edge::Right)].isDefined() ||
@@ -675,6 +683,7 @@ class YG_EXPORT Style {
Wrap flexWrap_ : bitCount() = Wrap::NoWrap;
Overflow overflow_ : bitCount() = Overflow::Visible;
Display display_ : bitCount() = Display::Flex;
+ BoxSizing boxSizing_ : bitCount() = BoxSizing::BorderBox;
StyleValueHandle flex_{};
StyleValueHandle flexGrow_{};