From 435f1f6a1254aed543ce1c57921c2153d9db485a Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Sun, 11 Dec 2016 15:58:30 +0100 Subject: [PATCH 01/39] added percentage feature --- .gitignore | 5 + csharp/Yoga/YGInterop.cpp | 2 +- enums.py | 4 + yoga/YGEnums.h | 6 + yoga/Yoga.c | 742 +++++++++++++++++++++++--------------- yoga/Yoga.h | 47 ++- 6 files changed, 501 insertions(+), 305 deletions(-) diff --git a/.gitignore b/.gitignore index 5b346768..42953e20 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,8 @@ # Visual studio code .vscode +*.pdb +*.tlog +*.obj +*.pch +*.log diff --git a/csharp/Yoga/YGInterop.cpp b/csharp/Yoga/YGInterop.cpp index fc2043dc..63181112 100644 --- a/csharp/Yoga/YGInterop.cpp +++ b/csharp/Yoga/YGInterop.cpp @@ -15,7 +15,7 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { int result = 0; if (gManagedFunc) { char buffer[256]; - result = vsnprintf(buffer, sizeof(buffer), format, args); + result = vsnprintf_s(buffer, sizeof(buffer), format, args); (*gManagedFunc)(level, buffer); } return result; diff --git a/enums.py b/enums.py index d2fc6dc0..e51d3ee8 100644 --- a/enums.py +++ b/enums.py @@ -16,6 +16,10 @@ ENUMS = { 'Inherit', 'LTR', 'RTL', + ], + 'Unit': [ + 'Pixel', + 'Percent', ], 'FlexDirection': [ 'Column', diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 85d9d2f9..32a56ff6 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -21,6 +21,12 @@ typedef enum YGFlexDirection { YGFlexDirectionCount, } YGFlexDirection; +typedef enum YGUnit { + YGUnitPixel, + YGUnitPercent, + YGUnitModeCount, +} YGUnit; + typedef enum YGMeasureMode { YGMeasureModeUndefined, YGMeasureModeExactly, diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 29acb459..39b01cc3 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -77,14 +77,14 @@ typedef struct YGStyle { float flex; float flexGrow; float flexShrink; - float flexBasis; - float margin[YGEdgeCount]; - float position[YGEdgeCount]; - float padding[YGEdgeCount]; - float border[YGEdgeCount]; - float dimensions[2]; - float minDimensions[2]; - float maxDimensions[2]; + YGValue flexBasis; + YGValue margin[YGEdgeCount]; + YGValue position[YGEdgeCount]; + YGValue padding[YGEdgeCount]; + YGValue border[YGEdgeCount]; + YGValue dimensions[2]; + YGValue minDimensions[2]; + YGValue maxDimensions[2]; // Yoga specific properties, not compatible with flexbox specification float aspectRatio; @@ -156,7 +156,7 @@ static int YGDefaultLog(YGLogLevel level, const char *format, va_list args) { static YGLogger gLogger = &YGDefaultLog; #endif -static inline float YGComputedEdgeValue(const float edges[YGEdgeCount], +static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const YGEdge edge, const float defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); @@ -179,10 +179,26 @@ static inline float YGComputedEdgeValue(const float edges[YGEdgeCount], } if (edge == YGEdgeStart || edge == YGEdgeEnd) { - return YGUndefined; + YGValue result; + result.value = YGUndefined; + result.defined = false; + result.unit = YGUnitPixel; + return result; } - return defaultValue; + YGValue result; + result.value = defaultValue; + result.defined = (defaultValue < 0 || defaultValue >= 0); /* is faster than a nan function call and enough at this point */ + result.unit = YGUnitPixel; + return result; +} + +static inline float YGValueToFloat(const YGValue unit, const float parentSize) { + if (unit.unit == YGUnitPixel){ + return unit.value; + } else { + return unit.value * parentSize / 100.0f; + } } static void YGNodeInit(const YGNodeRef node) { @@ -194,7 +210,9 @@ static void YGNodeInit(const YGNodeRef node) { node->style.flex = YGUndefined; node->style.flexGrow = YGUndefined; node->style.flexShrink = YGUndefined; - node->style.flexBasis = YGUndefined; + node->style.flexBasis.value = YGUndefined; + node->style.flexBasis.defined = false; + node->style.flexBasis.unit = YGUnitPixel; node->style.alignItems = YGAlignStretch; node->style.alignContent = YGAlignFlexStart; @@ -205,20 +223,40 @@ static void YGNodeInit(const YGNodeRef node) { node->style.overflow = YGOverflowVisible; // Some of the fields default to undefined and not 0 - node->style.dimensions[YGDimensionWidth] = YGUndefined; - node->style.dimensions[YGDimensionHeight] = YGUndefined; + node->style.dimensions[YGDimensionWidth].value = YGUndefined; + node->style.dimensions[YGDimensionWidth].defined = false; + node->style.dimensions[YGDimensionWidth].unit = YGUnitPixel; + node->style.dimensions[YGDimensionHeight].value = YGUndefined; + node->style.dimensions[YGDimensionHeight].defined = false; + node->style.dimensions[YGDimensionHeight].unit = YGUnitPixel; - node->style.minDimensions[YGDimensionWidth] = YGUndefined; - node->style.minDimensions[YGDimensionHeight] = YGUndefined; + node->style.minDimensions[YGDimensionWidth].value = YGUndefined; + node->style.minDimensions[YGDimensionWidth].defined = false; + node->style.minDimensions[YGDimensionWidth].unit = YGUnitPixel; + node->style.minDimensions[YGDimensionHeight].value = YGUndefined; + node->style.minDimensions[YGDimensionHeight].defined = false; + node->style.minDimensions[YGDimensionHeight].unit = YGUnitPixel; - node->style.maxDimensions[YGDimensionWidth] = YGUndefined; - node->style.maxDimensions[YGDimensionHeight] = YGUndefined; + node->style.maxDimensions[YGDimensionWidth].value = YGUndefined; + node->style.maxDimensions[YGDimensionWidth].defined = false; + node->style.maxDimensions[YGDimensionWidth].unit = YGUnitPixel; + node->style.maxDimensions[YGDimensionHeight].value = YGUndefined; + node->style.maxDimensions[YGDimensionHeight].defined = false; + node->style.maxDimensions[YGDimensionHeight].unit = YGUnitPixel; for (YGEdge edge = YGEdgeLeft; edge < YGEdgeCount; edge++) { - node->style.position[edge] = YGUndefined; - node->style.margin[edge] = YGUndefined; - node->style.padding[edge] = YGUndefined; - node->style.border[edge] = YGUndefined; + node->style.position[edge].value = YGUndefined; + node->style.position[edge].defined = false; + node->style.position[edge].unit = YGUnitPixel; + node->style.margin[edge].value = YGUndefined; + node->style.margin[edge].defined = false; + node->style.margin[edge].unit = YGUnitPixel; + node->style.padding[edge].value = YGUndefined; + node->style.padding[edge].defined = false; + node->style.padding[edge].unit = YGUnitPixel; + node->style.border[edge].value = YGUndefined; + node->style.border[edge].defined = false; + node->style.border[edge].unit = YGUnitPixel; } node->style.aspectRatio = YGUndefined; @@ -241,6 +279,22 @@ static void YGNodeInit(const YGNodeRef node) { int32_t gNodeInstanceCount = 0; +YGValue YGPx(const float value){ + YGValue result; + result.value = value; + result.defined = !YGValueIsUndefinedf(value); + result.unit = YGUnitPixel; + return result; +} + +YGValue YGPercent(const float value){ + YGValue result; + result.value = value; + result.defined = !YGValueIsUndefinedf(value); + result.unit = YGUnitPercent; + return result; +} + YGNodeRef YGNodeNew(void) { const YGNodeRef node = gYGCalloc(1, sizeof(YGNode)); YG_ASSERT(node, "Could not allocate memory for node"); @@ -356,20 +410,20 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) { } inline float YGNodeStyleGetFlexGrow(const YGNodeRef node) { - if (!YGValueIsUndefined(node->style.flexGrow)) { + if (!YGValueIsUndefinedf(node->style.flexGrow)) { return node->style.flexGrow; } - if (!YGValueIsUndefined(node->style.flex) && node->style.flex > 0) { + if (!YGValueIsUndefinedf(node->style.flex) && node->style.flex > 0) { return node->style.flex; } return 0; } inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { - if (!YGValueIsUndefined(node->style.flexShrink)) { + if (!YGValueIsUndefinedf(node->style.flexShrink)) { return node->style.flexShrink; } - if (!YGValueIsUndefined(node->style.flex) && node->style.flex < 0) { + if (!YGValueIsUndefinedf(node->style.flex) && node->style.flex < 0) { return -node->style.flex; } return 0; @@ -377,14 +431,24 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { inline float YGNodeStyleGetFlexBasis(const YGNodeRef node) { if (!YGValueIsUndefined(node->style.flexBasis)) { - return node->style.flexBasis; + return node->style.flexBasis.value; } - if (!YGValueIsUndefined(node->style.flex)) { + if (!YGValueIsUndefinedf(node->style.flex)) { return node->style.flex > 0 ? 0 : YGUndefined; } return YGUndefined; } +inline YGValue YGNodeStyleGetFlexBasisWithUnit(const YGNodeRef node) { + if (!YGValueIsUndefined(node->style.flexBasis)) { + return node->style.flexBasis; + } + if (!YGValueIsUndefinedf(node->style.flex)) { + return YGPx(node->style.flex > 0 ? 0 : YGUndefined); + } + return YGPx(YGUndefined); +} + void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { if (node->style.flex != flex) { node->style.flex = flex; @@ -409,6 +473,24 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } \ } +#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ + void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName) { \ + if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ + node->style.instanceName.value = paramName.value; \ + node->style.instanceName.defined = !YGValueIsUndefinedf(paramName.value); \ + node->style.instanceName.unit = paramName.unit; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + void YGNodeStyleSet##name(const YGNodeRef node, const float paramName) { \ + if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPixel) { \ + node->style.instanceName.value = paramName; \ + node->style.instanceName.defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName.unit = YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } + #define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \ YG_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \ \ @@ -416,18 +498,43 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { return node->style.instanceName; \ } -#define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName, defaultValue) \ - void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const type paramName) { \ - if (node->style.instanceName[edge] != paramName) { \ - node->style.instanceName[edge] = paramName; \ - YGNodeMarkDirtyInternal(node); \ - } \ - } \ - \ - type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue); \ +#define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ + \ + float YGNodeStyleGet##name(const YGNodeRef node) { \ + return node->style.instanceName.value; \ + } \ + type YGNodeStyleGet##name##WithUnit(const YGNodeRef node) { \ + return node->style.instanceName; \ } +#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName, defaultValue) \ + void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const YGEdge edge, const type paramName) { \ + if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ + node->style.instanceName[edge].value = paramName.value; \ + node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName.value); \ + node->style.instanceName[edge].unit = paramName.unit; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName[edge].unit = YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + type YGNodeStyleGet##name##WithUnit(const YGNodeRef node, const YGEdge edge) { \ + return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue); \ + } \ + \ + float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ + return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue).value; \ + } + #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node) { \ return node->layout.instanceName; \ @@ -449,19 +556,19 @@ YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink); -YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexBasis, flexBasis, flexBasis); +YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis); -YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Position, position, position, YGUndefined); -YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Margin, margin, margin, 0); -YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Padding, padding, padding, 0); -YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, 0); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGUndefined); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, 0); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding, 0); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Border, border, border, 0); -YG_NODE_STYLE_PROPERTY_IMPL(float, Width, width, dimensions[YGDimensionWidth]); -YG_NODE_STYLE_PROPERTY_IMPL(float, Height, height, dimensions[YGDimensionHeight]); -YG_NODE_STYLE_PROPERTY_IMPL(float, MinWidth, minWidth, minDimensions[YGDimensionWidth]); -YG_NODE_STYLE_PROPERTY_IMPL(float, MinHeight, minHeight, minDimensions[YGDimensionHeight]); -YG_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[YGDimensionWidth]); -YG_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[YGDimensionHeight]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Height, height, dimensions[YGDimensionHeight]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MinWidth, minWidth, minDimensions[YGDimensionWidth]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MinHeight, minHeight, minDimensions[YGDimensionHeight]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MaxWidth, maxWidth, maxDimensions[YGDimensionWidth]); +YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MaxHeight, maxHeight, maxDimensions[YGDimensionHeight]); // Yoga specific properties, not compatible with flexbox specification YG_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio); @@ -482,17 +589,34 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const YGDirection parentDirection, const YGMeasureMode widthMeasureMode, const YGMeasureMode heightMeasureMode, + const float parentWidth, + const float parentHeight, const bool performLayout, const char *reason); -inline bool YGValueIsUndefined(const float value) { +inline bool YGValueIsUndefinedf(const float value) { return isnan(value); } -static inline bool YGFloatsEqual(const float a, const float b) { +inline bool YGValueIsUndefined(const YGValue value) { + return !value.defined; +} + +static inline bool YGValueEqual(const YGValue a, const YGValue b) { + if (a.unit != b.unit){ + return false; + } + if (YGValueIsUndefined(a)) { return YGValueIsUndefined(b); } + return fabs(a.value - b.value) < 0.0001; +} + +static inline bool YGFloatsEqual(const float a, const float b) { + if (YGValueIsUndefinedf(a)) { + return YGValueIsUndefinedf(b); + } return fabs(a - b) < 0.0001; } @@ -502,21 +626,27 @@ static void YGIndent(const uint32_t n) { } } -static void YGPrintNumberIfNotZero(const char *str, const float number) { - if (!YGFloatsEqual(number, 0)) { +static void YGPrintNumberIfNotZero(const char *str, const YGValue number) { + if (!YGFloatsEqual(number.value, 0)) { + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); + } +} + +static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { + if (!YGValueIsUndefinedf(number)) { YGLog(YGLogLevelDebug, "%s: %g, ", str, number); } } -static void YGPrintNumberIfNotUndefined(const char *str, const float number) { +static void YGPrintNumberIfNotUndefined(const char *str, const YGValue number) { if (!YGValueIsUndefined(number)) { - YGLog(YGLogLevelDebug, "%s: %g, ", str, number); + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); } } -static bool YGFourFloatsEqual(const float four[4]) { - return YGFloatsEqual(four[0], four[1]) && YGFloatsEqual(four[0], four[2]) && - YGFloatsEqual(four[0], four[3]); +static bool YGFourValuesEqual(const YGValue four[4]) { + return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) && + YGValueEqual(four[0], four[3]); } static void YGNodePrintInternal(const YGNodeRef node, @@ -585,9 +715,9 @@ static void YGNodePrintInternal(const YGNodeRef node, YGLog(YGLogLevelDebug, "alignSelf: 'stretch', "); } - YGPrintNumberIfNotUndefined("flexGrow", YGNodeStyleGetFlexGrow(node)); - YGPrintNumberIfNotUndefined("flexShrink", YGNodeStyleGetFlexShrink(node)); - YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasis(node)); + YGPrintNumberIfNotUndefinedf("flexGrow", YGNodeStyleGetFlexGrow(node)); + YGPrintNumberIfNotUndefinedf("flexShrink", YGNodeStyleGetFlexShrink(node)); + YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasisWithUnit(node)); if (node->style.overflow == YGOverflowHidden) { YGLog(YGLogLevelDebug, "overflow: 'hidden', "); @@ -597,7 +727,7 @@ static void YGNodePrintInternal(const YGNodeRef node, YGLog(YGLogLevelDebug, "overflow: 'scroll', "); } - if (YGFourFloatsEqual(node->style.margin)) { + if (YGFourValuesEqual(node->style.margin)) { YGPrintNumberIfNotZero("margin", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, 0)); } else { YGPrintNumberIfNotZero("marginLeft", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, 0)); @@ -611,7 +741,7 @@ static void YGNodePrintInternal(const YGNodeRef node, YGPrintNumberIfNotZero("marginEnd", YGComputedEdgeValue(node->style.margin, YGEdgeEnd, 0)); } - if (YGFourFloatsEqual(node->style.padding)) { + if (YGFourValuesEqual(node->style.padding)) { YGPrintNumberIfNotZero("padding", YGComputedEdgeValue(node->style.padding, YGEdgeLeft, 0)); } else { YGPrintNumberIfNotZero("paddingLeft", @@ -626,7 +756,7 @@ static void YGNodePrintInternal(const YGNodeRef node, YGPrintNumberIfNotZero("paddingEnd", YGComputedEdgeValue(node->style.padding, YGEdgeEnd, 0)); } - if (YGFourFloatsEqual(node->style.border)) { + if (YGFourValuesEqual(node->style.border)) { YGPrintNumberIfNotZero("borderWidth", YGComputedEdgeValue(node->style.border, YGEdgeLeft, 0)); } else { YGPrintNumberIfNotZero("borderLeftWidth", @@ -714,75 +844,75 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse; } -static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis) { +static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeStart])) { - return node->style.margin[YGEdgeStart]; + return YGValueToFloat(node->style.margin[YGEdgeStart], axisSize); } - return YGComputedEdgeValue(node->style.margin, leading[axis], 0); + return YGValueToFloat(YGComputedEdgeValue(node->style.margin, leading[axis], 0), axisSize); } -static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeEnd])) { - return node->style.margin[YGEdgeEnd]; + return YGValueToFloat(node->style.margin[YGEdgeEnd], axisSize); } - return YGComputedEdgeValue(node->style.margin, trailing[axis], 0); + return YGValueToFloat(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), axisSize); } -static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeStart]) && - node->style.padding[YGEdgeStart] >= 0) { - return node->style.padding[YGEdgeStart]; + YGValueToFloat(node->style.padding[YGEdgeStart], axisSize) >= 0) { + return YGValueToFloat(node->style.padding[YGEdgeStart], axisSize); } - return fmaxf(YGComputedEdgeValue(node->style.padding, leading[axis], 0), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, leading[axis], 0), axisSize), 0); } -static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeEnd]) && - node->style.padding[YGEdgeEnd] >= 0) { - return node->style.padding[YGEdgeEnd]; + YGValueToFloat(node->style.padding[YGEdgeEnd], axisSize) >= 0) { + return YGValueToFloat(node->style.padding[YGEdgeEnd], axisSize); } - return fmaxf(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), axisSize), 0); } -static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeStart]) && - node->style.border[YGEdgeStart] >= 0) { - return node->style.border[YGEdgeStart]; + YGValueToFloat(node->style.border[YGEdgeStart], axisSize) >= 0) { + return YGValueToFloat(node->style.border[YGEdgeStart], axisSize); } - return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], 0), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.border, leading[axis], 0), axisSize), 0); } -static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeEnd]) && - node->style.border[YGEdgeEnd] >= 0) { - return node->style.border[YGEdgeEnd]; + YGValueToFloat(node->style.border[YGEdgeEnd], axisSize) >= 0) { + return YGValueToFloat(node->style.border[YGEdgeEnd], axisSize); } - return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], 0), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.border, trailing[axis], 0), axisSize), 0); } static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node, - const YGFlexDirection axis) { - return YGNodeLeadingPadding(node, axis) + YGNodeLeadingBorder(node, axis); + const YGFlexDirection axis, const float axisSize) { + return YGNodeLeadingPadding(node, axis, axisSize) + YGNodeLeadingBorder(node, axis, axisSize); } static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node, - const YGFlexDirection axis) { - return YGNodeTrailingPadding(node, axis) + YGNodeTrailingBorder(node, axis); + const YGFlexDirection axis, const float axisSize) { + return YGNodeTrailingPadding(node, axis, axisSize) + YGNodeTrailingBorder(node, axis, axisSize); } -static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis) { - return YGNodeLeadingMargin(node, axis) + YGNodeTrailingMargin(node, axis); +static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { + return YGNodeLeadingMargin(node, axis, axisSize) + YGNodeTrailingMargin(node, axis, axisSize); } static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, - const YGFlexDirection axis) { - return YGNodeLeadingPaddingAndBorder(node, axis) + YGNodeTrailingPaddingAndBorder(node, axis); + const YGFlexDirection axis, const float axisSize) { + return YGNodeLeadingPaddingAndBorder(node, axis, axisSize) + YGNodeTrailingPaddingAndBorder(node, axis, axisSize); } static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { @@ -823,19 +953,19 @@ static inline bool YGNodeIsFlex(const YGNodeRef node) { (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); } -static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis) { - return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis) + - YGNodeTrailingMargin(node, axis); +static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { + return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis, axisSize) + + YGNodeTrailingMargin(node, axis, axisSize); } static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { - const float value = node->style.dimensions[dim[axis]]; - return !YGValueIsUndefined(value) && value >= 0.0; + const YGValue value = node->style.dimensions[dim[axis]]; + return !YGValueIsUndefined(value) && value.value >= 0.0; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const float value = node->layout.measuredDimensions[dim[axis]]; - return !YGValueIsUndefined(value) && value >= 0.0; + return !YGValueIsUndefinedf(value) && value >= 0.0; } static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -852,57 +982,57 @@ static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlex YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined)); } -static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { - const float leadingPosition = + const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); if (!YGValueIsUndefined(leadingPosition)) { - return leadingPosition; + return YGValueToFloat(leadingPosition, axisSize); } } - const float leadingPosition = + const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined); - return YGValueIsUndefined(leadingPosition) ? 0 : leadingPosition; + return YGValueIsUndefined(leadingPosition) ? 0 : YGValueToFloat(leadingPosition, axisSize); } -static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis) { +static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { - const float trailingPosition = + const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); if (!YGValueIsUndefined(trailingPosition)) { - return trailingPosition; + return YGValueToFloat(trailingPosition, axisSize); } } - const float trailingPosition = + const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined); - return YGValueIsUndefined(trailingPosition) ? 0 : trailingPosition; + return YGValueIsUndefined(trailingPosition) ? 0 : YGValueToFloat(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, const YGFlexDirection axis, - const float value) { + const float value, const float axisSize) { float min = YGUndefined; float max = YGUndefined; if (YGFlexDirectionIsColumn(axis)) { - min = node->style.minDimensions[YGDimensionHeight]; - max = node->style.maxDimensions[YGDimensionHeight]; + min = YGValueToFloat(node->style.minDimensions[YGDimensionHeight], axisSize); + max = YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], axisSize); } else if (YGFlexDirectionIsRow(axis)) { - min = node->style.minDimensions[YGDimensionWidth]; - max = node->style.maxDimensions[YGDimensionWidth]; + min = YGValueToFloat(node->style.minDimensions[YGDimensionWidth], axisSize); + max = YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], axisSize); } float boundValue = value; - if (!YGValueIsUndefined(max) && max >= 0.0 && boundValue > max) { + if (!YGValueIsUndefinedf(max) && max >= 0.0 && boundValue > max) { boundValue = max; } - if (!YGValueIsUndefined(min) && min >= 0.0 && boundValue < min) { + if (!YGValueIsUndefinedf(min) && min >= 0.0 && boundValue < min) { boundValue = min; } @@ -914,9 +1044,9 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, // padding and border amount. static inline float YGNodeBoundAxis(const YGNodeRef node, const YGFlexDirection axis, - const float value) { - return fmaxf(YGNodeBoundAxisWithinMinAndMax(node, axis, value), - YGNodePaddingAndBorderForAxis(node, axis)); + const float value, const float axisSize) { + return fmaxf(YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize), + YGNodePaddingAndBorderForAxis(node, axis, axisSize)); } static void YGNodeSetChildTrailingPosition(const YGNodeRef node, @@ -929,19 +1059,19 @@ static void YGNodeSetChildTrailingPosition(const YGNodeRef node, // If both left and right are defined, then use left. Otherwise return // +left or -right depending on which is defined. -static float YGNodeRelativePosition(const YGNodeRef node, const YGFlexDirection axis) { - return YGNodeIsLeadingPosDefined(node, axis) ? YGNodeLeadingPosition(node, axis) - : -YGNodeTrailingPosition(node, axis); +static float YGNodeRelativePosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { + return YGNodeIsLeadingPosDefined(node, axis) ? YGNodeLeadingPosition(node, axis, axisSize) + : -YGNodeTrailingPosition(node, axis, axisSize); } static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, float *size) { switch (*mode) { case YGMeasureModeExactly: case YGMeasureModeAtMost: - *size = (YGValueIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; + *size = (YGValueIsUndefinedf(maxSize) || *size < maxSize) ? *size : maxSize; break; case YGMeasureModeUndefined: - if (!YGValueIsUndefined(maxSize)) { + if (!YGValueIsUndefinedf(maxSize)) { *mode = YGMeasureModeAtMost; *size = maxSize; } @@ -951,20 +1081,20 @@ static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, } } -static void YGNodeSetPosition(const YGNodeRef node, const YGDirection direction) { +static void YGNodeSetPosition(const YGNodeRef node, const YGDirection direction, const float mainSize, const float crossSize) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); - const float relativePositionMain = YGNodeRelativePosition(node, mainAxis); - const float relativePositionCross = YGNodeRelativePosition(node, crossAxis); + const float relativePositionMain = YGNodeRelativePosition(node, mainAxis, mainSize); + const float relativePositionCross = YGNodeRelativePosition(node, crossAxis, crossSize); node->layout.position[leading[mainAxis]] = - YGNodeLeadingMargin(node, mainAxis) + relativePositionMain; + YGNodeLeadingMargin(node, mainAxis, mainSize) + relativePositionMain; node->layout.position[trailing[mainAxis]] = - YGNodeTrailingMargin(node, mainAxis) + relativePositionMain; + YGNodeTrailingMargin(node, mainAxis, mainSize) + relativePositionMain; node->layout.position[leading[crossAxis]] = - YGNodeLeadingMargin(node, crossAxis) + relativePositionCross; + YGNodeLeadingMargin(node, crossAxis, crossSize) + relativePositionCross; node->layout.position[trailing[crossAxis]] = - YGNodeTrailingMargin(node, crossAxis) + relativePositionCross; + YGNodeTrailingMargin(node, crossAxis, crossSize) + relativePositionCross; } static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, @@ -976,6 +1106,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const YGDirection direction) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); + float mainAxisSize = isMainAxisRow ? width : height; float childWidth; float childHeight; @@ -985,24 +1116,24 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (!YGValueIsUndefined(YGNodeStyleGetFlexBasis(child)) && - !YGValueIsUndefined(isMainAxisRow ? width : height)) { - if (YGValueIsUndefined(child->layout.computedFlexBasis) || + if (!YGValueIsUndefined(YGNodeStyleGetFlexBasisWithUnit(child)) && + !YGValueIsUndefinedf(mainAxisSize)) { + if (YGValueIsUndefinedf(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(YGNodeStyleGetFlexBasis(child), YGNodePaddingAndBorderForAxis(child, mainAxis)); + fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisSize), YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisSize)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(child->style.dimensions[YGDimensionWidth], - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); + fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionWidth], width), + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(child->style.dimensions[YGDimensionHeight], - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); + fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionHeight], height), + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, height)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped // flex basis). @@ -1012,13 +1143,13 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { - childWidth = child->style.dimensions[YGDimensionWidth] + - YGNodeMarginForAxis(child, YGFlexDirectionRow); + childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], width) + + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = child->style.dimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn); + childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], height) + + YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1026,7 +1157,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, // but all major browsers appear to implement the following logic. if ((!isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (YGValueIsUndefined(childWidth) && !YGValueIsUndefined(width)) { + if (YGValueIsUndefinedf(childWidth) && !YGValueIsUndefinedf(width)) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } @@ -1034,7 +1165,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if ((isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (YGValueIsUndefined(childHeight) && !YGValueIsUndefined(height)) { + if (YGValueIsUndefinedf(childHeight) && !YGValueIsUndefinedf(height)) { childHeight = height; childHeightMeasureMode = YGMeasureModeAtMost; } @@ -1043,35 +1174,35 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, // If child has no defined size in the cross axis and is set to stretch, // set the cross // axis to be measured exactly with the available inner width - if (!isMainAxisRow && !YGValueIsUndefined(width) && !isRowStyleDimDefined && + if (!isMainAxisRow && !YGValueIsUndefinedf(width) && !isRowStyleDimDefined && widthMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childWidth = width; childWidthMeasureMode = YGMeasureModeExactly; } - if (isMainAxisRow && !YGValueIsUndefined(height) && !isColumnStyleDimDefined && + if (isMainAxisRow && !YGValueIsUndefinedf(height) && !isColumnStyleDimDefined && heightMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childHeight = height; childHeightMeasureMode = YGMeasureModeExactly; } - if (!YGValueIsUndefined(child->style.aspectRatio)) { + if (!YGValueIsUndefinedf(child->style.aspectRatio)) { if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childWidth * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width)); return; } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childHeight * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, height)); return; } } - YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], width), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], height), &childHeightMeasureMode, &childHeight); @@ -1082,13 +1213,15 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, + width, + height, false, "measure"); child->layout.computedFlexBasis = fmaxf(isMainAxisRow ? child->layout.measuredDimensions[YGDimensionWidth] : child->layout.measuredDimensions[YGDimensionHeight], - YGNodePaddingAndBorderForAxis(child, mainAxis)); + YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisSize)); } child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; @@ -1098,6 +1231,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, const YGNodeRef child, const float width, const YGMeasureMode widthMode, + const float height, const YGDirection direction) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); @@ -1109,8 +1243,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) { - childWidth = - child->style.dimensions[YGDimensionWidth] + YGNodeMarginForAxis(child, YGFlexDirectionRow); + childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], width) + + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); } else { // If the child doesn't have a specified width, compute the width based // on the left/right @@ -1118,17 +1252,17 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionRow) && YGNodeIsTrailingPosDefined(child, YGFlexDirectionRow)) { childWidth = node->layout.measuredDimensions[YGDimensionWidth] - - (YGNodeLeadingBorder(node, YGFlexDirectionRow) + - YGNodeTrailingBorder(node, YGFlexDirectionRow)) - - (YGNodeLeadingPosition(child, YGFlexDirectionRow) + - YGNodeTrailingPosition(child, YGFlexDirectionRow)); - childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth); + (YGNodeLeadingBorder(node, YGFlexDirectionRow, width) + + YGNodeTrailingBorder(node, YGFlexDirectionRow, width)) - + (YGNodeLeadingPosition(child, YGFlexDirectionRow, width) + + YGNodeTrailingPosition(child, YGFlexDirectionRow, width)); + childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width); } } if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) { - childHeight = child->style.dimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn); + childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], height) + + YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); } else { // If the child doesn't have a specified height, compute the height // based on the top/bottom @@ -1136,40 +1270,40 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionColumn) && YGNodeIsTrailingPosDefined(child, YGFlexDirectionColumn)) { childHeight = node->layout.measuredDimensions[YGDimensionHeight] - - (YGNodeLeadingBorder(node, YGFlexDirectionColumn) + - YGNodeTrailingBorder(node, YGFlexDirectionColumn)) - - (YGNodeLeadingPosition(child, YGFlexDirectionColumn) + - YGNodeTrailingPosition(child, YGFlexDirectionColumn)); - childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight); + (YGNodeLeadingBorder(node, YGFlexDirectionColumn, height) + + YGNodeTrailingBorder(node, YGFlexDirectionColumn, height)) - + (YGNodeLeadingPosition(child, YGFlexDirectionColumn, height) + + YGNodeTrailingPosition(child, YGFlexDirectionColumn, height)); + childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height); } } // Exactly one dimension needs to be defined for us to be able to do aspect ratio // calculation. One dimension being the anchor and the other being flexible. - if (YGValueIsUndefined(childWidth) ^ YGValueIsUndefined(childHeight)) { - if (!YGValueIsUndefined(child->style.aspectRatio)) { - if (YGValueIsUndefined(childWidth)) { + if (YGValueIsUndefinedf(childWidth) ^ YGValueIsUndefinedf(childHeight)) { + if (!YGValueIsUndefinedf(child->style.aspectRatio)) { + if (YGValueIsUndefinedf(childWidth)) { childWidth = fmaxf(childHeight * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); - } else if (YGValueIsUndefined(childHeight)) { + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, height)); + } else if (YGValueIsUndefinedf(childHeight)) { childHeight = fmaxf(childWidth * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width)); } } } // If we're still missing one or the other dimension, measure the content. - if (YGValueIsUndefined(childWidth) || YGValueIsUndefined(childHeight)) { + if (YGValueIsUndefinedf(childWidth) || YGValueIsUndefinedf(childHeight)) { childWidthMeasureMode = - YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - YGValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; // According to the spec, if the main size is not definite and the // child's inline axis is parallel to the main axis (i.e. it's // horizontal), the child should be sized using "UNDEFINED" in // the main size. Otherwise use "AT_MOST" in the cross axis. - if (!isMainAxisRow && YGValueIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) { + if (!isMainAxisRow && YGValueIsUndefinedf(childWidth) && widthMode != YGMeasureModeUndefined) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } @@ -1180,12 +1314,14 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, + childWidth, + childHeight, false, "abs-measure"); childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - YGNodeMarginForAxis(child, YGFlexDirectionRow); + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); } YGLayoutNodeInternal(child, @@ -1194,22 +1330,25 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, direction, YGMeasureModeExactly, YGMeasureModeExactly, + childWidth, + childHeight, true, "abs-layout"); if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) { + const float mainAxisSize = isMainAxisRow ? width : height; child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - child->layout.measuredDimensions[dim[mainAxis]] - - YGNodeTrailingBorder(node, mainAxis) - - YGNodeTrailingPosition(child, mainAxis); + YGNodeTrailingBorder(node, mainAxis, mainAxisSize) - + YGNodeTrailingPosition(child, mainAxis, mainAxisSize); } - if (YGNodeIsTrailingPosDefined(child, crossAxis) && - !YGNodeIsLeadingPosDefined(child, crossAxis)) { + if (YGNodeIsTrailingPosDefined(child, crossAxis) && !YGNodeIsLeadingPosDefined(child, crossAxis)) { + const float crossAxisSize = isMainAxisRow ? height : width; child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - - YGNodeTrailingBorder(node, crossAxis) - - YGNodeTrailingPosition(child, crossAxis); + YGNodeTrailingBorder(node, crossAxis, crossAxisSize) - + YGNodeTrailingPosition(child, crossAxis, crossAxisSize); } } @@ -1220,11 +1359,11 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, const YGMeasureMode heightMeasureMode) { YG_ASSERT(node->measure, "Expected node to have custom measure function"); - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableHeight); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; @@ -1232,16 +1371,16 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) { // Don't bother sizing the text if both dimensions are already defined. node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight); } else if (innerWidth <= 0 || innerHeight <= 0) { // Don't bother sizing the text if there's no horizontal or vertical // space. node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, 0); + YGNodeBoundAxis(node, YGFlexDirectionRow, 0, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, 0); + YGNodeBoundAxis(node, YGFlexDirectionColumn, 0, availableHeight); } else { // Measure the text under the current constraints. const YGSize measuredSize = @@ -1253,14 +1392,14 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, (widthMeasureMode == YGMeasureModeUndefined || widthMeasureMode == YGMeasureModeAtMost) ? measuredSize.width + paddingAndBorderAxisRow - : availableWidth - marginAxisRow); + : availableWidth - marginAxisRow, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, (heightMeasureMode == YGMeasureModeUndefined || heightMeasureMode == YGMeasureModeAtMost) ? measuredSize.height + paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); + : availableHeight - marginAxisColumn, availableHeight); } } @@ -1270,12 +1409,14 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node, const float availableWidth, const float availableHeight, const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode) { - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); + const YGMeasureMode heightMeasureMode, + const float parentWidth, + const float parentHeight) { + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentWidth); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(node, @@ -1283,40 +1424,42 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node, (widthMeasureMode == YGMeasureModeUndefined || widthMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisRow - : availableWidth - marginAxisRow); + : availableWidth - marginAxisRow, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, (heightMeasureMode == YGMeasureModeUndefined || heightMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); + : availableHeight - marginAxisColumn, parentHeight); } static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, const float availableWidth, const float availableHeight, const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode) { + const YGMeasureMode heightMeasureMode, + const float parentWidth, + const float parentHeight) { if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0) || (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly)) { - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(node, YGFlexDirectionRow, - YGValueIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) + YGValueIsUndefinedf(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) ? 0 - : availableWidth - marginAxisRow); + : availableWidth - marginAxisRow, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, - YGValueIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) + YGValueIsUndefinedf(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) ? 0 - : availableHeight - marginAxisColumn); + : availableHeight - marginAxisColumn, parentHeight); return true; } @@ -1442,11 +1585,13 @@ static void YGNodelayoutImpl(const YGNodeRef node, const YGDirection parentDirection, const YGMeasureMode widthMeasureMode, const YGMeasureMode heightMeasureMode, + const float parentWidth, + const float parentHeight, const bool performLayout) { - YG_ASSERT(YGValueIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, + YG_ASSERT(YGValueIsUndefinedf(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, "availableWidth is indefinite so widthMeasureMode must be " "YGMeasureModeUndefined"); - YG_ASSERT(YGValueIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined + YG_ASSERT(YGValueIsUndefinedf(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined : true, "availableHeight is indefinite so heightMeasureMode must be " "YGMeasureModeUndefined"); @@ -1464,7 +1609,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, const uint32_t childCount = YGNodeListCount(node->children); if (childCount == 0) { YGNodeEmptyContainerSetMeasuredDimensions( - node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode); + node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode, parentWidth, parentHeight); return; } @@ -1472,7 +1617,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // the size if (!performLayout && YGNodeFixedSizeSetMeasuredDimensions( - node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode)) { + node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode, parentWidth, parentHeight)) { return; } @@ -1483,23 +1628,26 @@ static void YGNodelayoutImpl(const YGNodeRef node, const YGJustify justifyContent = node->style.justifyContent; const bool isNodeFlexWrap = node->style.flexWrap == YGWrapWrap; + const float mainAxisSize = isMainAxisRow ? availableWidth : availableHeight; + const float crossAxisSize = isMainAxisRow ? availableHeight : availableWidth; + YGNodeRef firstAbsoluteChild = NULL; YGNodeRef currentAbsoluteChild = NULL; - const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis); - const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis); - const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis); - const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis); - const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis); + const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, mainAxisSize); + const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, mainAxisSize); + const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis, crossAxisSize); + const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, mainAxisSize); + const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, crossAxisSize); const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableHeight); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; @@ -1535,7 +1683,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (performLayout) { // Set the initial position (relative to the parent). const YGDirection childDirection = YGNodeResolveDirection(child, direction); - YGNodeSetPosition(child, childDirection); + YGNodeSetPosition(child, childDirection, mainAxisSize, crossAxisSize); } // Absolute-positioned children don't participate in flex layout. Add them @@ -1609,7 +1757,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = - child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis); + child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, mainAxisSize); // If this is a multi-line flow and this item pushes us over the // available size, we've @@ -1660,7 +1808,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If the main dimension size isn't known, it is computed based on // the line length, so there's no more space left to distribute. float remainingFreeSpace = 0; - if (!YGValueIsUndefined(availableInnerMainDim)) { + if (!YGValueIsUndefinedf(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; } else if (sizeConsumedOnCurrentLine < 0) { // availableInnerMainDim is indefinite which means the node is being sized @@ -1720,7 +1868,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, mainAxisSize); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1739,7 +1887,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (flexGrowFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, mainAxisSize); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1781,7 +1929,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, (remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor; } - updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize); + updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, mainAxisSize); } } else if (remainingFreeSpace > 0) { flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); @@ -1792,7 +1940,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeBoundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor); + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, mainAxisSize); } } @@ -1805,10 +1953,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childWidth = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth); childWidthMeasureMode = YGMeasureModeExactly; - if (!YGValueIsUndefined(availableInnerCrossDim) && + if (!YGValueIsUndefinedf(availableInnerCrossDim) && !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn) && heightMeasureMode == YGMeasureModeExactly && YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { @@ -1817,18 +1965,18 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn)) { childHeight = availableInnerCrossDim; childHeightMeasureMode = - YGValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = currentRelativeChild->style.dimensions[YGDimensionHeight] + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn); + childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], availableHeight) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight); childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight); childHeightMeasureMode = YGMeasureModeExactly; - if (!YGValueIsUndefined(availableInnerCrossDim) && + if (!YGValueIsUndefinedf(availableInnerCrossDim) && !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow) && widthMeasureMode == YGMeasureModeExactly && YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { @@ -1837,32 +1985,32 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow)) { childWidth = availableInnerCrossDim; childWidthMeasureMode = - YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = currentRelativeChild->style.dimensions[YGDimensionWidth] + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow); + childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], availableWidth) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth); childWidthMeasureMode = YGMeasureModeExactly; } } - if (!YGValueIsUndefined(currentRelativeChild->style.aspectRatio)) { + if (!YGValueIsUndefinedf(currentRelativeChild->style.aspectRatio)) { if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth)); childWidthMeasureMode = YGMeasureModeExactly; } } - YGConstrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionWidth], + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionHeight], + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableHeight), &childHeightMeasureMode, &childHeight); @@ -1878,6 +2026,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, + parentWidth, + parentHeight, performLayout && !requiresStretchLayout, "flex"); @@ -1901,9 +2051,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { if (!YGValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && - node->style.minDimensions[dim[mainAxis]] >= 0) { + YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisSize) >= 0) { remainingFreeSpace = fmaxf(0, - node->style.minDimensions[dim[mainAxis]] - + YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisSize) - (availableInnerMainDim - remainingFreeSpace)); } else { remainingFreeSpace = 0; @@ -1946,9 +2096,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said // (and margin/border). - child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis) + - YGNodeLeadingBorder(node, mainAxis) + - YGNodeLeadingMargin(child, mainAxis); + child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, mainAxisSize) + + YGNodeLeadingBorder(node, mainAxis, mainAxisSize) + + YGNodeLeadingMargin(child, mainAxis, mainAxisSize); } } else { // Now that we placed the element, we need to update the variables. @@ -1963,22 +2113,22 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If we skipped the flex step, then we can't rely on the // measuredDims because // they weren't computed. This means we can't call YGNodeDimWithMargin. - mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis) + + mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, mainAxisSize) + child->layout.computedFlexBasis; crossDim = availableInnerCrossDim; } else { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis); + mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, mainAxisSize); // The cross dimension is the max of the elements dimension since // there // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis)); + crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, crossAxisSize)); } } else if (performLayout) { child->layout.position[pos[mainAxis]] += - YGNodeLeadingBorder(node, mainAxis) + leadingMainDim; + YGNodeLeadingBorder(node, mainAxis, mainAxisSize) + leadingMainDim; } } } @@ -1989,7 +2139,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeCrossDim == YGMeasureModeUndefined || measureModeCrossDim == YGMeasureModeAtMost) { // Compute the cross axis from the max cross dimension of the children. - containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - + containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisSize) - paddingAndBorderAxisCross; if (measureModeCrossDim == YGMeasureModeAtMost) { @@ -2003,7 +2153,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // Clamp to the min/max size specified on the container. - crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - + crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisSize) - paddingAndBorderAxisCross; // STEP 7: CROSS-AXIS ALIGNMENT @@ -2018,12 +2168,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, // set, override all the previously computed positions to set it // correctly. if (YGNodeIsLeadingPosDefined(child, crossAxis)) { - child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis) + - YGNodeLeadingBorder(node, crossAxis) + - YGNodeLeadingMargin(child, crossAxis); + child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, crossAxisSize) + + YGNodeLeadingBorder(node, crossAxis, crossAxisSize) + + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); } else { child->layout.position[pos[crossAxis]] = - YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis); + YGNodeLeadingBorder(node, crossAxis, crossAxisSize) + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2050,17 +2200,17 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childHeight = crossDim; childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - YGNodeMarginForAxis(child, YGFlexDirectionRow); + YGNodeMarginForAxis(child, YGFlexDirectionRow, availableWidth); } else { childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableHeight); } - YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], availableWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], availableHeight), &childHeightMeasureMode, &childHeight); @@ -2068,9 +2218,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // no need to stretch. if (!isCrossSizeDefinite) { childWidthMeasureMode = - YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - YGValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; YGLayoutNodeInternal(child, childWidth, @@ -2078,12 +2228,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, + parentWidth, + parentHeight, true, "stretch"); } } else if (alignItem != YGAlignFlexStart) { const float remainingCrossDim = - containerCrossAxis - YGNodeDimWithMargin(child, crossAxis); + containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, crossAxisSize); if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; @@ -2103,7 +2255,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // STEP 8: MULTI-LINE CONTENT ALIGNMENT - if (lineCount > 1 && performLayout && !YGValueIsUndefined(availableInnerCrossDim)) { + if (lineCount > 1 && performLayout && !YGValueIsUndefinedf(availableInnerCrossDim)) { const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim; float crossDimLead = 0; @@ -2145,7 +2297,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (YGNodeIsLayoutDimDefined(child, crossAxis)) { lineHeight = fmaxf(lineHeight, child->layout.measuredDimensions[dim[crossAxis]] + - YGNodeMarginForAxis(child, crossAxis)); + YGNodeMarginForAxis(child, crossAxis, crossAxisSize)); } } } @@ -2160,12 +2312,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, switch (YGNodeAlignItem(node, child)) { case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis); + currentLead + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); break; } case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = - currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis) - + currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, crossAxisSize) - child->layout.measuredDimensions[dim[crossAxis]]; break; } @@ -2177,7 +2329,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } case YGAlignStretch: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis); + currentLead + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; @@ -2196,9 +2348,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // STEP 9: COMPUTING FINAL DIMENSIONS node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight); // If the user didn't specify a width or height for the node, set the // dimensions based on the children. @@ -2206,11 +2358,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[mainAxis]] = - YGNodeBoundAxis(node, mainAxis, maxLineMainDim); + YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisSize); } else if (measureModeMainDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, - YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), + YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisSize)), paddingAndBorderAxisMain); } @@ -2218,13 +2370,13 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[crossAxis]] = - YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross); + YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisSize); } else if (measureModeCrossDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, YGNodeBoundAxisWithinMinAndMax(node, crossAxis, - totalLineCrossDim + paddingAndBorderAxisCross)), + totalLineCrossDim + paddingAndBorderAxisCross, crossAxisSize)), paddingAndBorderAxisCross); } @@ -2233,7 +2385,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, for (currentAbsoluteChild = firstAbsoluteChild; currentAbsoluteChild != NULL; currentAbsoluteChild = currentAbsoluteChild->nextChild) { YGNodeAbsoluteLayoutChild( - node, currentAbsoluteChild, availableInnerWidth, widthMeasureMode, direction); + node, currentAbsoluteChild, availableInnerWidth, widthMeasureMode, availableInnerHeight, direction); } // STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN @@ -2370,6 +2522,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const YGDirection parentDirection, const YGMeasureMode widthMeasureMode, const YGMeasureMode heightMeasureMode, + const float parentWidth, + const float parentHeight, const bool performLayout, const char *reason) { YGLayout *layout = &node->layout; @@ -2404,8 +2558,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, // expensive to measure, so it's worth avoiding redundant measurements if at // all possible. if (node->measure) { - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); // First, try to use the layout cache. if (YGNodeCanUseCachedMeasurement(widthMeasureMode, @@ -2498,6 +2652,8 @@ bool YGLayoutNodeInternal(const YGNodeRef node, parentDirection, widthMeasureMode, heightMeasureMode, + parentWidth, + parentHeight, performLayout); if (gPrintChanges) { @@ -2589,25 +2745,25 @@ void YGNodeCalculateLayout(const YGNodeRef node, YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; YGMeasureMode heightMeasureMode = YGMeasureModeUndefined; - if (!YGValueIsUndefined(width)) { + if (!YGValueIsUndefinedf(width)) { widthMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow)) { - width = node->style.dimensions[dim[YGFlexDirectionRow]] + - YGNodeMarginForAxis(node, YGFlexDirectionRow); + width = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + + YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); widthMeasureMode = YGMeasureModeExactly; - } else if (node->style.maxDimensions[YGDimensionWidth] >= 0.0) { - width = node->style.maxDimensions[YGDimensionWidth]; + } else if (YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { + width = YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], availableWidth); widthMeasureMode = YGMeasureModeAtMost; } - if (!YGValueIsUndefined(height)) { + if (!YGValueIsUndefinedf(height)) { heightMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { - height = node->style.dimensions[dim[YGFlexDirectionColumn]] + - YGNodeMarginForAxis(node, YGFlexDirectionColumn); + height = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + + YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); heightMeasureMode = YGMeasureModeExactly; - } else if (node->style.maxDimensions[YGDimensionHeight] >= 0.0) { - height = node->style.maxDimensions[YGDimensionHeight]; + } else if (YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { + height = YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight); heightMeasureMode = YGMeasureModeAtMost; } @@ -2617,10 +2773,12 @@ void YGNodeCalculateLayout(const YGNodeRef node, parentDirection, widthMeasureMode, heightMeasureMode, + availableWidth, + availableHeight, true, "initia" "l")) { - YGNodeSetPosition(node, node->layout.direction); + YGNodeSetPosition(node, node->layout.direction, availableWidth, availableHeight); if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { roundToPixelGrid(node); diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c7bc600d..e49ccdb6 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -38,6 +38,16 @@ typedef struct YGSize { float height; } YGSize; +typedef struct YGValue{ + float value; + YGUnit unit; + bool defined; + +} YGValue; + +WIN_EXPORT YGValue YGPx(const float value); +WIN_EXPORT YGValue YGPercent(const float value); + typedef struct YGNode *YGNodeRef; typedef YGSize (*YGMeasureFunc)(YGNodeRef node, float width, @@ -82,7 +92,8 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); -WIN_EXPORT bool YGValueIsUndefined(const float value); +WIN_EXPORT bool YGValueIsUndefinedf(const float value); +WIN_EXPORT bool YGValueIsUndefined(const YGValue value); WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, const float width, @@ -107,12 +118,24 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); +#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ + YG_NODE_STYLE_PROPERTY(float, name, paramName); \ + WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName); \ + WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node); + #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ const YGEdge edge, \ const type paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); +#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ + YG_NODE_STYLE_EDGE_PROPERTY(float, name, paramName) \ + WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, \ + const YGEdge edge, \ + const type paramName); \ + WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node, const YGEdge edge); + #define YG_NODE_LAYOUT_PROPERTY(type, name) \ WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node); @@ -134,19 +157,19 @@ YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow); WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex); YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow); YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink); -YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, FlexBasis, flexBasis); -YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position); -YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin); -YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding); -YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Position, position); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Margin, margin); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Padding, padding); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Border, border); -YG_NODE_STYLE_PROPERTY(float, Width, width); -YG_NODE_STYLE_PROPERTY(float, Height, height); -YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth); -YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight); -YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth); -YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Width, width); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Height, height); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinWidth, minWidth); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinHeight, minHeight); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxWidth, maxWidth); +YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight); // Yoga specific properties, not compatible with flexbox specification // Aspect ratio control the size of the undefined dimension of a node. -- 2.50.1.windows.1 From d950cf3d106d50e02d9385818f412c3e6c9a6cb6 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Sun, 11 Dec 2016 16:39:27 +0100 Subject: [PATCH 02/39] adjusted gentests --- gentest/gentest-cpp.js | 59 ++++++++++++++++++++++++----------------- gentest/gentest-cs.js | 49 +++++++++++++++++++--------------- gentest/gentest-java.js | 49 +++++++++++++++++++--------------- gentest/gentest.js | 2 +- 4 files changed, 90 insertions(+), 69 deletions(-) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 0333dd7c..45700a06 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -7,9 +7,20 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -function toFloatString(n) { +function toValueCpp(value) { + var n = value.toString().replace('px','').replace('%',''); return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); } + +function toValueCppWithUnitCpp(value) { + var methodName = ''; + if(value.indexOf('px') >= 0){ + methodName = 'YGPx'; + }else if (value.indexOf('%') >= 0){ + methodName = 'YGPercent'; + } + return methodName + '(' + toValueCpp(value) + ')'; +} var CPPEmitter = function() { Emitter.call(this, 'cpp', ' '); @@ -66,7 +77,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, AssertEQ:{value:function(v0, v1) { - this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');'); + this.push('ASSERT_FLOAT_EQ(' + toValueCpp(v0) + ', ' + v1 + ');'); }}, YGAlignAuto:{value:'YGAlignAuto'}, @@ -133,90 +144,90 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetAlignContent:{value:function(nodeName, value) { - this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetAlignItems:{value:function(nodeName, value) { - this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { - this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetBorderWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { - this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexBasisWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { - this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMarginWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMaxHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMaxWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMinHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMinWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { - this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetPaddingWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetPositionWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { - this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); }}, }); diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 0dbbb498..293b188c 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -7,6 +7,11 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +function toValueCs(value) { + var n = value.toString().replace('px','').replace('%',''); + return n + (Number(n) == n && n % 1 !== 0 ? '' : ''); +} + var CSEmitter = function() { Emitter.call(this, 'cs', ' '); }; @@ -143,90 +148,90 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetAlignContent:{value:function(nodeName, value) { - this.push(nodeName + '.AlignContent = ' + value + ';'); + this.push(nodeName + '.AlignContent = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetAlignItems:{value:function(nodeName, value) { - this.push(nodeName + '.AlignItems = ' + value + ';'); + this.push(nodeName + '.AlignItems = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { - this.push(nodeName + '.AlignSelf = ' + value + ';'); + this.push(nodeName + '.AlignSelf = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + 'f);'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { - this.push(nodeName + '.StyleDirection = ' + value + ';'); + this.push(nodeName + '.StyleDirection = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push(nodeName + '.FlexBasis = ' + value + 'f;'); + this.push(nodeName + '.FlexBasis = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { - this.push(nodeName + '.FlexDirection = ' + value + ';'); + this.push(nodeName + '.FlexDirection = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push(nodeName + '.FlexGrow = ' + value + 'f;'); + this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push(nodeName + '.FlexShrink = ' + value + 'f;'); + this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { - this.push(nodeName + '.Wrap = ' + value + ';'); + this.push(nodeName + '.Wrap = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.Height = ' + value + 'f;'); + this.push(nodeName + '.Height = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { - this.push(nodeName + '.JustifyContent = ' + value + ';'); + this.push(nodeName + '.JustifyContent = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.SetMargin(' + edge + ', ' + toValueCs(value) + 'f);'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.MaxHeight = ' + value + 'f;'); + this.push(nodeName + '.MaxHeight = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.MaxWidth = ' + value + 'f;'); + this.push(nodeName + '.MaxWidth = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.MinHeight = ' + value + 'f;'); + this.push(nodeName + '.MinHeight = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.MinWidth = ' + value + 'f;'); + this.push(nodeName + '.MinWidth = ' + toValueCs(value) + 'f;'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { - this.push(nodeName + '.Overflow = ' + value + ';'); + this.push(nodeName + '.Overflow = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.SetPadding(' + edge + ', ' + toValueCs(value) + 'f);'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.SetPosition(' + edge + ', ' + toValueCs(value) + 'f);'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { - this.push(nodeName + '.PositionType = ' + value + ';'); + this.push(nodeName + '.PositionType = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.Width = ' + value + 'f;'); + this.push(nodeName + '.Width = ' + toValueCs(value) + 'f;'); }}, }); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 7034c617..1d876d4f 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -7,6 +7,11 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +function toValueJava(value) { + var n = value.toString().replace('px','').replace('%',''); + return n + (Number(n) == n && n % 1 !== 0 ? '' : ''); +} + var JavaEmitter = function() { Emitter.call(this, 'java', ' '); }; @@ -148,90 +153,90 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetAlignContent:{value:function(nodeName, value) { - this.push(nodeName + '.setAlignContent(' + value + ');'); + this.push(nodeName + '.setAlignContent(' + toValueJava(value) + ');'); }}, YGNodeStyleSetAlignItems:{value:function(nodeName, value) { - this.push(nodeName + '.setAlignItems(' + value + ');'); + this.push(nodeName + '.setAlignItems(' + toValueJava(value) + ');'); }}, YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { - this.push(nodeName + '.setAlignSelf(' + value + ');'); + this.push(nodeName + '.setAlignSelf(' + toValueJava(value) + ');'); }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.setBorder(' + edge + ', ' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { - this.push(nodeName + '.setDirection(' + value + ');'); + this.push(nodeName + '.setDirection(' + toValueJava(value) + ');'); }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexBasis(' + value + 'f);'); + this.push(nodeName + '.setFlexBasis(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexDirection(' + value + ');'); + this.push(nodeName + '.setFlexDirection(' + toValueJava(value) + ');'); }}, YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexGrow(' + value + 'f);'); + this.push(nodeName + '.setFlexGrow(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexShrink(' + value + 'f);'); + this.push(nodeName + '.setFlexShrink(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { - this.push(nodeName + '.setWrap(' + value + ');'); + this.push(nodeName + '.setWrap(' + toValueJava(value) + ');'); }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setHeight(' + value + 'f);'); + this.push(nodeName + '.setHeight(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { - this.push(nodeName + '.setJustifyContent(' + value + ');'); + this.push(nodeName + '.setJustifyContent(' + toValueJava(value) + ');'); }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.setMargin(' + edge + ', ' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setMaxHeight(' + value + 'f);'); + this.push(nodeName + '.setMaxHeight(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setMaxWidth(' + value + 'f);'); + this.push(nodeName + '.setMaxWidth(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setMinHeight(' + value + 'f);'); + this.push(nodeName + '.setMinHeight(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setMinWidth(' + value + 'f);'); + this.push(nodeName + '.setMinWidth(' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { - this.push(nodeName + '.setOverflow(' + value + ');'); + this.push(nodeName + '.setOverflow(' + toValueJava(value) + ');'); }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setPadding(' + edge + ', ' + value + ');'); + this.push(nodeName + '.setPadding(' + edge + ', ' + toValueJava(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);'); + this.push(nodeName + '.setPosition(' + edge + ', ' + toValueJava(value) + 'f);'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { - this.push(nodeName + '.setPositionType(' + value + ');'); + this.push(nodeName + '.setPositionType(' + toValueJava(value) + ');'); }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setWidth(' + value + 'f);'); + this.push(nodeName + '.setWidth(' + toValueJava(value) + 'f);'); }}, }); diff --git a/gentest/gentest.js b/gentest/gentest.js index 196a8c1e..552104a2 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -378,7 +378,7 @@ function pixelValue(e, value) { switch (value) { case 'auto': return e.YGUndefined; case 'undefined': return e.YGUndefined; - default: return value.replace('px', ''); + default: return value; } } -- 2.50.1.windows.1 From 8fbf1ddecb466d34af90ca1d99822047d3fbe213 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Sun, 11 Dec 2016 16:43:46 +0100 Subject: [PATCH 03/39] changed unittests to use units --- tests/YGAbsolutePositionTest.cpp | 108 ++++++++++++------------- tests/YGAlignContentTest.cpp | 86 ++++++++++---------- tests/YGAlignItemsTest.cpp | 30 +++---- tests/YGAlignSelfTest.cpp | 32 ++++---- tests/YGBorderTest.cpp | 62 +++++++-------- tests/YGFlexDirectionTest.cpp | 56 ++++++------- tests/YGFlexTest.cpp | 58 +++++++------- tests/YGFlexWrapTest.cpp | 72 ++++++++--------- tests/YGJustifyContentTest.cpp | 98 +++++++++++------------ tests/YGLayoutDefaultValuesTest.cpp | 42 +++++----- tests/YGMarginTest.cpp | 64 +++++++-------- tests/YGMinMaxDimensionTest.cpp | 80 +++++++++---------- tests/YGPaddingTest.cpp | 78 +++++++++--------- tests/YGRoundingTest.cpp | 118 ++++++++++++++-------------- 14 files changed, 492 insertions(+), 492 deletions(-) diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index c5a3891b..fc4df6c0 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -14,15 +14,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -53,15 +53,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { TEST(YogaTest, absolute_layout_width_height_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -92,15 +92,15 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) { TEST(YogaTest, absolute_layout_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -131,17 +131,17 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) { TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -174,18 +174,18 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowHidden); - YGNodeStyleSetWidth(root, 50); - YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetWidthWithUnit(root, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root, YGPx(50)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(0)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(0)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, 100); - YGNodeStyleSetHeight(root_child0_child0, 100); + YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(100)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -226,35 +226,35 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi TEST(YogaTest, absolute_layout_within_border) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMargin(root, YGEdgeLeft, 10); - YGNodeStyleSetMargin(root, YGEdgeTop, 10); - YGNodeStyleSetMargin(root, YGEdgeRight, 10); - YGNodeStyleSetMargin(root, YGEdgeBottom, 10); - YGNodeStyleSetPadding(root, YGEdgeLeft, 10); - YGNodeStyleSetPadding(root, YGEdgeTop, 10); - YGNodeStyleSetPadding(root, YGEdgeRight, 10); - YGNodeStyleSetPadding(root, YGEdgeBottom, 10); - YGNodeStyleSetBorder(root, YGEdgeLeft, 10); - YGNodeStyleSetBorder(root, YGEdgeTop, 10); - YGNodeStyleSetBorder(root, YGEdgeRight, 10); - YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetMarginWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetMarginWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMarginWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetMarginWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPx(0)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0); - YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetPositionWithUnit(root_child1, YGEdgeRight, YGPx(0)); + YGNodeStyleSetPositionWithUnit(root_child1, YGEdgeBottom, YGPx(0)); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index 6c2aaa40..e836d098 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -15,32 +15,32 @@ TEST(YogaTest, align_content_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 50); - YGNodeStyleSetHeight(root_child3, 10); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, 50); - YGNodeStyleSetHeight(root_child4, 10); + YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -113,32 +113,32 @@ TEST(YogaTest, align_content_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 50); - YGNodeStyleSetHeight(root_child3, 10); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, 50); - YGNodeStyleSetHeight(root_child4, 10); + YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -211,32 +211,32 @@ TEST(YogaTest, align_content_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 50); - YGNodeStyleSetHeight(root_child3, 10); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, 50); - YGNodeStyleSetHeight(root_child4, 10); + YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,27 +309,27 @@ TEST(YogaTest, align_content_stretch) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index e80ae1d4..a1a3bcb6 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -14,11 +14,11 @@ TEST(YogaTest, align_items_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -50,12 +50,12 @@ TEST(YogaTest, align_items_stretch) { TEST(YogaTest, align_items_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, align_items_center) { TEST(YogaTest, align_items_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -124,12 +124,12 @@ TEST(YogaTest, align_items_flex_start) { TEST(YogaTest, align_items_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index 436d78b4..88894aba 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -14,13 +14,13 @@ TEST(YogaTest, align_self_center) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,13 +51,13 @@ TEST(YogaTest, align_self_center) { TEST(YogaTest, align_self_flex_end) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -88,13 +88,13 @@ TEST(YogaTest, align_self_flex_end) { TEST(YogaTest, align_self_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,13 +126,13 @@ TEST(YogaTest, align_self_flex_start) { TEST(YogaTest, align_self_flex_end_override_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 41673414..a798c46e 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, border_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorder(root, YGEdgeLeft, 10); - YGNodeStyleSetBorder(root, YGEdgeTop, 10); - YGNodeStyleSetBorder(root, YGEdgeRight, 10); - YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,14 +37,14 @@ TEST(YogaTest, border_no_size) { TEST(YogaTest, border_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorder(root, YGEdgeLeft, 10); - YGNodeStyleSetBorder(root, YGEdgeTop, 10); - YGNodeStyleSetBorder(root, YGEdgeRight, 10); - YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -75,16 +75,16 @@ TEST(YogaTest, border_container_match_child) { TEST(YogaTest, border_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorder(root, YGEdgeLeft, 10); - YGNodeStyleSetBorder(root, YGEdgeTop, 10); - YGNodeStyleSetBorder(root, YGEdgeRight, 10); - YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -115,15 +115,15 @@ TEST(YogaTest, border_flex_child) { TEST(YogaTest, border_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorder(root, YGEdgeLeft, 10); - YGNodeStyleSetBorder(root, YGEdgeTop, 10); - YGNodeStyleSetBorder(root, YGEdgeRight, 10); - YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -156,15 +156,15 @@ TEST(YogaTest, border_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetBorder(root, YGEdgeStart, 10); - YGNodeStyleSetBorder(root, YGEdgeEnd, 20); - YGNodeStyleSetBorder(root, YGEdgeBottom, 20); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBorderWithUnit(root, YGEdgeStart, YGPx(10)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeEnd, YGPx(20)); + YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index b6016428..47168b99 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -14,18 +14,18 @@ TEST(YogaTest, flex_direction_column_no_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -77,18 +77,18 @@ TEST(YogaTest, flex_direction_column_no_height) { TEST(YogaTest, flex_direction_row_no_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -139,19 +139,19 @@ TEST(YogaTest, flex_direction_row_no_width) { TEST(YogaTest, flex_direction_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -203,19 +203,19 @@ TEST(YogaTest, flex_direction_column) { TEST(YogaTest, flex_direction_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -267,19 +267,19 @@ TEST(YogaTest, flex_direction_row) { TEST(YogaTest, flex_direction_column_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,19 +331,19 @@ TEST(YogaTest, flex_direction_column_reverse) { TEST(YogaTest, flex_direction_row_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index 559025f7..60641472 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -65,12 +65,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { TEST(YogaTest, flex_basis_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -115,16 +115,16 @@ TEST(YogaTest, flex_basis_flex_grow_row) { TEST(YogaTest, flex_basis_flex_shrink_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, 50); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -166,16 +166,16 @@ TEST(YogaTest, flex_basis_flex_shrink_column) { TEST(YogaTest, flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, 50); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -216,22 +216,22 @@ TEST(YogaTest, flex_basis_flex_shrink_row) { TEST(YogaTest, flex_shrink_to_zero) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, 75); + YGNodeStyleSetHeightWithUnit(root, YGPx(75)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child1, 1); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); - YGNodeStyleSetHeight(root_child2, 50); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -282,23 +282,23 @@ TEST(YogaTest, flex_shrink_to_zero) { TEST(YogaTest, flex_basis_overrides_main_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -349,8 +349,8 @@ TEST(YogaTest, flex_basis_overrides_main_size) { TEST(YogaTest, flex_grow_shrink_at_most) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeInsertChild(root, root_child0, 0); diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index 03d07a82..093fd2d7 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -15,26 +15,26 @@ TEST(YogaTest, wrap_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 30); - YGNodeStyleSetHeight(root_child0, 30); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(30)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 30); - YGNodeStyleSetHeight(root_child1, 30); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(30)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 30); - YGNodeStyleSetHeight(root_child2, 30); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 30); - YGNodeStyleSetHeight(root_child3, 30); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -97,26 +97,26 @@ TEST(YogaTest, wrap_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 30); - YGNodeStyleSetHeight(root_child0, 30); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(30)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 30); - YGNodeStyleSetHeight(root_child1, 30); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(30)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 30); - YGNodeStyleSetHeight(root_child2, 30); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 30); - YGNodeStyleSetHeight(root_child3, 30); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -180,26 +180,26 @@ TEST(YogaTest, wrap_row_align_items_flex_end) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 30); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 30); - YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 30); - YGNodeStyleSetHeight(root_child2, 30); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 30); - YGNodeStyleSetHeight(root_child3, 30); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -263,26 +263,26 @@ TEST(YogaTest, wrap_row_align_items_center) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 30); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 30); - YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 30); - YGNodeStyleSetHeight(root_child2, 30); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, 30); - YGNodeStyleSetHeight(root_child3, 30); + YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index b7afe1b6..2307d199 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -15,19 +15,19 @@ TEST(YogaTest, justify_content_row_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,19 +80,19 @@ TEST(YogaTest, justify_content_row_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -145,19 +145,19 @@ TEST(YogaTest, justify_content_row_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -210,19 +210,19 @@ TEST(YogaTest, justify_content_row_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -275,19 +275,19 @@ TEST(YogaTest, justify_content_row_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 10); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 10); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -338,18 +338,18 @@ TEST(YogaTest, justify_content_row_space_around) { TEST(YogaTest, justify_content_column_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -401,19 +401,19 @@ TEST(YogaTest, justify_content_column_flex_start) { TEST(YogaTest, justify_content_column_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -465,19 +465,19 @@ TEST(YogaTest, justify_content_column_flex_end) { TEST(YogaTest, justify_content_column_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -529,19 +529,19 @@ TEST(YogaTest, justify_content_column_center) { TEST(YogaTest, justify_content_column_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -593,19 +593,19 @@ TEST(YogaTest, justify_content_column_space_between) { TEST(YogaTest, justify_content_column_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, 102); - YGNodeStyleSetHeight(root, 102); + YGNodeStyleSetWidthWithUnit(root, YGPx(102)); + YGNodeStyleSetHeightWithUnit(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index fbc1e1b9..753a8bd9 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -27,49 +27,49 @@ TEST(YogaTest, assert_default_values) { ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetFlexBasis(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetFlexBasis(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeLeft))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeTop))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeRight))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeBottom))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeStart))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMargin(root, YGEdgeStart))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMargin(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPadding(root, YGEdgeStart))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPadding(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetBorder(root, YGEdgeStart))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetBorder(root, YGEdgeEnd))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetWidth(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetHeight(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinWidth(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinHeight(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxWidth(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetWidth(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetHeight(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMinWidth(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMinHeight(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMaxWidth(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMaxHeight(root))); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetWidth(root))); - ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetHeight(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeLayoutGetWidth(root))); + ASSERT_TRUE(YGValueIsUndefinedf(YGNodeLayoutGetHeight(root))); ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root)); YGNodeFreeRecursive(root); diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index 724b2eef..fb293065 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -15,12 +15,12 @@ TEST(YogaTest, margin_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, margin_start) { TEST(YogaTest, margin_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -89,12 +89,12 @@ TEST(YogaTest, margin_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,12 +126,12 @@ TEST(YogaTest, margin_end) { TEST(YogaTest, margin_bottom) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -163,12 +163,12 @@ TEST(YogaTest, margin_bottom) { TEST(YogaTest, margin_and_flex_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,12 +199,12 @@ TEST(YogaTest, margin_and_flex_row) { TEST(YogaTest, margin_and_flex_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -236,12 +236,12 @@ TEST(YogaTest, margin_and_flex_column) { TEST(YogaTest, margin_and_stretch_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -272,12 +272,12 @@ TEST(YogaTest, margin_and_stretch_row) { TEST(YogaTest, margin_and_stretch_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,8 +309,8 @@ TEST(YogaTest, margin_and_stretch_column) { TEST(YogaTest, margin_with_sibling_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -358,8 +358,8 @@ TEST(YogaTest, margin_with_sibling_row) { TEST(YogaTest, margin_with_sibling_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 2c6d3120..ee6eff52 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMaxWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, max_width) { TEST(YogaTest, max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetMaxHeight(root_child0, 50); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, max_height) { TEST(YogaTest, min_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeight(root_child0, 60); + YGNodeStyleSetMinHeightWithUnit(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -138,12 +138,12 @@ TEST(YogaTest, min_height) { TEST(YogaTest, min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinWidth(root_child0, 60); + YGNodeStyleSetMinWidthWithUnit(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -189,13 +189,13 @@ TEST(YogaTest, min_width) { TEST(YogaTest, justify_content_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetMinHeight(root, 100); - YGNodeStyleSetMaxHeight(root, 200); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetMinHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetMaxHeightWithUnit(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 60); - YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -227,13 +227,13 @@ TEST(YogaTest, justify_content_min_max) { TEST(YogaTest, align_items_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetMinWidth(root, 100); - YGNodeStyleSetMaxWidth(root, 200); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetMinWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetMaxWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 60); - YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -265,22 +265,22 @@ TEST(YogaTest, align_items_min_max) { TEST(YogaTest, justify_content_overflow_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetMinHeight(root, 100); - YGNodeStyleSetMaxHeight(root, 110); + YGNodeStyleSetMinHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetMaxHeightWithUnit(root, YGPx(110)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, 50); - YGNodeStyleSetHeight(root_child2, 50); + YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,17 +331,17 @@ TEST(YogaTest, justify_content_overflow_min_max) { TEST(YogaTest, flex_grow_within_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 200); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, 100); + YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, 20); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(20)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -382,17 +382,17 @@ TEST(YogaTest, flex_grow_within_max_width) { TEST(YogaTest, flex_grow_within_constrained_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 200); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, 300); + YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(300)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, 20); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(20)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index aab6726b..86b58175 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, padding_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, 10); - YGNodeStyleSetPadding(root, YGEdgeTop, 10); - YGNodeStyleSetPadding(root, YGEdgeRight, 10); - YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,14 +37,14 @@ TEST(YogaTest, padding_no_size) { TEST(YogaTest, padding_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, 10); - YGNodeStyleSetPadding(root, YGEdgeTop, 10); - YGNodeStyleSetPadding(root, YGEdgeRight, 10); - YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -75,16 +75,16 @@ TEST(YogaTest, padding_container_match_child) { TEST(YogaTest, padding_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, 10); - YGNodeStyleSetPadding(root, YGEdgeTop, 10); - YGNodeStyleSetPadding(root, YGEdgeRight, 10); - YGNodeStyleSetPadding(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -115,15 +115,15 @@ TEST(YogaTest, padding_flex_child) { TEST(YogaTest, padding_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, 10); - YGNodeStyleSetPadding(root, YGEdgeTop, 10); - YGNodeStyleSetPadding(root, YGEdgeRight, 10); - YGNodeStyleSetPadding(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -156,15 +156,15 @@ TEST(YogaTest, padding_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetPadding(root, YGEdgeStart, 10); - YGNodeStyleSetPadding(root, YGEdgeEnd, 20); - YGNodeStyleSetPadding(root, YGEdgeBottom, 20); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeEnd, YGPx(20)); + YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -197,16 +197,16 @@ TEST(YogaTest, child_with_padding_align_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, 200); - YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); - YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPx(20)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index 0ce9f5c0..fe2a39be 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -17,8 +17,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -85,8 +85,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 113); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(113)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -181,20 +181,20 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 101); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidthWithUnit(root, YGPx(101)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, 25); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(25)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child2, 25); + YGNodeStyleSetFlexBasisWithUnit(root_child2, YGPx(25)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -249,23 +249,23 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 113); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -320,23 +320,23 @@ TEST(YogaTest, rounding_total_fractial) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 87.4f); - YGNodeStyleSetHeight(root, 113.4f); + YGNodeStyleSetWidthWithUnit(root, YGPx(87.4f)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, 50.3f); - YGNodeStyleSetHeight(root_child0, 20.3f); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50.3f)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20.3f)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, 10.7f); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10.7f)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -391,37 +391,37 @@ TEST(YogaTest, rounding_total_fractial_nested) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 87.4f); - YGNodeStyleSetHeight(root, 113.4f); + YGNodeStyleSetWidthWithUnit(root, YGPx(87.4f)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, 50.3f); - YGNodeStyleSetHeight(root_child0, 20.3f); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50.3f)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20.3f)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f); - YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); - YGNodeStyleSetHeight(root_child0_child0, 9.9f); + YGNodeStyleSetFlexBasisWithUnit(root_child0_child0, YGPx(0.3f)); + YGNodeStyleSetPositionWithUnit(root_child0_child0, YGEdgeBottom, YGPx(13.3f)); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(9.9f)); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child1, 4); - YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f); - YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); - YGNodeStyleSetHeight(root_child0_child1, 1.1f); + YGNodeStyleSetFlexBasisWithUnit(root_child0_child1, YGPx(0.3f)); + YGNodeStyleSetPositionWithUnit(root_child0_child1, YGEdgeTop, YGPx(13.3f)); + YGNodeStyleSetHeightWithUnit(root_child0_child1, YGPx(1.1f)); YGNodeInsertChild(root_child0, root_child0_child1, 1); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, 10.7f); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10.7f)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -496,23 +496,23 @@ TEST(YogaTest, rounding_fractial_input_1) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 113.4f); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -567,23 +567,23 @@ TEST(YogaTest, rounding_fractial_input_2) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 113.6f); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.6f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -638,24 +638,24 @@ TEST(YogaTest, rounding_fractial_input_3) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 113.4f); + YGNodeStyleSetPositionWithUnit(root, YGEdgeTop, YGPx(0.3f)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -710,24 +710,24 @@ TEST(YogaTest, rounding_fractial_input_4) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 113.4f); + YGNodeStyleSetPositionWithUnit(root, YGEdgeTop, YGPx(0.7f)); + YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, 10); + YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, 10); + YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); -- 2.50.1.windows.1 From 687cbb863260eaa5383c7d7fa843438e326d93bb Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Sun, 11 Dec 2016 16:49:01 +0100 Subject: [PATCH 04/39] added tests for percentage --- .../tests/Facebook.Yoga/YGPercentageTest.cs | 794 ++++++++++++++++++ gentest/fixtures/YGPercentageTest.html | 67 ++ .../com/facebook/yoga/YGPercentageTest.java | 779 +++++++++++++++++ tests/YGPercentageTest.cpp | 760 +++++++++++++++++ 4 files changed, 2400 insertions(+) create mode 100644 csharp/tests/Facebook.Yoga/YGPercentageTest.cs create mode 100644 gentest/fixtures/YGPercentageTest.html create mode 100644 java/tests/com/facebook/yoga/YGPercentageTest.java create mode 100644 tests/YGPercentageTest.cpp diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs new file mode 100644 index 00000000..2a38c185 --- /dev/null +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -0,0 +1,794 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html + +using System; +using NUnit.Framework; + +namespace Facebook.Yoga +{ + [TestFixture] + public class YGPercentageTest + { + [Test] + public void Test_percentage_width_height() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.Width = 30f; + root_child0.Height = 30f; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(140f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_position_left_top() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 400f; + root.Height = 400f; + + YogaNode root_child0 = new YogaNode(); + root_child0.SetPosition(YogaEdge.Left, 10f); + root_child0.SetPosition(YogaEdge.Top, 20f); + root_child0.Width = 45f; + root_child0.Height = 55f; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(400f, root.LayoutWidth); + Assert.AreEqual(400f, root.LayoutHeight); + + Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(180f, root_child0.LayoutWidth); + Assert.AreEqual(220f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(400f, root.LayoutWidth); + Assert.AreEqual(400f, root.LayoutHeight); + + Assert.AreEqual(260f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(180f, root_child0.LayoutWidth); + Assert.AreEqual(220f, root_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_position_bottom_right() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 500f; + root.Height = 500f; + + YogaNode root_child0 = new YogaNode(); + root_child0.SetPosition(YogaEdge.Right, 20f); + root_child0.SetPosition(YogaEdge.Bottom, 10f); + root_child0.Width = 55f; + root_child0.Height = 15f; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(500f, root.LayoutWidth); + Assert.AreEqual(500f, root.LayoutHeight); + + Assert.AreEqual(-100f, root_child0.LayoutX); + Assert.AreEqual(-50f, root_child0.LayoutY); + Assert.AreEqual(275f, root_child0.LayoutWidth); + Assert.AreEqual(75f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(500f, root.LayoutWidth); + Assert.AreEqual(500f, root.LayoutHeight); + + Assert.AreEqual(125f, root_child0.LayoutX); + Assert.AreEqual(-50f, root_child0.LayoutY); + Assert.AreEqual(275f, root_child0.LayoutWidth); + Assert.AreEqual(75f, root_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 1f; + root_child1.FlexBasis = 25f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(125f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(125f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(75f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(75f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(125f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(75f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_cross() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 1f; + root_child1.FlexBasis = 25f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(125f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(125f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(75f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(125f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(125f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(75f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_cross_min_height() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.MinHeight = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 2f; + root_child1.MinHeight = 10f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(140f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(140f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(60f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(140f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(140f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(60f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_main_max_height() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 10f; + root_child0.MaxHeight = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 10f; + root_child1.MaxHeight = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(52f, root_child0.LayoutWidth); + Assert.AreEqual(120f, root_child0.LayoutHeight); + + Assert.AreEqual(52f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(148f, root_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(148f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(52f, root_child0.LayoutWidth); + Assert.AreEqual(120f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(148f, root_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_cross_max_height() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 10f; + root_child0.MaxHeight = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 10f; + root_child1.MaxHeight = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(120f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(120f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(120f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(120f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_main_max_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 15f; + root_child0.MaxWidth = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 10f; + root_child1.MaxWidth = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(120f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_cross_max_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 10f; + root_child0.MaxWidth = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 15f; + root_child1.MaxWidth = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(150f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(160f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(150f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_main_min_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 15f; + root_child0.MinWidth = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 10f; + root_child1.MinWidth = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(120f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(80f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(120f, root_child0.LayoutWidth); + Assert.AreEqual(200f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(80f, root_child1.LayoutWidth); + Assert.AreEqual(200f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_flex_basis_cross_min_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 10f; + root_child0.MinWidth = 60f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 15f; + root_child1.MinWidth = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(150f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(150f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 10f; + root_child0.SetMargin(YogaEdge.Left, 5f); + root_child0.SetMargin(YogaEdge.Top, 5f); + root_child0.SetMargin(YogaEdge.Right, 5f); + root_child0.SetMargin(YogaEdge.Bottom, 5f); + root_child0.SetPadding(YogaEdge.Left, 3f); + root_child0.SetPadding(YogaEdge.Top, 3f); + root_child0.SetPadding(YogaEdge.Right, 3f); + root_child0.SetPadding(YogaEdge.Bottom, 3f); + root_child0.MinWidth = 60f; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.SetMargin(YogaEdge.Left, 5f); + root_child0_child0.SetMargin(YogaEdge.Top, 5f); + root_child0_child0.SetMargin(YogaEdge.Right, 5f); + root_child0_child0.SetMargin(YogaEdge.Bottom, 5f); + root_child0_child0.SetPadding(YogaEdge.Left, 3f); + root_child0_child0.SetPadding(YogaEdge.Top, 3f); + root_child0_child0.SetPadding(YogaEdge.Right, 3f); + root_child0_child0.SetPadding(YogaEdge.Bottom, 3f); + root_child0_child0.Width = 50f; + root_child0.Insert(0, root_child0_child0); + + YogaNode root_child0_child0_child0 = new YogaNode(); + root_child0_child0_child0.SetMargin(YogaEdge.Left, 5f); + root_child0_child0_child0.SetMargin(YogaEdge.Top, 5f); + root_child0_child0_child0.SetMargin(YogaEdge.Right, 5f); + root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5f); + root_child0_child0_child0.SetPadding(YogaEdge.Left, 3f); + root_child0_child0_child0.SetPadding(YogaEdge.Top, 3f); + root_child0_child0_child0.SetPadding(YogaEdge.Right, 3f); + root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3f); + root_child0_child0_child0.Width = 45f; + root_child0_child0.Insert(0, root_child0_child0_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.FlexGrow = 4f; + root_child1.FlexBasis = 15f; + root_child1.MinWidth = 20f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(5f, root_child0.LayoutX); + Assert.AreEqual(5f, root_child0.LayoutY); + Assert.AreEqual(190f, root_child0.LayoutWidth); + Assert.AreEqual(48f, root_child0.LayoutHeight); + + Assert.AreEqual(8f, root_child0_child0.LayoutX); + Assert.AreEqual(8f, root_child0_child0.LayoutY); + Assert.AreEqual(92f, root_child0_child0.LayoutWidth); + Assert.AreEqual(25f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(10f, root_child0_child0_child0.LayoutX); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutY); + Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth); + Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(58f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(142f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(5f, root_child0.LayoutX); + Assert.AreEqual(5f, root_child0.LayoutY); + Assert.AreEqual(190f, root_child0.LayoutWidth); + Assert.AreEqual(48f, root_child0.LayoutHeight); + + Assert.AreEqual(90f, root_child0_child0.LayoutX); + Assert.AreEqual(8f, root_child0_child0.LayoutY); + Assert.AreEqual(92f, root_child0_child0.LayoutWidth); + Assert.AreEqual(25f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(46f, root_child0_child0_child0.LayoutX); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutY); + Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth); + Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(58f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(142f, root_child1.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + } +} diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html new file mode 100644 index 00000000..0384ecb9 --- /dev/null +++ b/gentest/fixtures/YGPercentageTest.html @@ -0,0 +1,67 @@ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java new file mode 100644 index 00000000..506b9b6c --- /dev/null +++ b/java/tests/com/facebook/yoga/YGPercentageTest.java @@ -0,0 +1,779 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html + +package com.facebook.yoga; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class YGPercentageTest { + @Test + public void test_percentage_width_height() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setWidth(30f); + root_child0.setHeight(30f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_position_left_top() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(400f); + root.setHeight(400f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setPosition(YogaEdge.LEFT, 10f); + root_child0.setPosition(YogaEdge.TOP, 20f); + root_child0.setWidth(45f); + root_child0.setHeight(55f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(180f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(180f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_position_bottom_right() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(500f); + root.setHeight(500f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setPosition(YogaEdge.RIGHT, 20f); + root_child0.setPosition(YogaEdge.BOTTOM, 10f); + root_child0.setWidth(55f); + root_child0.setHeight(15f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(-100f, root_child0.getLayoutX(), 0.0f); + assertEquals(-50f, root_child0.getLayoutY(), 0.0f); + assertEquals(275f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(125f, root_child0.getLayoutX(), 0.0f); + assertEquals(-50f, root_child0.getLayoutY(), 0.0f); + assertEquals(275f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(1f); + root_child1.setFlexBasis(25f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(125f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(125f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(75f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(75f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(125f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(75f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_cross() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(1f); + root_child1.setFlexBasis(25f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(125f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(125f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(125f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(125f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_cross_min_height() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setMinHeight(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(2f); + root_child1.setMinHeight(10f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(140f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(140f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(140f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(140f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_main_max_height() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(10f); + root_child0.setMaxHeight(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(10f); + root_child1.setMaxHeight(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(52f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(148f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(148f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(52f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(148f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_cross_max_height() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(10f); + root_child0.setMaxHeight(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(10f); + root_child1.setMaxHeight(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(120f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(120f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_main_max_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(15f); + root_child0.setMaxWidth(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(10f); + root_child1.setMaxWidth(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_cross_max_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(10f); + root_child0.setMaxWidth(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(15f); + root_child1.setMaxWidth(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, 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(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_main_min_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(15f); + root_child0.setMinWidth(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(10f); + root_child1.setMinWidth(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_flex_basis_cross_min_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(10f); + root_child0.setMinWidth(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(15f); + root_child1.setMinWidth(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, 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(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, 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(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(10f); + root_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0.setMargin(YogaEdge.TOP, 5f); + root_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0.setPadding(YogaEdge.LEFT, 3); + root_child0.setPadding(YogaEdge.TOP, 3); + root_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0.setMinWidth(60f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0_child0.setMargin(YogaEdge.TOP, 5f); + root_child0_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0_child0.setMargin(YogaEdge.BOTTOM, 5f); + 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.setWidth(50f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child0_child0 = new YogaNode(); + root_child0_child0_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0_child0_child0.setMargin(YogaEdge.TOP, 5f); + root_child0_child0_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0_child0_child0.setPadding(YogaEdge.LEFT, 3); + root_child0_child0_child0.setPadding(YogaEdge.TOP, 3); + root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0_child0_child0.setWidth(45f); + root_child0_child0.addChildAt(root_child0_child0_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setFlexGrow(4f); + root_child1.setFlexBasis(15f); + root_child1.setMinWidth(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(190f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(8f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(58f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(142f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(190f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(46f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(58f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(142f, root_child1.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + +} diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp new file mode 100644 index 00000000..e6e1bba7 --- /dev/null +++ b/tests/YGPercentageTest.cpp @@ -0,0 +1,760 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html + +#include +#include + +TEST(YogaTest, percentage_width_height) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(30)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(30)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_position_left_top) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(400)); + YGNodeStyleSetHeightWithUnit(root, YGPx(400)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(20)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(45)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(55)); + 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(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_position_bottom_right) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(500)); + YGNodeStyleSetHeightWithUnit(root, YGPx(500)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeRight, YGPercent(20)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(55)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(15)); + 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(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_cross) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_cross_min_height) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMinHeightWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 2); + YGNodeStyleSetMinHeightWithUnit(root_child1, YGPercent(10)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_main_max_height) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); + YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); + YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_cross_max_height) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); + YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); + YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_main_max_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15)); + YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); + YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_cross_max_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); + YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); + YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, 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(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_main_min_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15)); + YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); + YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_flex_basis_cross_min_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); + YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); + YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, 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(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, 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(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPx(5)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPx(3)); + YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeLeft, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeTop, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeRight, YGPx(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeBottom, YGPx(5)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeLeft, YGPercent(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeTop, YGPercent(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeRight, YGPercent(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeBottom, YGPercent(3)); + YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPercent(50)); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child0_child0 = YGNodeNew(); + YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPercent(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeTop, YGPercent(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeRight, YGPercent(5)); + YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPercent(5)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeTop, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeRight, YGPx(3)); + YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPx(3)); + YGNodeStyleSetWidthWithUnit(root_child0_child0_child0, YGPercent(45)); + YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 4); + YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); + YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} -- 2.50.1.windows.1 From a84d55e3c5fbd7f54ba1f0dc44a255ee5aa40e2f Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Thu, 15 Dec 2016 15:33:55 +0100 Subject: [PATCH 05/39] use correct parent sizes for percentage calculation --- yoga/Yoga.c | 178 ++++++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 82 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 39b01cc3..ca180ac7 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -194,11 +194,13 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], } static inline float YGValueToFloat(const YGValue unit, const float parentSize) { + float result; if (unit.unit == YGUnitPixel){ - return unit.value; + result = unit.value; } else { - return unit.value * parentSize / 100.0f; + result = unit.value * parentSize / 100.0f; } + return result; } static void YGNodeInit(const YGNodeRef node) { @@ -1102,11 +1104,14 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const float width, const YGMeasureMode widthMode, const float height, + const float parentWidth, + const float parentHeight, const YGMeasureMode heightMode, const YGDirection direction) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); - float mainAxisSize = isMainAxisRow ? width : height; + const float mainAxisSize = isMainAxisRow ? width : height; + const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight; float childWidth; float childHeight; @@ -1122,18 +1127,18 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisSize), YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisSize)); + fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisParentSize)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionWidth], width), - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width)); + fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionWidth], parentWidth), + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionHeight], height), - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, height)); + fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight), + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentHeight)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped // flex basis). @@ -1143,13 +1148,13 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { - childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], width) + - YGNodeMarginForAxis(child, YGFlexDirectionRow, width); + childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], parentWidth) + + YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth); childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], height) + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); + childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight) + + YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentHeight); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1189,20 +1194,20 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childWidth * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth)); return; } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childHeight * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, height)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentHeight)); return; } } - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], width), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], parentWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], height), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], parentHeight), &childHeightMeasureMode, &childHeight); @@ -1213,15 +1218,15 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, - width, - height, + parentWidth, + parentHeight, false, "measure"); child->layout.computedFlexBasis = fmaxf(isMainAxisRow ? child->layout.measuredDimensions[YGDimensionWidth] : child->layout.measuredDimensions[YGDimensionHeight], - YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisSize)); + YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisParentSize)); } child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; @@ -1628,31 +1633,38 @@ static void YGNodelayoutImpl(const YGNodeRef node, const YGJustify justifyContent = node->style.justifyContent; const bool isNodeFlexWrap = node->style.flexWrap == YGWrapWrap; - const float mainAxisSize = isMainAxisRow ? availableWidth : availableHeight; - const float crossAxisSize = isMainAxisRow ? availableHeight : availableWidth; + const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight; + const float crossAxisParentSize = isMainAxisRow ? parentHeight : parentWidth; + + //const float mainAxisSize = isMainAxisRow ? availableWidth : availableHeight; + //const float crossAxisSize = isMainAxisRow ? availableHeight : availableWidth; YGNodeRef firstAbsoluteChild = NULL; YGNodeRef currentAbsoluteChild = NULL; - const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, mainAxisSize); - const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, mainAxisSize); - const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis, crossAxisSize); - const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, mainAxisSize); - const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, crossAxisSize); + const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, mainAxisParentSize); + const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, mainAxisParentSize); + const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis, crossAxisParentSize); + const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, mainAxisParentSize); + const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, crossAxisParentSize); const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentHeight); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableHeight); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS + const float possibleNodeWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; + const float possibleNodeHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; + const float possibleNodeMainDim = isMainAxisRow ? possibleNodeWidth : possibleNodeHeight; + const float possibleNodeCrossDim = isMainAxisRow ? possibleNodeHeight : possibleNodeWidth; + const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - const float availableInnerHeight = - availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; + const float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; @@ -1683,7 +1695,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (performLayout) { // Set the initial position (relative to the parent). const YGDirection childDirection = YGNodeResolveDirection(child, direction); - YGNodeSetPosition(child, childDirection, mainAxisSize, crossAxisSize); + YGNodeSetPosition(child, childDirection, crossAxisParentSize, mainAxisParentSize); } // Absolute-positioned children don't participate in flex layout. Add them @@ -1709,6 +1721,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, widthMeasureMode, availableInnerHeight, + possibleNodeWidth, + possibleNodeHeight, heightMeasureMode, direction); } @@ -1757,7 +1771,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = - child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, mainAxisSize); + child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, possibleNodeMainDim); // If this is a multi-line flow and this item pushes us over the // available size, we've @@ -1868,7 +1882,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, mainAxisSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1887,7 +1901,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (flexGrowFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, mainAxisSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1929,7 +1943,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, (remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor; } - updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, mainAxisSize); + updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, possibleNodeMainDim); } } else if (remainingFreeSpace > 0) { flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); @@ -1940,7 +1954,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeBoundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, mainAxisSize); + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, possibleNodeMainDim); } } @@ -1953,7 +1967,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childWidth = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth); childWidthMeasureMode = YGMeasureModeExactly; if (!YGValueIsUndefinedf(availableInnerCrossDim) && @@ -1967,13 +1981,13 @@ static void YGNodelayoutImpl(const YGNodeRef node, childHeightMeasureMode = YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], availableHeight) + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight); + childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], possibleNodeHeight) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight); childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight); childHeightMeasureMode = YGMeasureModeExactly; if (!YGValueIsUndefinedf(availableInnerCrossDim) && @@ -1987,8 +2001,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, childWidthMeasureMode = YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], availableWidth) + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth); + childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], possibleNodeWidth) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth); childWidthMeasureMode = YGMeasureModeExactly; } } @@ -1997,20 +2011,20 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, availableHeight)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow, availableWidth)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth)); childWidthMeasureMode = YGMeasureModeExactly; } } - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableWidth), + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], possibleNodeWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableHeight), + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], possibleNodeHeight), &childHeightMeasureMode, &childHeight); @@ -2026,8 +2040,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, - parentWidth, - parentHeight, + possibleNodeWidth, + possibleNodeHeight, performLayout && !requiresStretchLayout, "flex"); @@ -2051,9 +2065,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { if (!YGValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && - YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisSize) >= 0) { + YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, - YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisSize) - + YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - (availableInnerMainDim - remainingFreeSpace)); } else { remainingFreeSpace = 0; @@ -2096,9 +2110,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said // (and margin/border). - child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, mainAxisSize) + - YGNodeLeadingBorder(node, mainAxis, mainAxisSize) + - YGNodeLeadingMargin(child, mainAxis, mainAxisSize); + child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, possibleNodeMainDim) + + YGNodeLeadingBorder(node, mainAxis, mainAxisParentSize) + + YGNodeLeadingMargin(child, mainAxis, possibleNodeMainDim); } } else { // Now that we placed the element, we need to update the variables. @@ -2113,22 +2127,22 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If we skipped the flex step, then we can't rely on the // measuredDims because // they weren't computed. This means we can't call YGNodeDimWithMargin. - mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, mainAxisSize) + + mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, possibleNodeMainDim) + child->layout.computedFlexBasis; crossDim = availableInnerCrossDim; } else { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, mainAxisSize); + mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, possibleNodeMainDim); // The cross dimension is the max of the elements dimension since // there // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, crossAxisSize)); + crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, possibleNodeCrossDim)); } } else if (performLayout) { child->layout.position[pos[mainAxis]] += - YGNodeLeadingBorder(node, mainAxis, mainAxisSize) + leadingMainDim; + YGNodeLeadingBorder(node, mainAxis, mainAxisParentSize) + leadingMainDim; } } } @@ -2139,7 +2153,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeCrossDim == YGMeasureModeUndefined || measureModeCrossDim == YGMeasureModeAtMost) { // Compute the cross axis from the max cross dimension of the children. - containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisSize) - + containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize) - paddingAndBorderAxisCross; if (measureModeCrossDim == YGMeasureModeAtMost) { @@ -2153,7 +2167,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // Clamp to the min/max size specified on the container. - crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisSize) - + crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize) - paddingAndBorderAxisCross; // STEP 7: CROSS-AXIS ALIGNMENT @@ -2168,12 +2182,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, // set, override all the previously computed positions to set it // correctly. if (YGNodeIsLeadingPosDefined(child, crossAxis)) { - child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, crossAxisSize) + - YGNodeLeadingBorder(node, crossAxis, crossAxisSize) + - YGNodeLeadingMargin(child, crossAxis, crossAxisSize); + child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, possibleNodeCrossDim) + + YGNodeLeadingBorder(node, crossAxis, crossAxisParentSize) + + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); } else { child->layout.position[pos[crossAxis]] = - YGNodeLeadingBorder(node, crossAxis, crossAxisSize) + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); + YGNodeLeadingBorder(node, crossAxis, crossAxisParentSize) + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2200,17 +2214,17 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childHeight = crossDim; childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - YGNodeMarginForAxis(child, YGFlexDirectionRow, availableWidth); + YGNodeMarginForAxis(child, YGFlexDirectionRow, possibleNodeWidth); } else { childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableHeight); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, possibleNodeHeight); } - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], availableWidth), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], possibleNodeWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], availableHeight), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], possibleNodeHeight), &childHeightMeasureMode, &childHeight); @@ -2228,14 +2242,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, - parentWidth, - parentHeight, + possibleNodeWidth, + possibleNodeHeight, true, "stretch"); } } else if (alignItem != YGAlignFlexStart) { const float remainingCrossDim = - containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, crossAxisSize); + containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, possibleNodeCrossDim); if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; @@ -2297,7 +2311,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (YGNodeIsLayoutDimDefined(child, crossAxis)) { lineHeight = fmaxf(lineHeight, child->layout.measuredDimensions[dim[crossAxis]] + - YGNodeMarginForAxis(child, crossAxis, crossAxisSize)); + YGNodeMarginForAxis(child, crossAxis, possibleNodeCrossDim)); } } } @@ -2312,12 +2326,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, switch (YGNodeAlignItem(node, child)) { case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); + currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); break; } case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = - currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, crossAxisSize) - + currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, possibleNodeCrossDim) - child->layout.measuredDimensions[dim[crossAxis]]; break; } @@ -2329,7 +2343,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } case YGAlignStretch: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, crossAxisSize); + currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; @@ -2348,9 +2362,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // STEP 9: COMPUTING FINAL DIMENSIONS node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight); // If the user didn't specify a width or height for the node, set the // dimensions based on the children. @@ -2358,11 +2372,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[mainAxis]] = - YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisSize); + YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize); } else if (measureModeMainDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, - YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisSize)), + YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)), paddingAndBorderAxisMain); } @@ -2370,13 +2384,13 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[crossAxis]] = - YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisSize); + YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisParentSize); } else if (measureModeCrossDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, YGNodeBoundAxisWithinMinAndMax(node, crossAxis, - totalLineCrossDim + paddingAndBorderAxisCross, crossAxisSize)), + totalLineCrossDim + paddingAndBorderAxisCross, crossAxisParentSize)), paddingAndBorderAxisCross); } -- 2.50.1.windows.1 From fc98df63d8115316907c24ea922bca5fb8f88b0b Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Thu, 15 Dec 2016 16:50:37 +0100 Subject: [PATCH 06/39] use only width for calculating margin/padding, border has no percentage support --- gentest/gentest-cpp.js | 2 +- tests/YGAbsolutePositionTest.cpp | 8 +- tests/YGBorderTest.cpp | 38 +++--- yoga/Yoga.c | 211 ++++++++++++++++--------------- yoga/Yoga.h | 2 +- 5 files changed, 136 insertions(+), 125 deletions(-) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 45700a06..7ab7e7de 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -156,7 +156,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetBorderWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index fc4df6c0..25b842c5 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -234,10 +234,10 @@ TEST(YogaTest, absolute_layout_within_border) { YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); YGNodeStyleSetWidthWithUnit(root, YGPx(100)); YGNodeStyleSetHeightWithUnit(root, YGPx(100)); diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index a798c46e..306f1c37 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, border_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,10 +37,10 @@ TEST(YogaTest, border_no_size) { TEST(YogaTest, border_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); @@ -75,10 +75,10 @@ TEST(YogaTest, border_container_match_child) { TEST(YogaTest, border_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); YGNodeStyleSetWidthWithUnit(root, YGPx(100)); YGNodeStyleSetHeightWithUnit(root, YGPx(100)); @@ -115,10 +115,10 @@ TEST(YogaTest, border_flex_child) { TEST(YogaTest, border_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetBorderWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); YGNodeStyleSetWidthWithUnit(root, YGPx(100)); YGNodeStyleSetHeightWithUnit(root, YGPx(100)); @@ -156,9 +156,9 @@ TEST(YogaTest, border_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetBorderWithUnit(root, YGEdgeStart, YGPx(10)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeEnd, YGPx(20)); - YGNodeStyleSetBorderWithUnit(root, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetBorder(root, YGEdgeStart, 10); + YGNodeStyleSetBorder(root, YGEdgeEnd, 20); + YGNodeStyleSetBorder(root, YGEdgeBottom, 20); YGNodeStyleSetWidthWithUnit(root, YGPx(100)); YGNodeStyleSetHeightWithUnit(root, YGPx(100)); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index ca180ac7..cc610894 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -537,6 +537,20 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue).value; \ } +#define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName, defaultValue) \ + void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName[edge].unit = YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ + return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue).value; \ + } + #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node) { \ return node->layout.instanceName; \ @@ -563,7 +577,7 @@ YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGUndefined); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, 0); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding, 0); -YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Border, border, border, 0); +YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, 0); YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]); YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Height, height, dimensions[YGDimensionHeight]); @@ -846,75 +860,75 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse; } -static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeStart])) { - return YGValueToFloat(node->style.margin[YGEdgeStart], axisSize); + return YGValueToFloat(node->style.margin[YGEdgeStart], widthSize); } - return YGValueToFloat(YGComputedEdgeValue(node->style.margin, leading[axis], 0), axisSize); + return YGValueToFloat(YGComputedEdgeValue(node->style.margin, leading[axis], 0), widthSize); } -static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeEnd])) { - return YGValueToFloat(node->style.margin[YGEdgeEnd], axisSize); + return YGValueToFloat(node->style.margin[YGEdgeEnd], widthSize); } - return YGValueToFloat(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), axisSize); + return YGValueToFloat(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), widthSize); } -static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeStart]) && - YGValueToFloat(node->style.padding[YGEdgeStart], axisSize) >= 0) { - return YGValueToFloat(node->style.padding[YGEdgeStart], axisSize); + YGValueToFloat(node->style.padding[YGEdgeStart], widthSize) >= 0) { + return YGValueToFloat(node->style.padding[YGEdgeStart], widthSize); } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, leading[axis], 0), axisSize), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, leading[axis], 0), widthSize), 0); } -static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeEnd]) && - YGValueToFloat(node->style.padding[YGEdgeEnd], axisSize) >= 0) { - return YGValueToFloat(node->style.padding[YGEdgeEnd], axisSize); + YGValueToFloat(node->style.padding[YGEdgeEnd], widthSize) >= 0) { + return YGValueToFloat(node->style.padding[YGEdgeEnd], widthSize); } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), axisSize), 0); + return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), widthSize), 0); } -static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeStart]) && - YGValueToFloat(node->style.border[YGEdgeStart], axisSize) >= 0) { - return YGValueToFloat(node->style.border[YGEdgeStart], axisSize); + node->style.border[YGEdgeStart].value >= 0) { + return node->style.border[YGEdgeStart].value; } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.border, leading[axis], 0), axisSize), 0); + return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], 0).value, 0); } -static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { +static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeEnd]) && - YGValueToFloat(node->style.border[YGEdgeEnd], axisSize) >= 0) { - return YGValueToFloat(node->style.border[YGEdgeEnd], axisSize); + node->style.border[YGEdgeEnd].value >= 0) { + return node->style.border[YGEdgeEnd].value; } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.border, trailing[axis], 0), axisSize), 0); + return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], 0).value, 0); } static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node, - const YGFlexDirection axis, const float axisSize) { - return YGNodeLeadingPadding(node, axis, axisSize) + YGNodeLeadingBorder(node, axis, axisSize); + const YGFlexDirection axis, const float widthSize) { + return YGNodeLeadingPadding(node, axis, widthSize) + YGNodeLeadingBorder(node, axis); } static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node, - const YGFlexDirection axis, const float axisSize) { - return YGNodeTrailingPadding(node, axis, axisSize) + YGNodeTrailingBorder(node, axis, axisSize); + const YGFlexDirection axis, const float widthSize) { + return YGNodeTrailingPadding(node, axis, widthSize) + YGNodeTrailingBorder(node, axis); } -static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { - return YGNodeLeadingMargin(node, axis, axisSize) + YGNodeTrailingMargin(node, axis, axisSize); +static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { + return YGNodeLeadingMargin(node, axis, widthSize) + YGNodeTrailingMargin(node, axis, widthSize); } static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, - const YGFlexDirection axis, const float axisSize) { - return YGNodeLeadingPaddingAndBorder(node, axis, axisSize) + YGNodeTrailingPaddingAndBorder(node, axis, axisSize); + const YGFlexDirection axis, const float widthSize) { + return YGNodeLeadingPaddingAndBorder(node, axis, widthSize) + YGNodeTrailingPaddingAndBorder(node, axis, widthSize); } static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { @@ -955,9 +969,9 @@ static inline bool YGNodeIsFlex(const YGNodeRef node) { (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); } -static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { - return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis, axisSize) + - YGNodeTrailingMargin(node, axis, axisSize); +static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { + return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis, widthSize) + + YGNodeTrailingMargin(node, axis, widthSize); } static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -1046,9 +1060,9 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, // padding and border amount. static inline float YGNodeBoundAxis(const YGNodeRef node, const YGFlexDirection axis, - const float value, const float axisSize) { + const float value, const float axisSize, const float widthSize) { return fmaxf(YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize), - YGNodePaddingAndBorderForAxis(node, axis, axisSize)); + YGNodePaddingAndBorderForAxis(node, axis, widthSize)); } static void YGNodeSetChildTrailingPosition(const YGNodeRef node, @@ -1083,20 +1097,20 @@ static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, } } -static void YGNodeSetPosition(const YGNodeRef node, const YGDirection direction, const float mainSize, const float crossSize) { +static void YGNodeSetPosition(const YGNodeRef node, const YGDirection direction, const float mainSize, const float crossSize, const float parentWidth) { const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); const float relativePositionMain = YGNodeRelativePosition(node, mainAxis, mainSize); const float relativePositionCross = YGNodeRelativePosition(node, crossAxis, crossSize); node->layout.position[leading[mainAxis]] = - YGNodeLeadingMargin(node, mainAxis, mainSize) + relativePositionMain; + YGNodeLeadingMargin(node, mainAxis, parentWidth) + relativePositionMain; node->layout.position[trailing[mainAxis]] = - YGNodeTrailingMargin(node, mainAxis, mainSize) + relativePositionMain; + YGNodeTrailingMargin(node, mainAxis, parentWidth) + relativePositionMain; node->layout.position[leading[crossAxis]] = - YGNodeLeadingMargin(node, crossAxis, crossSize) + relativePositionCross; + YGNodeLeadingMargin(node, crossAxis, parentWidth) + relativePositionCross; node->layout.position[trailing[crossAxis]] = - YGNodeTrailingMargin(node, crossAxis, crossSize) + relativePositionCross; + YGNodeTrailingMargin(node, crossAxis, parentWidth) + relativePositionCross; } static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, @@ -1154,7 +1168,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, } if (isColumnStyleDimDefined) { childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight) + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentHeight); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1257,17 +1271,17 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionRow) && YGNodeIsTrailingPosDefined(child, YGFlexDirectionRow)) { childWidth = node->layout.measuredDimensions[YGDimensionWidth] - - (YGNodeLeadingBorder(node, YGFlexDirectionRow, width) + - YGNodeTrailingBorder(node, YGFlexDirectionRow, width)) - + (YGNodeLeadingBorder(node, YGFlexDirectionRow) + + YGNodeTrailingBorder(node, YGFlexDirectionRow)) - (YGNodeLeadingPosition(child, YGFlexDirectionRow, width) + YGNodeTrailingPosition(child, YGFlexDirectionRow, width)); - childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width); + childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width); } } if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) { childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], height) + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, width); } else { // If the child doesn't have a specified height, compute the height // based on the top/bottom @@ -1275,11 +1289,11 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionColumn) && YGNodeIsTrailingPosDefined(child, YGFlexDirectionColumn)) { childHeight = node->layout.measuredDimensions[YGDimensionHeight] - - (YGNodeLeadingBorder(node, YGFlexDirectionColumn, height) + - YGNodeTrailingBorder(node, YGFlexDirectionColumn, height)) - - (YGNodeLeadingPosition(child, YGFlexDirectionColumn, height) + - YGNodeTrailingPosition(child, YGFlexDirectionColumn, height)); - childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height); + (YGNodeLeadingBorder(node, YGFlexDirectionColumn) + + YGNodeTrailingBorder(node, YGFlexDirectionColumn)) - + (YGNodeLeadingPosition(child, YGFlexDirectionColumn, width) + + YGNodeTrailingPosition(child, YGFlexDirectionColumn, width)); + childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width); } } @@ -1289,7 +1303,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, if (!YGValueIsUndefinedf(child->style.aspectRatio)) { if (YGValueIsUndefinedf(childWidth)) { childWidth = fmaxf(childHeight * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, height)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width)); } else if (YGValueIsUndefinedf(childHeight)) { childHeight = fmaxf(childWidth * child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width)); @@ -1326,7 +1340,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childWidth = child->layout.measuredDimensions[YGDimensionWidth] + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, height); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, width); } YGLayoutNodeInternal(child, @@ -1344,16 +1358,16 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, const float mainAxisSize = isMainAxisRow ? width : height; child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - child->layout.measuredDimensions[dim[mainAxis]] - - YGNodeTrailingBorder(node, mainAxis, mainAxisSize) - - YGNodeTrailingPosition(child, mainAxis, mainAxisSize); + YGNodeTrailingBorder(node, mainAxis) - + YGNodeTrailingPosition(child, mainAxis, width); } if (YGNodeIsTrailingPosDefined(child, crossAxis) && !YGNodeIsLeadingPosDefined(child, crossAxis)) { const float crossAxisSize = isMainAxisRow ? height : width; child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - - YGNodeTrailingBorder(node, crossAxis, crossAxisSize) - - YGNodeTrailingPosition(child, crossAxis, crossAxisSize); + YGNodeTrailingBorder(node, crossAxis) - + YGNodeTrailingPosition(child, crossAxis, width); } } @@ -1368,7 +1382,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableHeight); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; @@ -1376,16 +1390,16 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) { // Don't bother sizing the text if both dimensions are already defined. node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight, availableWidth); } else if (innerWidth <= 0 || innerHeight <= 0) { // Don't bother sizing the text if there's no horizontal or vertical // space. node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, 0, availableWidth); + YGNodeBoundAxis(node, YGFlexDirectionRow, 0, availableWidth, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, 0, availableHeight); + YGNodeBoundAxis(node, YGFlexDirectionColumn, 0, availableHeight, availableWidth); } else { // Measure the text under the current constraints. const YGSize measuredSize = @@ -1397,14 +1411,14 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, (widthMeasureMode == YGMeasureModeUndefined || widthMeasureMode == YGMeasureModeAtMost) ? measuredSize.width + paddingAndBorderAxisRow - : availableWidth - marginAxisRow, availableWidth); + : availableWidth - marginAxisRow, availableWidth, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, (heightMeasureMode == YGMeasureModeUndefined || heightMeasureMode == YGMeasureModeAtMost) ? measuredSize.height + paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn, availableHeight); + : availableHeight - marginAxisColumn, availableHeight, availableWidth); } } @@ -1421,7 +1435,7 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node, const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(node, @@ -1429,14 +1443,14 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node, (widthMeasureMode == YGMeasureModeUndefined || widthMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisRow - : availableWidth - marginAxisRow, parentWidth); + : availableWidth - marginAxisRow, parentWidth, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, (heightMeasureMode == YGMeasureModeUndefined || heightMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn, parentHeight); + : availableHeight - marginAxisColumn, parentHeight, parentWidth); } static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, @@ -1457,14 +1471,14 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, YGFlexDirectionRow, YGValueIsUndefinedf(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) ? 0 - : availableWidth - marginAxisRow, parentWidth); + : availableWidth - marginAxisRow, parentWidth, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, YGValueIsUndefinedf(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) ? 0 - : availableHeight - marginAxisColumn, parentHeight); + : availableHeight - marginAxisColumn, parentHeight, parentHeight); return true; } @@ -1636,9 +1650,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight; const float crossAxisParentSize = isMainAxisRow ? parentHeight : parentWidth; - //const float mainAxisSize = isMainAxisRow ? availableWidth : availableHeight; - //const float crossAxisSize = isMainAxisRow ? availableHeight : availableWidth; - YGNodeRef firstAbsoluteChild = NULL; YGNodeRef currentAbsoluteChild = NULL; @@ -1655,7 +1666,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentHeight); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS const float possibleNodeWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; @@ -1695,7 +1706,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (performLayout) { // Set the initial position (relative to the parent). const YGDirection childDirection = YGNodeResolveDirection(child, direction); - YGNodeSetPosition(child, childDirection, crossAxisParentSize, mainAxisParentSize); + YGNodeSetPosition(child, childDirection, possibleNodeMainDim, possibleNodeCrossDim, possibleNodeWidth); } // Absolute-positioned children don't participate in flex layout. Add them @@ -1771,7 +1782,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = - child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, possibleNodeMainDim); + child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, possibleNodeWidth); // If this is a multi-line flow and this item pushes us over the // available size, we've @@ -1882,7 +1893,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim, possibleNodeWidth); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1901,7 +1912,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (flexGrowFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim, possibleNodeWidth); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1943,7 +1954,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, (remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor; } - updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, possibleNodeMainDim); + updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, possibleNodeMainDim, possibleNodeWidth); } } else if (remainingFreeSpace > 0) { flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); @@ -1954,7 +1965,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeBoundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, possibleNodeMainDim); + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, possibleNodeMainDim, possibleNodeWidth); } } @@ -1982,12 +1993,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], possibleNodeHeight) + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight); + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth); childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth); childHeightMeasureMode = YGMeasureModeExactly; if (!YGValueIsUndefinedf(availableInnerCrossDim) && @@ -2111,8 +2122,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, // defined, we override the position to whatever the user said // (and margin/border). child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, possibleNodeMainDim) + - YGNodeLeadingBorder(node, mainAxis, mainAxisParentSize) + - YGNodeLeadingMargin(child, mainAxis, possibleNodeMainDim); + YGNodeLeadingBorder(node, mainAxis) + + YGNodeLeadingMargin(child, mainAxis, possibleNodeWidth); } } else { // Now that we placed the element, we need to update the variables. @@ -2127,7 +2138,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If we skipped the flex step, then we can't rely on the // measuredDims because // they weren't computed. This means we can't call YGNodeDimWithMargin. - mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, possibleNodeMainDim) + + mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, possibleNodeWidth) + child->layout.computedFlexBasis; crossDim = availableInnerCrossDim; } else { @@ -2142,7 +2153,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } } else if (performLayout) { child->layout.position[pos[mainAxis]] += - YGNodeLeadingBorder(node, mainAxis, mainAxisParentSize) + leadingMainDim; + YGNodeLeadingBorder(node, mainAxis) + leadingMainDim; } } } @@ -2153,7 +2164,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeCrossDim == YGMeasureModeUndefined || measureModeCrossDim == YGMeasureModeAtMost) { // Compute the cross axis from the max cross dimension of the children. - containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize) - + containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize, parentWidth) - paddingAndBorderAxisCross; if (measureModeCrossDim == YGMeasureModeAtMost) { @@ -2167,7 +2178,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // Clamp to the min/max size specified on the container. - crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize) - + crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross, crossAxisParentSize, parentWidth) - paddingAndBorderAxisCross; // STEP 7: CROSS-AXIS ALIGNMENT @@ -2183,11 +2194,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, // correctly. if (YGNodeIsLeadingPosDefined(child, crossAxis)) { child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, possibleNodeCrossDim) + - YGNodeLeadingBorder(node, crossAxis, crossAxisParentSize) + + YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); } else { child->layout.position[pos[crossAxis]] = - YGNodeLeadingBorder(node, crossAxis, crossAxisParentSize) + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); + YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2218,7 +2229,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else { childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, possibleNodeHeight); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, possibleNodeWidth); } YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], possibleNodeWidth), @@ -2311,7 +2322,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (YGNodeIsLayoutDimDefined(child, crossAxis)) { lineHeight = fmaxf(lineHeight, child->layout.measuredDimensions[dim[crossAxis]] + - YGNodeMarginForAxis(child, crossAxis, possibleNodeCrossDim)); + YGNodeMarginForAxis(child, crossAxis, possibleNodeWidth)); } } } @@ -2326,12 +2337,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, switch (YGNodeAlignItem(node, child)) { case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); + currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); break; } case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = - currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, possibleNodeCrossDim) - + currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, possibleNodeWidth) - child->layout.measuredDimensions[dim[crossAxis]]; break; } @@ -2362,9 +2373,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // STEP 9: COMPUTING FINAL DIMENSIONS node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth); // If the user didn't specify a width or height for the node, set the // dimensions based on the children. @@ -2372,7 +2383,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[mainAxis]] = - YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize); + YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth); } else if (measureModeMainDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, @@ -2384,7 +2395,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // Clamp the size to the min/max size, if specified, and make sure it // doesn't go below the padding and border amount. node->layout.measuredDimensions[dim[crossAxis]] = - YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisParentSize); + YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisParentSize, parentWidth); } else if (measureModeCrossDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, @@ -2573,7 +2584,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, // all possible. if (node->measure) { const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); // First, try to use the layout cache. if (YGNodeCanUseCachedMeasurement(widthMeasureMode, @@ -2774,7 +2785,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, heightMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { height = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + - YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableHeight); + YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); heightMeasureMode = YGMeasureModeExactly; } else if (YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { height = YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight); @@ -2792,7 +2803,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, true, "initia" "l")) { - YGNodeSetPosition(node, node->layout.direction, availableWidth, availableHeight); + YGNodeSetPosition(node, node->layout.direction, availableWidth, availableHeight, availableWidth); if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { roundToPixelGrid(node); diff --git a/yoga/Yoga.h b/yoga/Yoga.h index e49ccdb6..6272b7f8 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -162,7 +162,7 @@ YG_NODE_STYLE_PROPERTY_UNIT(YGValue, FlexBasis, flexBasis); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Position, position); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Margin, margin); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Padding, padding); -YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Border, border); +YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Width, width); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Height, height); -- 2.50.1.windows.1 From 54e943d4529742da6e59148c0d9eb8dd8aeb1e68 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Thu, 15 Dec 2016 17:05:06 +0100 Subject: [PATCH 07/39] corrected last wrong usage of height --- yoga/Yoga.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index cc610894..a117cfe6 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1141,7 +1141,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisParentSize)); + fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. @@ -1152,7 +1152,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, // The height is definite, so use that as the flex basis. child->layout.computedFlexBasis = fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight), - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentHeight)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped // flex basis). @@ -1213,7 +1213,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childHeight * child->style.aspectRatio, - YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentHeight)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth)); return; } } @@ -1240,7 +1240,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, child->layout.computedFlexBasis = fmaxf(isMainAxisRow ? child->layout.measuredDimensions[YGDimensionWidth] : child->layout.measuredDimensions[YGDimensionHeight], - YGNodePaddingAndBorderForAxis(child, mainAxis, mainAxisParentSize)); + YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); } child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; @@ -1380,7 +1380,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableHeight); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableWidth); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); @@ -1433,7 +1433,7 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node, const float parentHeight) { const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentWidth); const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentWidth); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); @@ -1463,7 +1463,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0) || (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly)) { - const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentHeight); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); node->layout.measuredDimensions[YGDimensionWidth] = @@ -1478,7 +1478,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, YGFlexDirectionColumn, YGValueIsUndefinedf(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) ? 0 - : availableHeight - marginAxisColumn, parentHeight, parentHeight); + : availableHeight - marginAxisColumn, parentHeight, parentWidth); return true; } @@ -1653,19 +1653,18 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeRef firstAbsoluteChild = NULL; YGNodeRef currentAbsoluteChild = NULL; - const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, mainAxisParentSize); - const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, mainAxisParentSize); - const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis, crossAxisParentSize); - const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, mainAxisParentSize); - const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, crossAxisParentSize); + const float leadingPaddingAndBorderMain = YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth); + const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth); + const float leadingPaddingAndBorderCross = YGNodeLeadingPaddingAndBorder(node, crossAxis, parentWidth); + const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, parentWidth); + const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth); const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentHeight); - const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentHeight); - const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentHeight); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentWidth); + const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentWidth); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS @@ -2022,7 +2021,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeHeight)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { childWidth = @@ -2144,12 +2143,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, possibleNodeMainDim); + mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, possibleNodeWidth); // The cross dimension is the max of the elements dimension since // there // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, possibleNodeCrossDim)); + crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, possibleNodeWidth)); } } else if (performLayout) { child->layout.position[pos[mainAxis]] += @@ -2195,10 +2194,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (YGNodeIsLeadingPosDefined(child, crossAxis)) { child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, possibleNodeCrossDim) + YGNodeLeadingBorder(node, crossAxis) + - YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); } else { child->layout.position[pos[crossAxis]] = - YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); + YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2260,7 +2259,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } } else if (alignItem != YGAlignFlexStart) { const float remainingCrossDim = - containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, possibleNodeCrossDim); + containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, possibleNodeWidth); if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; @@ -2354,7 +2353,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } case YGAlignStretch: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeCrossDim); + currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; -- 2.50.1.windows.1 From 7b71daa929f5fccb25aa2b91f0720dab0a1548f2 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 16 Dec 2016 10:59:28 +0100 Subject: [PATCH 08/39] added explicit tests for padding, margin and absolute --- .../tests/Facebook.Yoga/YGPercentageTest.cs | 165 ++++++++++++++++++ gentest/fixtures/YGPercentageTest.html | 19 ++ .../com/facebook/yoga/YGPercentageTest.java | 162 +++++++++++++++++ tests/YGPercentageTest.cpp | 159 +++++++++++++++++ 4 files changed, 505 insertions(+) diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index 2a38c185..7a7f4cc9 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -790,5 +790,170 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } + [Test] + public void Test_percentage_margin_should_calculate_based_only_on_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.SetMargin(YogaEdge.Left, 10f); + root_child0.SetMargin(YogaEdge.Top, 10f); + root_child0.SetMargin(YogaEdge.Right, 10f); + root_child0.SetMargin(YogaEdge.Bottom, 10f); + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.Width = 10f; + root_child0_child0.Height = 10f; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(160f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(160f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + Assert.AreEqual(150f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_padding_should_calculate_based_only_on_width() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root_child0.SetPadding(YogaEdge.Left, 10f); + root_child0.SetPadding(YogaEdge.Top, 10f); + root_child0.SetPadding(YogaEdge.Right, 10f); + root_child0.SetPadding(YogaEdge.Bottom, 10f); + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.Width = 10f; + root_child0_child0.Height = 10f; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(20f, root_child0_child0.LayoutX); + Assert.AreEqual(20f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(170f, root_child0_child0.LayoutX); + Assert.AreEqual(20f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_percentage_absolute_position() + { + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + + YogaNode root = new YogaNode(); + root.Width = 200f; + root.Height = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Left, 30f); + root_child0.SetPosition(YogaEdge.Top, 10f); + root_child0.Width = 10f; + root_child0.Height = 10f; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(60f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(60f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + } + } } diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html index 0384ecb9..b6eb42ae 100644 --- a/gentest/fixtures/YGPercentageTest.html +++ b/gentest/fixtures/YGPercentageTest.html @@ -64,4 +64,23 @@
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java index 506b9b6c..2ca53c0f 100644 --- a/java/tests/com/facebook/yoga/YGPercentageTest.java +++ b/java/tests/com/facebook/yoga/YGPercentageTest.java @@ -776,4 +776,166 @@ public class YGPercentageTest { YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } + @Test + public void test_percentage_margin_should_calculate_based_only_on_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setMargin(YogaEdge.LEFT, 10f); + root_child0.setMargin(YogaEdge.TOP, 10f); + root_child0.setMargin(YogaEdge.RIGHT, 10f); + root_child0.setMargin(YogaEdge.BOTTOM, 10f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(160f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(160f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_padding_should_calculate_based_only_on_width() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root_child0.setPadding(YogaEdge.LEFT, 10); + root_child0.setPadding(YogaEdge.TOP, 10); + root_child0.setPadding(YogaEdge.RIGHT, 10); + root_child0.setPadding(YogaEdge.BOTTOM, 10); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, 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(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, 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(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(170f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_percentage_absolute_position() { + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + + final YogaNode root = new YogaNode(); + root.setWidth(200f); + root.setHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 30f); + root_child0.setPosition(YogaEdge.TOP, 10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + } + } diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp index e6e1bba7..a9ecdfaa 100644 --- a/tests/YGPercentageTest.cpp +++ b/tests/YGPercentageTest.cpp @@ -758,3 +758,162 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } + +TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPercent(10)); + YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10)); + 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(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPercent(10)); + YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10)); + 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(200, 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(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, 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(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} + +TEST(YogaTest, percentage_absolute_position) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); + + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidthWithUnit(root, YGPx(200)); + YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(30)); + YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); +} -- 2.50.1.windows.1 From 8b6079cdf7cdded07c0c186f8a2f545bc96d797a Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 16 Dec 2016 11:02:29 +0100 Subject: [PATCH 09/39] revert unrelated changes --- .gitignore | 5 ----- csharp/Yoga/YGInterop.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 42953e20..5b346768 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,3 @@ # Visual studio code .vscode -*.pdb -*.tlog -*.obj -*.pch -*.log diff --git a/csharp/Yoga/YGInterop.cpp b/csharp/Yoga/YGInterop.cpp index 63181112..fc2043dc 100644 --- a/csharp/Yoga/YGInterop.cpp +++ b/csharp/Yoga/YGInterop.cpp @@ -15,7 +15,7 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { int result = 0; if (gManagedFunc) { char buffer[256]; - result = vsnprintf_s(buffer, sizeof(buffer), format, args); + result = vsnprintf(buffer, sizeof(buffer), format, args); (*gManagedFunc)(level, buffer); } return result; -- 2.50.1.windows.1 From 9cce30c91f7567637328903f7d36140dac8e9806 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 16 Dec 2016 11:15:28 +0100 Subject: [PATCH 10/39] update indentation --- gentest/fixtures/YGPercentageTest.html | 72 ++++++++++++-------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html index b6eb42ae..87c4753c 100644 --- a/gentest/fixtures/YGPercentageTest.html +++ b/gentest/fixtures/YGPercentageTest.html @@ -1,86 +1,82 @@
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
+
\ No newline at end of file -- 2.50.1.windows.1 From f84583c00216cd8133edb66f21768daf7347b8da Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 16 Dec 2016 11:29:35 +0100 Subject: [PATCH 11/39] renamed some function and removed unused/duplicate variables --- tests/YGLayoutDefaultValuesTest.cpp | 42 +++--- yoga/Yoga.c | 195 +++++++++++++--------------- yoga/Yoga.h | 2 +- 3 files changed, 115 insertions(+), 124 deletions(-) diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index 753a8bd9..97d10b7a 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -27,49 +27,49 @@ TEST(YogaTest, assert_default_values) { ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetFlexBasis(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetFlexBasis(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeLeft))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeTop))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeRight))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeBottom))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPosition(root, YGEdgeEnd))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMargin(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMargin(root, YGEdgeEnd))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPadding(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetPadding(root, YGEdgeEnd))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd))); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom)); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetBorder(root, YGEdgeStart))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetBorder(root, YGEdgeEnd))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetWidth(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetHeight(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMinWidth(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMinHeight(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMaxWidth(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeStyleGetMaxHeight(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetWidth(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetHeight(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMinWidth(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMinHeight(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxWidth(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxHeight(root))); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root)); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeLayoutGetWidth(root))); - ASSERT_TRUE(YGValueIsUndefinedf(YGNodeLayoutGetHeight(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetWidth(root))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetHeight(root))); ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root)); YGNodeFreeRecursive(root); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index a117cfe6..6bdd6423 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -194,13 +194,11 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], } static inline float YGValueToFloat(const YGValue unit, const float parentSize) { - float result; if (unit.unit == YGUnitPixel){ - result = unit.value; + return unit.value; } else { - result = unit.value * parentSize / 100.0f; + return unit.value * parentSize / 100.0f; } - return result; } static void YGNodeInit(const YGNodeRef node) { @@ -284,7 +282,7 @@ int32_t gNodeInstanceCount = 0; YGValue YGPx(const float value){ YGValue result; result.value = value; - result.defined = !YGValueIsUndefinedf(value); + result.defined = !YGFloatIsUndefined(value); result.unit = YGUnitPixel; return result; } @@ -292,7 +290,7 @@ YGValue YGPx(const float value){ YGValue YGPercent(const float value){ YGValue result; result.value = value; - result.defined = !YGValueIsUndefinedf(value); + result.defined = !YGFloatIsUndefined(value); result.unit = YGUnitPercent; return result; } @@ -412,20 +410,20 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) { } inline float YGNodeStyleGetFlexGrow(const YGNodeRef node) { - if (!YGValueIsUndefinedf(node->style.flexGrow)) { + if (!YGFloatIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; } - if (!YGValueIsUndefinedf(node->style.flex) && node->style.flex > 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { return node->style.flex; } return 0; } inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { - if (!YGValueIsUndefinedf(node->style.flexShrink)) { + if (!YGFloatIsUndefined(node->style.flexShrink)) { return node->style.flexShrink; } - if (!YGValueIsUndefinedf(node->style.flex) && node->style.flex < 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex < 0) { return -node->style.flex; } return 0; @@ -435,7 +433,7 @@ inline float YGNodeStyleGetFlexBasis(const YGNodeRef node) { if (!YGValueIsUndefined(node->style.flexBasis)) { return node->style.flexBasis.value; } - if (!YGValueIsUndefinedf(node->style.flex)) { + if (!YGFloatIsUndefined(node->style.flex)) { return node->style.flex > 0 ? 0 : YGUndefined; } return YGUndefined; @@ -445,7 +443,7 @@ inline YGValue YGNodeStyleGetFlexBasisWithUnit(const YGNodeRef node) { if (!YGValueIsUndefined(node->style.flexBasis)) { return node->style.flexBasis; } - if (!YGValueIsUndefinedf(node->style.flex)) { + if (!YGFloatIsUndefined(node->style.flex)) { return YGPx(node->style.flex > 0 ? 0 : YGUndefined); } return YGPx(YGUndefined); @@ -479,7 +477,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName) { \ if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ node->style.instanceName.value = paramName.value; \ - node->style.instanceName.defined = !YGValueIsUndefinedf(paramName.value); \ + node->style.instanceName.defined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName.unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -487,7 +485,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const float paramName) { \ if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPixel) { \ node->style.instanceName.value = paramName; \ - node->style.instanceName.defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName.defined = !YGFloatIsUndefined(paramName); \ node->style.instanceName.unit = YGUnitPixel; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -514,7 +512,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const YGEdge edge, const type paramName) { \ if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ node->style.instanceName[edge].value = paramName.value; \ - node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName.value); \ + node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName[edge].unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -523,7 +521,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName); \ node->style.instanceName[edge].unit = YGUnitPixel; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -541,7 +539,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].defined = !YGValueIsUndefinedf(paramName); \ + node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName); \ node->style.instanceName[edge].unit = YGUnitPixel; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -610,7 +608,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const bool performLayout, const char *reason); -inline bool YGValueIsUndefinedf(const float value) { +inline bool YGFloatIsUndefined(const float value) { return isnan(value); } @@ -630,8 +628,8 @@ static inline bool YGValueEqual(const YGValue a, const YGValue b) { } static inline bool YGFloatsEqual(const float a, const float b) { - if (YGValueIsUndefinedf(a)) { - return YGValueIsUndefinedf(b); + if (YGFloatIsUndefined(a)) { + return YGFloatIsUndefined(b); } return fabs(a - b) < 0.0001; } @@ -649,7 +647,7 @@ static void YGPrintNumberIfNotZero(const char *str, const YGValue number) { } static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { - if (!YGValueIsUndefinedf(number)) { + if (!YGFloatIsUndefined(number)) { YGLog(YGLogLevelDebug, "%s: %g, ", str, number); } } @@ -981,7 +979,7 @@ static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDir static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const float value = node->layout.measuredDimensions[dim[axis]]; - return !YGValueIsUndefinedf(value) && value >= 0.0; + return !YGFloatIsUndefined(value) && value >= 0.0; } static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -1044,11 +1042,11 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, float boundValue = value; - if (!YGValueIsUndefinedf(max) && max >= 0.0 && boundValue > max) { + if (!YGFloatIsUndefined(max) && max >= 0.0 && boundValue > max) { boundValue = max; } - if (!YGValueIsUndefinedf(min) && min >= 0.0 && boundValue < min) { + if (!YGFloatIsUndefined(min) && min >= 0.0 && boundValue < min) { boundValue = min; } @@ -1084,10 +1082,10 @@ static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, switch (*mode) { case YGMeasureModeExactly: case YGMeasureModeAtMost: - *size = (YGValueIsUndefinedf(maxSize) || *size < maxSize) ? *size : maxSize; + *size = (YGFloatIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; break; case YGMeasureModeUndefined: - if (!YGValueIsUndefinedf(maxSize)) { + if (!YGFloatIsUndefined(maxSize)) { *mode = YGMeasureModeAtMost; *size = maxSize; } @@ -1136,8 +1134,8 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); if (!YGValueIsUndefined(YGNodeStyleGetFlexBasisWithUnit(child)) && - !YGValueIsUndefinedf(mainAxisSize)) { - if (YGValueIsUndefinedf(child->layout.computedFlexBasis) || + !YGFloatIsUndefined(mainAxisSize)) { + if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = @@ -1176,7 +1174,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, // but all major browsers appear to implement the following logic. if ((!isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (YGValueIsUndefinedf(childWidth) && !YGValueIsUndefinedf(width)) { + if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } @@ -1184,7 +1182,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if ((isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (YGValueIsUndefinedf(childHeight) && !YGValueIsUndefinedf(height)) { + if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) { childHeight = height; childHeightMeasureMode = YGMeasureModeAtMost; } @@ -1193,18 +1191,18 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, // If child has no defined size in the cross axis and is set to stretch, // set the cross // axis to be measured exactly with the available inner width - if (!isMainAxisRow && !YGValueIsUndefinedf(width) && !isRowStyleDimDefined && + if (!isMainAxisRow && !YGFloatIsUndefined(width) && !isRowStyleDimDefined && widthMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childWidth = width; childWidthMeasureMode = YGMeasureModeExactly; } - if (isMainAxisRow && !YGValueIsUndefinedf(height) && !isColumnStyleDimDefined && + if (isMainAxisRow && !YGFloatIsUndefined(height) && !isColumnStyleDimDefined && heightMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childHeight = height; childHeightMeasureMode = YGMeasureModeExactly; } - if (!YGValueIsUndefinedf(child->style.aspectRatio)) { + if (!YGFloatIsUndefined(child->style.aspectRatio)) { if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childWidth * child->style.aspectRatio, @@ -1299,12 +1297,12 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, // Exactly one dimension needs to be defined for us to be able to do aspect ratio // calculation. One dimension being the anchor and the other being flexible. - if (YGValueIsUndefinedf(childWidth) ^ YGValueIsUndefinedf(childHeight)) { - if (!YGValueIsUndefinedf(child->style.aspectRatio)) { - if (YGValueIsUndefinedf(childWidth)) { + if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) { + if (!YGFloatIsUndefined(child->style.aspectRatio)) { + if (YGFloatIsUndefined(childWidth)) { childWidth = fmaxf(childHeight * child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width)); - } else if (YGValueIsUndefinedf(childHeight)) { + } else if (YGFloatIsUndefined(childHeight)) { childHeight = fmaxf(childWidth * child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width)); } @@ -1312,17 +1310,17 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, } // If we're still missing one or the other dimension, measure the content. - if (YGValueIsUndefinedf(childWidth) || YGValueIsUndefinedf(childHeight)) { + if (YGFloatIsUndefined(childWidth) || YGFloatIsUndefined(childHeight)) { childWidthMeasureMode = - YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; // According to the spec, if the main size is not definite and the // child's inline axis is parallel to the main axis (i.e. it's // horizontal), the child should be sized using "UNDEFINED" in // the main size. Otherwise use "AT_MOST" in the cross axis. - if (!isMainAxisRow && YGValueIsUndefinedf(childWidth) && widthMode != YGMeasureModeUndefined) { + if (!isMainAxisRow && YGFloatIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } @@ -1355,7 +1353,6 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, "abs-layout"); if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) { - const float mainAxisSize = isMainAxisRow ? width : height; child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - child->layout.measuredDimensions[dim[mainAxis]] - YGNodeTrailingBorder(node, mainAxis) - @@ -1363,7 +1360,6 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, } if (YGNodeIsTrailingPosDefined(child, crossAxis) && !YGNodeIsLeadingPosDefined(child, crossAxis)) { - const float crossAxisSize = isMainAxisRow ? height : width; child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - YGNodeTrailingBorder(node, crossAxis) - @@ -1469,14 +1465,14 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(node, YGFlexDirectionRow, - YGValueIsUndefinedf(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) + YGFloatIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) ? 0 : availableWidth - marginAxisRow, parentWidth, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, - YGValueIsUndefinedf(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) + YGFloatIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) ? 0 : availableHeight - marginAxisColumn, parentHeight, parentWidth); @@ -1607,10 +1603,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float parentWidth, const float parentHeight, const bool performLayout) { - YG_ASSERT(YGValueIsUndefinedf(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, + YG_ASSERT(YGFloatIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, "availableWidth is indefinite so widthMeasureMode must be " "YGMeasureModeUndefined"); - YG_ASSERT(YGValueIsUndefinedf(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined + YG_ASSERT(YGFloatIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined : true, "availableHeight is indefinite so heightMeasureMode must be " "YGMeasureModeUndefined"); @@ -1668,11 +1664,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS - const float possibleNodeWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - const float possibleNodeHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - const float possibleNodeMainDim = isMainAxisRow ? possibleNodeWidth : possibleNodeHeight; - const float possibleNodeCrossDim = isMainAxisRow ? possibleNodeHeight : possibleNodeWidth; - const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; @@ -1705,7 +1696,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (performLayout) { // Set the initial position (relative to the parent). const YGDirection childDirection = YGNodeResolveDirection(child, direction); - YGNodeSetPosition(child, childDirection, possibleNodeMainDim, possibleNodeCrossDim, possibleNodeWidth); + YGNodeSetPosition(child, childDirection, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth); } // Absolute-positioned children don't participate in flex layout. Add them @@ -1731,8 +1722,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth, widthMeasureMode, availableInnerHeight, - possibleNodeWidth, - possibleNodeHeight, + availableInnerWidth, + availableInnerHeight, heightMeasureMode, direction); } @@ -1781,7 +1772,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = - child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, possibleNodeWidth); + child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, availableInnerWidth); // If this is a multi-line flow and this item pushes us over the // available size, we've @@ -1832,7 +1823,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If the main dimension size isn't known, it is computed based on // the line length, so there's no more space left to distribute. float remainingFreeSpace = 0; - if (!YGValueIsUndefinedf(availableInnerMainDim)) { + if (!YGFloatIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; } else if (sizeConsumedOnCurrentLine < 0) { // availableInnerMainDim is indefinite which means the node is being sized @@ -1892,7 +1883,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim, possibleNodeWidth); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, availableInnerMainDim, availableInnerWidth); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1911,7 +1902,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (flexGrowFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, possibleNodeMainDim, possibleNodeWidth); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize, availableInnerMainDim, availableInnerWidth); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1953,7 +1944,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, (remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor; } - updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, possibleNodeMainDim, possibleNodeWidth); + updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize, availableInnerMainDim, availableInnerWidth); } } else if (remainingFreeSpace > 0) { flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); @@ -1964,7 +1955,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeBoundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, possibleNodeMainDim, possibleNodeWidth); + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor, availableInnerMainDim, availableInnerWidth); } } @@ -1977,10 +1968,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childWidth = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth); childWidthMeasureMode = YGMeasureModeExactly; - if (!YGValueIsUndefinedf(availableInnerCrossDim) && + if (!YGFloatIsUndefined(availableInnerCrossDim) && !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn) && heightMeasureMode == YGMeasureModeExactly && YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { @@ -1989,18 +1980,18 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn)) { childHeight = availableInnerCrossDim; childHeightMeasureMode = - YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], possibleNodeHeight) + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth); + childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], availableInnerHeight) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth); childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth); childHeightMeasureMode = YGMeasureModeExactly; - if (!YGValueIsUndefinedf(availableInnerCrossDim) && + if (!YGFloatIsUndefined(availableInnerCrossDim) && !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow) && widthMeasureMode == YGMeasureModeExactly && YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { @@ -2009,32 +2000,32 @@ static void YGNodelayoutImpl(const YGNodeRef node, } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow)) { childWidth = availableInnerCrossDim; childWidthMeasureMode = - YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], possibleNodeWidth) + - YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth); + childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], availableInnerWidth) + + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth); childWidthMeasureMode = YGMeasureModeExactly; } } - if (!YGValueIsUndefinedf(currentRelativeChild->style.aspectRatio)) { + if (!YGFloatIsUndefined(currentRelativeChild->style.aspectRatio)) { if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, possibleNodeWidth)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, - YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow, possibleNodeWidth)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth)); childWidthMeasureMode = YGMeasureModeExactly; } } - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], possibleNodeWidth), + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], possibleNodeHeight), + YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2050,8 +2041,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, - possibleNodeWidth, - possibleNodeHeight, + availableInnerWidth, + availableInnerHeight, performLayout && !requiresStretchLayout, "flex"); @@ -2120,9 +2111,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said // (and margin/border). - child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, possibleNodeMainDim) + + child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis, availableInnerMainDim) + YGNodeLeadingBorder(node, mainAxis) + - YGNodeLeadingMargin(child, mainAxis, possibleNodeWidth); + YGNodeLeadingMargin(child, mainAxis, availableInnerWidth); } } else { // Now that we placed the element, we need to update the variables. @@ -2137,18 +2128,18 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If we skipped the flex step, then we can't rely on the // measuredDims because // they weren't computed. This means we can't call YGNodeDimWithMargin. - mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, possibleNodeWidth) + + mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, availableInnerWidth) + child->layout.computedFlexBasis; crossDim = availableInnerCrossDim; } else { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, possibleNodeWidth); + mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, availableInnerWidth); // The cross dimension is the max of the elements dimension since // there // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, possibleNodeWidth)); + crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, availableInnerWidth)); } } else if (performLayout) { child->layout.position[pos[mainAxis]] += @@ -2192,12 +2183,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, // set, override all the previously computed positions to set it // correctly. if (YGNodeIsLeadingPosDefined(child, crossAxis)) { - child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, possibleNodeCrossDim) + + child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis, availableInnerCrossDim) + YGNodeLeadingBorder(node, crossAxis) + - YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth); } else { child->layout.position[pos[crossAxis]] = - YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); + YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2224,17 +2215,17 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (isMainAxisRow) { childHeight = crossDim; childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - YGNodeMarginForAxis(child, YGFlexDirectionRow, possibleNodeWidth); + YGNodeMarginForAxis(child, YGFlexDirectionRow, availableInnerWidth); } else { childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - YGNodeMarginForAxis(child, YGFlexDirectionColumn, possibleNodeWidth); + YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth); } - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], possibleNodeWidth), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], possibleNodeHeight), + YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2242,9 +2233,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, // no need to stretch. if (!isCrossSizeDefinite) { childWidthMeasureMode = - YGValueIsUndefinedf(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - YGValueIsUndefinedf(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; YGLayoutNodeInternal(child, childWidth, @@ -2252,14 +2243,14 @@ static void YGNodelayoutImpl(const YGNodeRef node, direction, childWidthMeasureMode, childHeightMeasureMode, - possibleNodeWidth, - possibleNodeHeight, + availableInnerWidth, + availableInnerHeight, true, "stretch"); } } else if (alignItem != YGAlignFlexStart) { const float remainingCrossDim = - containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, possibleNodeWidth); + containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, availableInnerWidth); if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; @@ -2279,7 +2270,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } // STEP 8: MULTI-LINE CONTENT ALIGNMENT - if (lineCount > 1 && performLayout && !YGValueIsUndefinedf(availableInnerCrossDim)) { + if (lineCount > 1 && performLayout && !YGFloatIsUndefined(availableInnerCrossDim)) { const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim; float crossDimLead = 0; @@ -2321,7 +2312,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (YGNodeIsLayoutDimDefined(child, crossAxis)) { lineHeight = fmaxf(lineHeight, child->layout.measuredDimensions[dim[crossAxis]] + - YGNodeMarginForAxis(child, crossAxis, possibleNodeWidth)); + YGNodeMarginForAxis(child, crossAxis, availableInnerWidth)); } } } @@ -2336,12 +2327,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, switch (YGNodeAlignItem(node, child)) { case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); + currentLead + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth); break; } case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = - currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, possibleNodeWidth) - + currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis, availableInnerWidth) - child->layout.measuredDimensions[dim[crossAxis]]; break; } @@ -2353,7 +2344,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, } case YGAlignStretch: { child->layout.position[pos[crossAxis]] = - currentLead + YGNodeLeadingMargin(child, crossAxis, possibleNodeWidth); + currentLead + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; @@ -2769,7 +2760,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; YGMeasureMode heightMeasureMode = YGMeasureModeUndefined; - if (!YGValueIsUndefinedf(width)) { + if (!YGFloatIsUndefined(width)) { widthMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow)) { width = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + @@ -2780,7 +2771,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, widthMeasureMode = YGMeasureModeAtMost; } - if (!YGValueIsUndefinedf(height)) { + if (!YGFloatIsUndefined(height)) { heightMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { height = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 6272b7f8..c30d14a7 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -92,7 +92,7 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); -WIN_EXPORT bool YGValueIsUndefinedf(const float value); +WIN_EXPORT bool YGFloatIsUndefined(const float value); WIN_EXPORT bool YGValueIsUndefined(const YGValue value); WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, -- 2.50.1.windows.1 From e258d9867dd47848de4b91fadc99d1edecfe1f33 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 16 Dec 2016 11:42:36 +0100 Subject: [PATCH 12/39] use correct undefined function --- tests/YGMeasureModeTest.cpp | 4 ++-- tests/YGStyleTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index 730247fa..cd5aedba 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -283,7 +283,7 @@ TEST(YogaTest, overflow_scroll_column) { ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); - ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].height)); + ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].height)); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode); free(constraintList.constraints); @@ -312,7 +312,7 @@ TEST(YogaTest, overflow_scroll_row) { ASSERT_EQ(1, constraintList.length); - ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].width)); + ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].width)); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index 4eb7fd60..65747337 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -26,7 +26,7 @@ TEST(YogaTest, copy_style_modified) { const YGNodeRef node0 = YGNodeNew(); ASSERT_FALSE(YGNodeIsDirty(node0)); ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); - ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(node0))); + ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxHeight(node0))); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); -- 2.50.1.windows.1 From a7003b6821c357157d1af394061ccd5b768c3507 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:15:48 +0100 Subject: [PATCH 13/39] code review changes --- gentest/gentest-cpp.js | 22 +-- tests/YGAbsolutePositionTest.cpp | 100 +++++----- tests/YGAlignContentTest.cpp | 86 ++++----- tests/YGAlignItemsTest.cpp | 30 +-- tests/YGAlignSelfTest.cpp | 32 ++-- tests/YGBorderTest.cpp | 24 +-- tests/YGDirtyMarkingTest.cpp | 36 ++-- tests/YGEdgeTest.cpp | 66 +++---- tests/YGFlexDirectionTest.cpp | 56 +++--- tests/YGFlexTest.cpp | 58 +++--- tests/YGFlexWrapTest.cpp | 72 ++++---- tests/YGJustifyContentTest.cpp | 98 +++++----- tests/YGLayoutDefaultValuesTest.cpp | 50 ++--- tests/YGMarginTest.cpp | 64 +++---- tests/YGMinMaxDimensionTest.cpp | 80 ++++---- tests/YGPaddingTest.cpp | 78 ++++---- tests/YGPercentageTest.cpp | 236 ++++++++++++------------ tests/YGRelayoutTest.cpp | 4 +- tests/YGRoundingTest.cpp | 118 ++++++------ yoga/Yoga.c | 273 +++++++++++----------------- yoga/Yoga.h | 14 +- 21 files changed, 768 insertions(+), 829 deletions(-) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 7ab7e7de..b66eb10a 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -12,7 +12,7 @@ function toValueCpp(value) { return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); } -function toValueCppWithUnitCpp(value) { +function toValueCppCpp(value) { var methodName = ''; if(value.indexOf('px') >= 0){ methodName = 'YGPx'; @@ -164,7 +164,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexBasisWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -184,7 +184,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -192,23 +192,23 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetMarginWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinHeightWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -216,11 +216,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPaddingWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPositionWithUnit(' + nodeName + ', ' + edge + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -228,6 +228,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetWidthWithUnit(' + nodeName + ', ' + toValueCppWithUnitCpp(value) + ');'); + this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); }}, }); diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index 25b842c5..9187c37b 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -14,15 +14,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -53,15 +53,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { TEST(YogaTest, absolute_layout_width_height_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -92,15 +92,15 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) { TEST(YogaTest, absolute_layout_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -131,17 +131,17 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) { TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -174,18 +174,18 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowHidden); - YGNodeStyleSetWidthWithUnit(root, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root, YGPx(50)); + YGNodeStyleSetWidth(root, YGPx(50)); + YGNodeStyleSetHeight(root, YGPx(50)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeStart, YGPx(0)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(100)); + YGNodeStyleSetWidth(root_child0_child0, YGPx(100)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(100)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -226,35 +226,35 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi TEST(YogaTest, absolute_layout_within_border) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetMarginWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetMarginWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetMarginWithUnit(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPx(0)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPx(0)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child1, YGEdgeRight, YGPx(0)); - YGNodeStyleSetPositionWithUnit(root_child1, YGEdgeBottom, YGPx(0)); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetPosition(root_child1, YGEdgeRight, YGPx(0)); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, YGPx(0)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index e836d098..d5e09f93 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -15,32 +15,32 @@ TEST(YogaTest, align_content_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, YGPx(50)); + YGNodeStyleSetHeight(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, YGPx(50)); + YGNodeStyleSetHeight(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -113,32 +113,32 @@ TEST(YogaTest, align_content_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, YGPx(50)); + YGNodeStyleSetHeight(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, YGPx(50)); + YGNodeStyleSetHeight(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -211,32 +211,32 @@ TEST(YogaTest, align_content_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, YGPx(50)); + YGNodeStyleSetHeight(root_child3, YGPx(10)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, YGPx(50)); + YGNodeStyleSetHeight(root_child4, YGPx(10)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,27 +309,27 @@ TEST(YogaTest, align_content_stretch) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(50)); + YGNodeStyleSetWidth(root_child3, YGPx(50)); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child4, YGPx(50)); + YGNodeStyleSetWidth(root_child4, YGPx(50)); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index a1a3bcb6..90a7cee6 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -14,11 +14,11 @@ TEST(YogaTest, align_items_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -50,12 +50,12 @@ TEST(YogaTest, align_items_stretch) { TEST(YogaTest, align_items_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, align_items_center) { TEST(YogaTest, align_items_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -124,12 +124,12 @@ TEST(YogaTest, align_items_flex_start) { TEST(YogaTest, align_items_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index 88894aba..6293c725 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -14,13 +14,13 @@ TEST(YogaTest, align_self_center) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,13 +51,13 @@ TEST(YogaTest, align_self_center) { TEST(YogaTest, align_self_flex_end) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -88,13 +88,13 @@ TEST(YogaTest, align_self_flex_end) { TEST(YogaTest, align_self_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,13 +126,13 @@ TEST(YogaTest, align_self_flex_start) { TEST(YogaTest, align_self_flex_end_override_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 306f1c37..3b8743e1 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -43,8 +43,8 @@ TEST(YogaTest, border_container_match_child) { YGNodeStyleSetBorder(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -79,12 +79,12 @@ TEST(YogaTest, border_flex_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -119,11 +119,11 @@ TEST(YogaTest, border_stretch_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -159,12 +159,12 @@ TEST(YogaTest, border_center_child) { YGNodeStyleSetBorder(root, YGEdgeStart, 10); YGNodeStyleSetBorder(root, YGEdgeEnd, 20); YGNodeStyleSetBorder(root, YGEdgeBottom, 20); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp index 3888966e..e5035835 100644 --- a/tests/YGDirtyMarkingTest.cpp +++ b/tests/YGDirtyMarkingTest.cpp @@ -13,22 +13,22 @@ TEST(YogaTest, dirty_propagation) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetWidth(root_child0, YGPx(20)); EXPECT_TRUE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -46,22 +46,22 @@ TEST(YogaTest, dirty_propagation) { TEST(YogaTest, dirty_propagation_only_if_prop_changed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); - YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetWidth(root_child0, YGPx(50)); EXPECT_FALSE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -73,12 +73,12 @@ TEST(YogaTest, dirty_propagation_only_if_prop_changed) { TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 50); - YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetWidth(root, YGPx(50)); + YGNodeStyleSetHeight(root, YGPx(50)); const YGNodeRef child0 = YGNodeNew(); - YGNodeStyleSetWidth(child0, 50); - YGNodeStyleSetHeight(child0, 25); + YGNodeStyleSetWidth(child0, YGPx(50)); + YGNodeStyleSetHeight(child0, YGPx(25)); YGNodeInsertChild(root, child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index 4122b11b..df6a0a55 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -13,14 +13,14 @@ TEST(YogaTest, start_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -37,14 +37,14 @@ TEST(YogaTest, start_overrides) { TEST(YogaTest, end_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -61,13 +61,13 @@ TEST(YogaTest, end_overrides) { TEST(YogaTest, horizontal_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,13 +80,13 @@ TEST(YogaTest, horizontal_overridden) { TEST(YogaTest, vertical_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -99,13 +99,13 @@ TEST(YogaTest, vertical_overridden) { TEST(YogaTest, horizontal_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -120,13 +120,13 @@ TEST(YogaTest, horizontal_overrides_all) { TEST(YogaTest, vertical_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -141,16 +141,16 @@ TEST(YogaTest, vertical_overrides_all) { TEST(YogaTest, all_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index 47168b99..30cb2a4b 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -14,18 +14,18 @@ TEST(YogaTest, flex_direction_column_no_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -77,18 +77,18 @@ TEST(YogaTest, flex_direction_column_no_height) { TEST(YogaTest, flex_direction_row_no_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -139,19 +139,19 @@ TEST(YogaTest, flex_direction_row_no_width) { TEST(YogaTest, flex_direction_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -203,19 +203,19 @@ TEST(YogaTest, flex_direction_column) { TEST(YogaTest, flex_direction_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -267,19 +267,19 @@ TEST(YogaTest, flex_direction_row) { TEST(YogaTest, flex_direction_column_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,19 +331,19 @@ TEST(YogaTest, flex_direction_column_reverse) { TEST(YogaTest, flex_direction_row_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index 60641472..69cf569a 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -65,12 +65,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { TEST(YogaTest, flex_basis_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -115,16 +115,16 @@ TEST(YogaTest, flex_basis_flex_grow_row) { TEST(YogaTest, flex_basis_flex_shrink_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -166,16 +166,16 @@ TEST(YogaTest, flex_basis_flex_shrink_column) { TEST(YogaTest, flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -216,22 +216,22 @@ TEST(YogaTest, flex_basis_flex_shrink_row) { TEST(YogaTest, flex_shrink_to_zero) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root, YGPx(75)); + YGNodeStyleSetHeight(root, YGPx(75)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child1, 1); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetHeight(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -282,23 +282,23 @@ TEST(YogaTest, flex_shrink_to_zero) { TEST(YogaTest, flex_basis_overrides_main_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -349,8 +349,8 @@ TEST(YogaTest, flex_basis_overrides_main_size) { TEST(YogaTest, flex_grow_shrink_at_most) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeInsertChild(root, root_child0, 0); diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index 093fd2d7..32e86a6e 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -15,26 +15,26 @@ TEST(YogaTest, wrap_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, YGPx(30)); + YGNodeStyleSetHeight(root_child0, YGPx(30)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, YGPx(30)); + YGNodeStyleSetHeight(root_child1, YGPx(30)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, YGPx(30)); + YGNodeStyleSetHeight(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, YGPx(30)); + YGNodeStyleSetHeight(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -97,26 +97,26 @@ TEST(YogaTest, wrap_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, YGPx(30)); + YGNodeStyleSetHeight(root_child0, YGPx(30)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, YGPx(30)); + YGNodeStyleSetHeight(root_child1, YGPx(30)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, YGPx(30)); + YGNodeStyleSetHeight(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, YGPx(30)); + YGNodeStyleSetHeight(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -180,26 +180,26 @@ TEST(YogaTest, wrap_row_align_items_flex_end) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(30)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, YGPx(30)); + YGNodeStyleSetHeight(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, YGPx(30)); + YGNodeStyleSetHeight(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, YGPx(30)); + YGNodeStyleSetHeight(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -263,26 +263,26 @@ TEST(YogaTest, wrap_row_align_items_center) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(30)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, YGPx(30)); + YGNodeStyleSetHeight(root_child1, YGPx(20)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, YGPx(30)); + YGNodeStyleSetHeight(root_child2, YGPx(30)); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child3, YGPx(30)); - YGNodeStyleSetHeightWithUnit(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, YGPx(30)); + YGNodeStyleSetHeight(root_child3, YGPx(30)); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index 2307d199..260d3914 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -15,19 +15,19 @@ TEST(YogaTest, justify_content_row_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,19 +80,19 @@ TEST(YogaTest, justify_content_row_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -145,19 +145,19 @@ TEST(YogaTest, justify_content_row_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -210,19 +210,19 @@ TEST(YogaTest, justify_content_row_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -275,19 +275,19 @@ TEST(YogaTest, justify_content_row_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -338,18 +338,18 @@ TEST(YogaTest, justify_content_row_space_around) { TEST(YogaTest, justify_content_column_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -401,19 +401,19 @@ TEST(YogaTest, justify_content_column_flex_start) { TEST(YogaTest, justify_content_column_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -465,19 +465,19 @@ TEST(YogaTest, justify_content_column_flex_end) { TEST(YogaTest, justify_content_column_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -529,19 +529,19 @@ TEST(YogaTest, justify_content_column_center) { TEST(YogaTest, justify_content_column_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -593,19 +593,19 @@ TEST(YogaTest, justify_content_column_space_between) { TEST(YogaTest, justify_content_column_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidthWithUnit(root, YGPx(102)); - YGNodeStyleSetHeightWithUnit(root, YGPx(102)); + YGNodeStyleSetWidth(root, YGPx(102)); + YGNodeStyleSetHeight(root, YGPx(102)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index 97d10b7a..67906ac4 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -27,28 +27,28 @@ TEST(YogaTest, assert_default_values) { ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetFlexBasis(root))); + ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).defined); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd))); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).defined); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom)); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd))); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom).value); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).defined); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).defined); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight)); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom)); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd))); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight).value); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom).value); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).defined); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).defined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); @@ -57,12 +57,12 @@ TEST(YogaTest, assert_default_values) { ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetWidth(root))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetHeight(root))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMinWidth(root))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMinHeight(root))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxWidth(root))); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxHeight(root))); + ASSERT_FALSE(YGNodeStyleGetWidth(root).defined); + ASSERT_FALSE(YGNodeStyleGetHeight(root).defined); + ASSERT_FALSE(YGNodeStyleGetMinWidth(root).defined); + ASSERT_FALSE(YGNodeStyleGetMinHeight(root).defined); + ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).defined); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).defined); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index fb293065..17de3e78 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -15,12 +15,12 @@ TEST(YogaTest, margin_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, margin_start) { TEST(YogaTest, margin_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -89,12 +89,12 @@ TEST(YogaTest, margin_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,12 +126,12 @@ TEST(YogaTest, margin_end) { TEST(YogaTest, margin_bottom) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -163,12 +163,12 @@ TEST(YogaTest, margin_bottom) { TEST(YogaTest, margin_and_flex_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,12 +199,12 @@ TEST(YogaTest, margin_and_flex_row) { TEST(YogaTest, margin_and_flex_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -236,12 +236,12 @@ TEST(YogaTest, margin_and_flex_column) { TEST(YogaTest, margin_and_stretch_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -272,12 +272,12 @@ TEST(YogaTest, margin_and_stretch_row) { TEST(YogaTest, margin_and_stretch_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,8 +309,8 @@ TEST(YogaTest, margin_and_stretch_column) { TEST(YogaTest, margin_with_sibling_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -358,8 +358,8 @@ TEST(YogaTest, margin_with_sibling_row) { TEST(YogaTest, margin_with_sibling_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index ee6eff52..739f1b7b 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetMaxWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, max_width) { TEST(YogaTest, max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetMaxHeight(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, max_height) { TEST(YogaTest, min_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeightWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetMinHeight(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -138,12 +138,12 @@ TEST(YogaTest, min_height) { TEST(YogaTest, min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinWidthWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetMinWidth(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -189,13 +189,13 @@ TEST(YogaTest, min_width) { TEST(YogaTest, justify_content_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetMinHeightWithUnit(root, YGPx(100)); - YGNodeStyleSetMaxHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetMinHeight(root, YGPx(100)); + YGNodeStyleSetMaxHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(60)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, YGPx(60)); + YGNodeStyleSetHeight(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -227,13 +227,13 @@ TEST(YogaTest, justify_content_min_max) { TEST(YogaTest, align_items_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetMinWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetMaxWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetMinWidth(root, YGPx(100)); + YGNodeStyleSetMaxWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(60)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, YGPx(60)); + YGNodeStyleSetHeight(root_child0, YGPx(60)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -265,22 +265,22 @@ TEST(YogaTest, align_items_min_max) { TEST(YogaTest, justify_content_overflow_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetMinHeightWithUnit(root, YGPx(100)); - YGNodeStyleSetMaxHeightWithUnit(root, YGPx(110)); + YGNodeStyleSetMinHeight(root, YGPx(100)); + YGNodeStyleSetMaxHeight(root, YGPx(110)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child1, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child2, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetHeight(root_child2, YGPx(50)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,17 +331,17 @@ TEST(YogaTest, justify_content_overflow_min_max) { TEST(YogaTest, flex_grow_within_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -382,17 +382,17 @@ TEST(YogaTest, flex_grow_within_max_width) { TEST(YogaTest, flex_grow_within_constrained_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPx(300)); + YGNodeStyleSetMaxWidth(root_child0, YGPx(300)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index 86b58175..9fe33ac0 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, padding_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,14 +37,14 @@ TEST(YogaTest, padding_no_size) { TEST(YogaTest, padding_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -75,16 +75,16 @@ TEST(YogaTest, padding_container_match_child) { TEST(YogaTest, padding_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -115,15 +115,15 @@ TEST(YogaTest, padding_flex_child) { TEST(YogaTest, padding_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -156,15 +156,15 @@ TEST(YogaTest, padding_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeEnd, YGPx(20)); - YGNodeStyleSetPaddingWithUnit(root, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeStart, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeEnd, YGPx(20)); + YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -197,16 +197,16 @@ TEST(YogaTest, child_with_padding_align_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPx(20)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPx(20)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(20)); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(20)); + YGNodeStyleSetWidth(root_child0, YGPx(100)); + YGNodeStyleSetHeight(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp index a9ecdfaa..9d16db6f 100644 --- a/tests/YGPercentageTest.cpp +++ b/tests/YGPercentageTest.cpp @@ -17,12 +17,12 @@ TEST(YogaTest, percentage_width_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(30)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(30)); + YGNodeStyleSetWidth(root_child0, YGPercent(30)); + YGNodeStyleSetHeight(root_child0, YGPercent(30)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -58,14 +58,14 @@ TEST(YogaTest, percentage_position_left_top) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(400)); - YGNodeStyleSetHeightWithUnit(root, YGPx(400)); + YGNodeStyleSetWidth(root, YGPx(400)); + YGNodeStyleSetHeight(root, YGPx(400)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(20)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(45)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(55)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(20)); + YGNodeStyleSetWidth(root_child0, YGPercent(45)); + YGNodeStyleSetHeight(root_child0, YGPercent(55)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -101,14 +101,14 @@ TEST(YogaTest, percentage_position_bottom_right) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(500)); - YGNodeStyleSetHeightWithUnit(root, YGPx(500)); + YGNodeStyleSetWidth(root, YGPx(500)); + YGNodeStyleSetHeight(root, YGPx(500)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeRight, YGPercent(20)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPercent(55)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPercent(15)); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, YGPercent(20)); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetWidth(root_child0, YGPercent(55)); + YGNodeStyleSetHeight(root_child0, YGPercent(15)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -144,17 +144,17 @@ TEST(YogaTest, percentage_flex_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,17 +199,17 @@ TEST(YogaTest, percentage_flex_basis_cross) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -254,17 +254,17 @@ TEST(YogaTest, percentage_flex_basis_cross_min_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeightWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetMinHeight(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 2); - YGNodeStyleSetMinHeightWithUnit(root_child1, YGPercent(10)); + YGNodeStyleSetMinHeight(root_child1, YGPercent(10)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -310,19 +310,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); + YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); + YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -367,19 +367,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeightWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); + YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeightWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); + YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -425,19 +425,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15)); - YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); + YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); - YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); + YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -482,19 +482,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); - YGNodeStyleSetMaxWidthWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); + YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); - YGNodeStyleSetMaxWidthWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); + YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -540,19 +540,19 @@ TEST(YogaTest, percentage_flex_basis_main_min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(15)); - YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); + YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(10)); - YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); + YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -597,19 +597,19 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); - YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); + YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); + YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -654,51 +654,51 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(200)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPercent(10)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetMinWidthWithUnit(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(5)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(5)); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(5)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(5)); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(3)); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(3)); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(3)); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(3)); + YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeLeft, YGPercent(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeTop, YGPercent(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeRight, YGPercent(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0, YGEdgeBottom, YGPercent(3)); - YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPercent(50)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, YGPx(5)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, YGPx(5)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, YGPx(5)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, YGPx(5)); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, YGPercent(3)); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, YGPercent(3)); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, YGPercent(3)); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, YGPercent(3)); + YGNodeStyleSetWidth(root_child0_child0, YGPercent(50)); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child0_child0 = YGNodeNew(); - YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPercent(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeTop, YGPercent(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeRight, YGPercent(5)); - YGNodeStyleSetMarginWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPercent(5)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPaddingWithUnit(root_child0_child0_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetWidthWithUnit(root_child0_child0_child0, YGPercent(45)); + YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeLeft, YGPercent(5)); + YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeTop, YGPercent(5)); + YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeRight, YGPercent(5)); + YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeBottom, YGPercent(5)); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, YGPx(3)); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, YGPx(3)); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, YGPx(3)); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, YGPx(3)); + YGNodeStyleSetWidth(root_child0_child0_child0, YGPercent(45)); YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidthWithUnit(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); + YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -763,20 +763,20 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPercent(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPercent(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -821,20 +821,20 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPercent(10)); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPercent(10)); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPercent(10)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -879,15 +879,15 @@ TEST(YogaTest, percentage_absolute_position) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(200)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(30)); - YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(30)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(10)); + YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, YGPx(10)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRelayoutTest.cpp b/tests/YGRelayoutTest.cpp index de298325..b637d17c 100644 --- a/tests/YGRelayoutTest.cpp +++ b/tests/YGRelayoutTest.cpp @@ -16,8 +16,8 @@ TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { const YGNodeRef root = YGNodeNew(); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 10); - YGNodeStyleSetFlexBasis(root_child0, 20); + YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index fe2a39be..aaad141c 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -17,8 +17,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -85,8 +85,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(113)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(113)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -181,20 +181,20 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidthWithUnit(root, YGPx(101)); - YGNodeStyleSetHeightWithUnit(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(101)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasisWithUnit(root_child1, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child1, YGPx(25)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetFlexBasisWithUnit(root_child2, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child2, YGPx(25)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -249,23 +249,23 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(113)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -320,23 +320,23 @@ TEST(YogaTest, rounding_total_fractial) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(87.4f)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, YGPx(87.4f)); + YGNodeStyleSetHeight(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); + YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -391,37 +391,37 @@ TEST(YogaTest, rounding_total_fractial_nested) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(87.4f)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, YGPx(87.4f)); + YGNodeStyleSetHeight(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); + YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0_child0, YGPx(0.3f)); - YGNodeStyleSetPositionWithUnit(root_child0_child0, YGEdgeBottom, YGPx(13.3f)); - YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(9.9f)); + YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(0.3f)); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, YGPx(13.3f)); + YGNodeStyleSetHeight(root_child0_child0, YGPx(9.9f)); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child1, 4); - YGNodeStyleSetFlexBasisWithUnit(root_child0_child1, YGPx(0.3f)); - YGNodeStyleSetPositionWithUnit(root_child0_child1, YGEdgeTop, YGPx(13.3f)); - YGNodeStyleSetHeightWithUnit(root_child0_child1, YGPx(1.1f)); + YGNodeStyleSetFlexBasis(root_child0_child1, YGPx(0.3f)); + YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, YGPx(13.3f)); + YGNodeStyleSetHeight(root_child0_child1, YGPx(1.1f)); YGNodeInsertChild(root_child0, root_child0_child1, 1); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -496,23 +496,23 @@ TEST(YogaTest, rounding_fractial_input_1) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -567,23 +567,23 @@ TEST(YogaTest, rounding_fractial_input_2) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.6f)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(113.6f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -638,24 +638,24 @@ TEST(YogaTest, rounding_fractial_input_3) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPositionWithUnit(root, YGEdgeTop, YGPx(0.3f)); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.3f)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -710,24 +710,24 @@ TEST(YogaTest, rounding_fractial_input_4) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPositionWithUnit(root, YGEdgeTop, YGPx(0.7f)); - YGNodeStyleSetWidthWithUnit(root, YGPx(100)); - YGNodeStyleSetHeightWithUnit(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.7f)); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(113.4f)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasisWithUnit(root_child0, YGPx(50)); - YGNodeStyleSetHeightWithUnit(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, YGPx(20)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeightWithUnit(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, YGPx(10)); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeightWithUnit(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, YGPx(10)); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 6bdd6423..c4bed869 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -113,6 +113,12 @@ YGCalloc gYGCalloc = &calloc; YGRealloc gYGRealloc = &realloc; YGFree gYGFree = &free; +static YGValue YGValueUndefined = { + .value = YGUndefined, + .defined = false, + .unit = YGUnitPixel +}; + #ifdef ANDROID #include static int YGAndroidLog(YGLogLevel level, const char *format, va_list args) { @@ -161,39 +167,35 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const float defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (!YGValueIsUndefined(edges[edge])) { + if (edges[edge].defined) { return edges[edge]; } - if ((edge == YGEdgeTop || edge == YGEdgeBottom) && !YGValueIsUndefined(edges[YGEdgeVertical])) { + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].defined) { return edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && - !YGValueIsUndefined(edges[YGEdgeHorizontal])) { + edges[YGEdgeHorizontal].defined) { return edges[YGEdgeHorizontal]; } - if (!YGValueIsUndefined(edges[YGEdgeAll])) { + if (edges[YGEdgeAll].defined) { return edges[YGEdgeAll]; } if (edge == YGEdgeStart || edge == YGEdgeEnd) { - YGValue result; - result.value = YGUndefined; - result.defined = false; - result.unit = YGUnitPixel; - return result; + return YGValueUndefined; } - YGValue result; - result.value = defaultValue; - result.defined = (defaultValue < 0 || defaultValue >= 0); /* is faster than a nan function call and enough at this point */ - result.unit = YGUnitPixel; - return result; + YGValue result; + result.value = defaultValue; + result.defined = (defaultValue < 0 || defaultValue >= 0); /* is faster than a nan function call and enough at this point */ + result.unit = YGUnitPixel; + return result; } -static inline float YGValueToFloat(const YGValue unit, const float parentSize) { +static inline float YGValueResolve(const YGValue unit, const float parentSize) { if (unit.unit == YGUnitPixel){ return unit.value; } else { @@ -223,40 +225,20 @@ static void YGNodeInit(const YGNodeRef node) { node->style.overflow = YGOverflowVisible; // Some of the fields default to undefined and not 0 - node->style.dimensions[YGDimensionWidth].value = YGUndefined; - node->style.dimensions[YGDimensionWidth].defined = false; - node->style.dimensions[YGDimensionWidth].unit = YGUnitPixel; - node->style.dimensions[YGDimensionHeight].value = YGUndefined; - node->style.dimensions[YGDimensionHeight].defined = false; - node->style.dimensions[YGDimensionHeight].unit = YGUnitPixel; + node->style.dimensions[YGDimensionWidth] = YGValueUndefined; + node->style.dimensions[YGDimensionHeight] = YGValueUndefined; - node->style.minDimensions[YGDimensionWidth].value = YGUndefined; - node->style.minDimensions[YGDimensionWidth].defined = false; - node->style.minDimensions[YGDimensionWidth].unit = YGUnitPixel; - node->style.minDimensions[YGDimensionHeight].value = YGUndefined; - node->style.minDimensions[YGDimensionHeight].defined = false; - node->style.minDimensions[YGDimensionHeight].unit = YGUnitPixel; + node->style.minDimensions[YGDimensionWidth] = YGValueUndefined; + node->style.minDimensions[YGDimensionHeight] = YGValueUndefined; - node->style.maxDimensions[YGDimensionWidth].value = YGUndefined; - node->style.maxDimensions[YGDimensionWidth].defined = false; - node->style.maxDimensions[YGDimensionWidth].unit = YGUnitPixel; - node->style.maxDimensions[YGDimensionHeight].value = YGUndefined; - node->style.maxDimensions[YGDimensionHeight].defined = false; - node->style.maxDimensions[YGDimensionHeight].unit = YGUnitPixel; + node->style.maxDimensions[YGDimensionWidth] = YGValueUndefined; + node->style.maxDimensions[YGDimensionHeight] = YGValueUndefined; for (YGEdge edge = YGEdgeLeft; edge < YGEdgeCount; edge++) { - node->style.position[edge].value = YGUndefined; - node->style.position[edge].defined = false; - node->style.position[edge].unit = YGUnitPixel; - node->style.margin[edge].value = YGUndefined; - node->style.margin[edge].defined = false; - node->style.margin[edge].unit = YGUnitPixel; - node->style.padding[edge].value = YGUndefined; - node->style.padding[edge].defined = false; - node->style.padding[edge].unit = YGUnitPixel; - node->style.border[edge].value = YGUndefined; - node->style.border[edge].defined = false; - node->style.border[edge].unit = YGUnitPixel; + node->style.position[edge] = YGValueUndefined; + node->style.margin[edge] = YGValueUndefined; + node->style.padding[edge] = YGValueUndefined; + node->style.border[edge] = YGValueUndefined; } node->style.aspectRatio = YGUndefined; @@ -280,19 +262,19 @@ static void YGNodeInit(const YGNodeRef node) { int32_t gNodeInstanceCount = 0; YGValue YGPx(const float value){ - YGValue result; - result.value = value; - result.defined = !YGFloatIsUndefined(value); - result.unit = YGUnitPixel; - return result; + YGValue result; + result.value = value; + result.defined = !YGFloatIsUndefined(value); + result.unit = YGUnitPixel; + return result; } YGValue YGPercent(const float value){ - YGValue result; - result.value = value; - result.defined = !YGFloatIsUndefined(value); - result.unit = YGUnitPercent; - return result; + YGValue result; + result.value = value; + result.defined = !YGFloatIsUndefined(value); + result.unit = YGUnitPercent; + return result; } YGNodeRef YGNodeNew(void) { @@ -429,18 +411,8 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { return 0; } -inline float YGNodeStyleGetFlexBasis(const YGNodeRef node) { - if (!YGValueIsUndefined(node->style.flexBasis)) { - return node->style.flexBasis.value; - } - if (!YGFloatIsUndefined(node->style.flex)) { - return node->style.flex > 0 ? 0 : YGUndefined; - } - return YGUndefined; -} - -inline YGValue YGNodeStyleGetFlexBasisWithUnit(const YGNodeRef node) { - if (!YGValueIsUndefined(node->style.flexBasis)) { +inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { + if (node->style.flexBasis.defined) { return node->style.flexBasis; } if (!YGFloatIsUndefined(node->style.flex)) { @@ -474,21 +446,13 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ - void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName) { \ + void YGNodeStyleSet##name##(const YGNodeRef node, const type paramName) { \ if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ node->style.instanceName.value = paramName.value; \ node->style.instanceName.defined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName.unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ - } \ - } \ - void YGNodeStyleSet##name(const YGNodeRef node, const float paramName) { \ - if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPixel) { \ - node->style.instanceName.value = paramName; \ - node->style.instanceName.defined = !YGFloatIsUndefined(paramName); \ - node->style.instanceName.unit = YGUnitPixel; \ - YGNodeMarkDirtyInternal(node); \ - } \ + } \ } #define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \ @@ -501,39 +465,24 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ \ - float YGNodeStyleGet##name(const YGNodeRef node) { \ - return node->style.instanceName.value; \ - } \ - type YGNodeStyleGet##name##WithUnit(const YGNodeRef node) { \ + type YGNodeStyleGet##name##(const YGNodeRef node) { \ return node->style.instanceName; \ } #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName, defaultValue) \ - void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const YGEdge edge, const type paramName) { \ + void YGNodeStyleSet##name##(const YGNodeRef node, const YGEdge edge, const type paramName) { \ if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ node->style.instanceName[edge].value = paramName.value; \ node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName[edge].unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ - } \ + } \ } \ - \ - void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ - if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ - node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName); \ - node->style.instanceName[edge].unit = YGUnitPixel; \ - YGNodeMarkDirtyInternal(node); \ - } \ - } \ \ - type YGNodeStyleGet##name##WithUnit(const YGNodeRef node, const YGEdge edge) { \ + type YGNodeStyleGet##name##(const YGNodeRef node, const YGEdge edge) { \ return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue); \ } \ - \ - float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue).value; \ - } + #define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName, defaultValue) \ void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ @@ -612,17 +561,13 @@ inline bool YGFloatIsUndefined(const float value) { return isnan(value); } -inline bool YGValueIsUndefined(const YGValue value) { - return !value.defined; -} - static inline bool YGValueEqual(const YGValue a, const YGValue b) { if (a.unit != b.unit){ return false; } - if (YGValueIsUndefined(a)) { - return YGValueIsUndefined(b); + if (!a.defined) { + return !b.defined; } return fabs(a.value - b.value) < 0.0001; } @@ -653,7 +598,7 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { } static void YGPrintNumberIfNotUndefined(const char *str, const YGValue number) { - if (!YGValueIsUndefined(number)) { + if (number.defined) { YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); } } @@ -731,7 +676,7 @@ static void YGNodePrintInternal(const YGNodeRef node, YGPrintNumberIfNotUndefinedf("flexGrow", YGNodeStyleGetFlexGrow(node)); YGPrintNumberIfNotUndefinedf("flexShrink", YGNodeStyleGetFlexShrink(node)); - YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasisWithUnit(node)); + YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasis(node)); if (node->style.overflow == YGOverflowHidden) { YGLog(YGLogLevelDebug, "overflow: 'hidden', "); @@ -859,41 +804,41 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) } static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeStart])) { - return YGValueToFloat(node->style.margin[YGEdgeStart], widthSize); + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].defined) { + return YGValueResolve(node->style.margin[YGEdgeStart], widthSize); } - return YGValueToFloat(YGComputedEdgeValue(node->style.margin, leading[axis], 0), widthSize); + return YGValueResolve(YGComputedEdgeValue(node->style.margin, leading[axis], 0), widthSize); } static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeEnd])) { - return YGValueToFloat(node->style.margin[YGEdgeEnd], widthSize); + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].defined) { + return YGValueResolve(node->style.margin[YGEdgeEnd], widthSize); } - return YGValueToFloat(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), widthSize); + return YGValueResolve(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), widthSize); } static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeStart]) && - YGValueToFloat(node->style.padding[YGEdgeStart], widthSize) >= 0) { - return YGValueToFloat(node->style.padding[YGEdgeStart], widthSize); + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].defined && + YGValueResolve(node->style.padding[YGEdgeStart], widthSize) >= 0) { + return YGValueResolve(node->style.padding[YGEdgeStart], widthSize); } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, leading[axis], 0), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, leading[axis], 0), widthSize), 0); } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeEnd]) && - YGValueToFloat(node->style.padding[YGEdgeEnd], widthSize) >= 0) { - return YGValueToFloat(node->style.padding[YGEdgeEnd], widthSize); + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].defined && + YGValueResolve(node->style.padding[YGEdgeEnd], widthSize) >= 0) { + return YGValueResolve(node->style.padding[YGEdgeEnd], widthSize); } - return fmaxf(YGValueToFloat(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), widthSize), 0); } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeStart]) && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].defined && node->style.border[YGEdgeStart].value >= 0) { return node->style.border[YGEdgeStart].value; } @@ -902,7 +847,7 @@ static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axi } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeEnd]) && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].defined && node->style.border[YGEdgeEnd].value >= 0) { return node->style.border[YGEdgeEnd].value; } @@ -974,7 +919,7 @@ static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirect static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const YGValue value = node->style.dimensions[dim[axis]]; - return !YGValueIsUndefined(value) && value.value >= 0.0; + return value.defined && value.value >= 0.0; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -984,46 +929,44 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - !YGValueIsUndefined( - YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined))) || - !YGValueIsUndefined(YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined)); + YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined).defined) || + YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined).defined; } static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - !YGValueIsUndefined(YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined))) || - !YGValueIsUndefined( - YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined)); + YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined).defined) || + YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined).defined; } static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); - if (!YGValueIsUndefined(leadingPosition)) { - return YGValueToFloat(leadingPosition, axisSize); + if (leadingPosition.defined) { + return YGValueResolve(leadingPosition, axisSize); } } const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined); - return YGValueIsUndefined(leadingPosition) ? 0 : YGValueToFloat(leadingPosition, axisSize); + return !leadingPosition.defined ? 0 : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); - if (!YGValueIsUndefined(trailingPosition)) { - return YGValueToFloat(trailingPosition, axisSize); + if (trailingPosition.defined) { + return YGValueResolve(trailingPosition, axisSize); } } const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined); - return YGValueIsUndefined(trailingPosition) ? 0 : YGValueToFloat(trailingPosition, axisSize); + return !trailingPosition.defined ? 0 : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -1033,11 +976,11 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, float max = YGUndefined; if (YGFlexDirectionIsColumn(axis)) { - min = YGValueToFloat(node->style.minDimensions[YGDimensionHeight], axisSize); - max = YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], axisSize); + min = YGValueResolve(node->style.minDimensions[YGDimensionHeight], axisSize); + max = YGValueResolve(node->style.maxDimensions[YGDimensionHeight], axisSize); } else if (YGFlexDirectionIsRow(axis)) { - min = YGValueToFloat(node->style.minDimensions[YGDimensionWidth], axisSize); - max = YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], axisSize); + min = YGValueResolve(node->style.minDimensions[YGDimensionWidth], axisSize); + max = YGValueResolve(node->style.maxDimensions[YGDimensionWidth], axisSize); } float boundValue = value; @@ -1133,23 +1076,23 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (!YGValueIsUndefined(YGNodeStyleGetFlexBasisWithUnit(child)) && + if (YGNodeStyleGetFlexBasis(child).defined && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(YGNodeStyleGetFlexBasisWithUnit(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); + fmaxf(YGValueResolve(YGNodeStyleGetFlexBasis(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionWidth], parentWidth), + fmaxf(YGValueResolve(child->style.dimensions[YGDimensionWidth], parentWidth), YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight), + fmaxf(YGValueResolve(child->style.dimensions[YGDimensionHeight], parentHeight), YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped @@ -1160,12 +1103,12 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { - childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], parentWidth) + + childWidth = YGValueResolve(child->style.dimensions[YGDimensionWidth], parentWidth) + YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth); childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], parentHeight) + + childHeight = YGValueResolve(child->style.dimensions[YGDimensionHeight], parentHeight) + YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1216,10 +1159,10 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, } } - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], parentWidth), + YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionWidth], parentWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], parentHeight), + YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionHeight], parentHeight), &childHeightMeasureMode, &childHeight); @@ -1260,7 +1203,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) { - childWidth = YGValueToFloat(child->style.dimensions[YGDimensionWidth], width) + + childWidth = YGValueResolve(child->style.dimensions[YGDimensionWidth], width) + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); } else { // If the child doesn't have a specified width, compute the width based @@ -1278,7 +1221,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, } if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) { - childHeight = YGValueToFloat(child->style.dimensions[YGDimensionHeight], height) + + childHeight = YGValueResolve(child->style.dimensions[YGDimensionHeight], height) + YGNodeMarginForAxis(child, YGFlexDirectionColumn, width); } else { // If the child doesn't have a specified height, compute the height @@ -1289,8 +1232,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childHeight = node->layout.measuredDimensions[YGDimensionHeight] - (YGNodeLeadingBorder(node, YGFlexDirectionColumn) + YGNodeTrailingBorder(node, YGFlexDirectionColumn)) - - (YGNodeLeadingPosition(child, YGFlexDirectionColumn, width) + - YGNodeTrailingPosition(child, YGFlexDirectionColumn, width)); + (YGNodeLeadingPosition(child, YGFlexDirectionColumn, height) + + YGNodeTrailingPosition(child, YGFlexDirectionColumn, height)); childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width); } } @@ -1982,7 +1925,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, childHeightMeasureMode = YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionHeight], availableInnerHeight) + + childHeight = YGValueResolve(currentRelativeChild->style.dimensions[YGDimensionHeight], availableInnerHeight) + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth); childHeightMeasureMode = YGMeasureModeExactly; } @@ -2002,7 +1945,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, childWidthMeasureMode = YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = YGValueToFloat(currentRelativeChild->style.dimensions[YGDimensionWidth], availableInnerWidth) + + childWidth = YGValueResolve(currentRelativeChild->style.dimensions[YGDimensionWidth], availableInnerWidth) + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth); childWidthMeasureMode = YGMeasureModeExactly; } @@ -2022,10 +1965,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, } } - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableInnerWidth), + YGConstrainMaxSizeForMode(YGValueResolve(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableInnerHeight), + YGConstrainMaxSizeForMode(YGValueResolve(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2065,10 +2008,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, // constraint by the min size defined for the main axis. if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { - if (!YGValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && - YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { + if (node->style.minDimensions[dim[mainAxis]].defined && + YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, - YGValueToFloat(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - + YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - (availableInnerMainDim - remainingFreeSpace)); } else { remainingFreeSpace = 0; @@ -2222,10 +2165,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth); } - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionWidth], availableInnerWidth), + YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueToFloat(child->style.maxDimensions[YGDimensionHeight], availableInnerHeight), + YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2763,22 +2706,22 @@ void YGNodeCalculateLayout(const YGNodeRef node, if (!YGFloatIsUndefined(width)) { widthMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow)) { - width = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + + width = YGValueResolve(node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); widthMeasureMode = YGMeasureModeExactly; - } else if (YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { - width = YGValueToFloat(node->style.maxDimensions[YGDimensionWidth], availableWidth); + } else if (YGValueResolve(node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { + width = YGValueResolve(node->style.maxDimensions[YGDimensionWidth], availableWidth); widthMeasureMode = YGMeasureModeAtMost; } if (!YGFloatIsUndefined(height)) { heightMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { - height = YGValueToFloat(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + + height = YGValueResolve(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); heightMeasureMode = YGMeasureModeExactly; - } else if (YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { - height = YGValueToFloat(node->style.maxDimensions[YGDimensionHeight], availableHeight); + } else if (YGValueResolve(node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { + height = YGValueResolve(node->style.maxDimensions[YGDimensionHeight], availableHeight); heightMeasureMode = YGMeasureModeAtMost; } diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c30d14a7..358d217f 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -38,11 +38,10 @@ typedef struct YGSize { float height; } YGSize; -typedef struct YGValue{ +typedef struct YGValue { float value; YGUnit unit; bool defined; - } YGValue; WIN_EXPORT YGValue YGPx(const float value); @@ -93,7 +92,6 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); WIN_EXPORT bool YGFloatIsUndefined(const float value); -WIN_EXPORT bool YGValueIsUndefined(const YGValue value); WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, const float width, @@ -119,9 +117,8 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ - YG_NODE_STYLE_PROPERTY(float, name, paramName); \ - WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName); \ - WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node); + WIN_EXPORT void YGNodeStyleSet##name##(const YGNodeRef node, const type paramName); \ + WIN_EXPORT type YGNodeStyleGet##name##(const YGNodeRef node); #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ @@ -130,11 +127,10 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ - YG_NODE_STYLE_EDGE_PROPERTY(float, name, paramName) \ - WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, \ + WIN_EXPORT void YGNodeStyleSet##name##(const YGNodeRef node, \ const YGEdge edge, \ const type paramName); \ - WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node, const YGEdge edge); + WIN_EXPORT type YGNodeStyleGet##name##(const YGNodeRef node, const YGEdge edge); #define YG_NODE_LAYOUT_PROPERTY(type, name) \ WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node); -- 2.50.1.windows.1 From 1af3a763218b61d2bc962119d603571192e7f996 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:18:28 +0100 Subject: [PATCH 14/39] rename enum count --- yoga/YGEnums.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 32a56ff6..761f00e5 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -24,7 +24,7 @@ typedef enum YGFlexDirection { typedef enum YGUnit { YGUnitPixel, YGUnitPercent, - YGUnitModeCount, + YGUnitCount, } YGUnit; typedef enum YGMeasureMode { -- 2.50.1.windows.1 From 26ad37af79edaa88e451a9b0f08eb0bdd518aa04 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:20:30 +0100 Subject: [PATCH 15/39] use YGValueUndefined also here --- yoga/Yoga.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index c4bed869..1c263000 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -212,9 +212,7 @@ static void YGNodeInit(const YGNodeRef node) { node->style.flex = YGUndefined; node->style.flexGrow = YGUndefined; node->style.flexShrink = YGUndefined; - node->style.flexBasis.value = YGUndefined; - node->style.flexBasis.defined = false; - node->style.flexBasis.unit = YGUnitPixel; + node->style.flexBasis = YGValueUndefined; node->style.alignItems = YGAlignStretch; node->style.alignContent = YGAlignFlexStart; -- 2.50.1.windows.1 From 9ea8e73dd529c75f18ddd8f2339d01f5f3ca4f73 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:28:01 +0100 Subject: [PATCH 16/39] use struct initializer --- yoga/Yoga.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 1c263000..e387a5fd 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -188,11 +188,12 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], return YGValueUndefined; } - YGValue result; - result.value = defaultValue; - result.defined = (defaultValue < 0 || defaultValue >= 0); /* is faster than a nan function call and enough at this point */ - result.unit = YGUnitPixel; - return result; + YGValue result = { + .value = defaultValue, + .defined = (defaultValue < 0 || defaultValue >= 0), /* is faster than a nan function call and enough at this point */ + .unit = YGUnitPixel, + }; + return result; } static inline float YGValueResolve(const YGValue unit, const float parentSize) { @@ -260,19 +261,21 @@ static void YGNodeInit(const YGNodeRef node) { int32_t gNodeInstanceCount = 0; YGValue YGPx(const float value){ - YGValue result; - result.value = value; - result.defined = !YGFloatIsUndefined(value); - result.unit = YGUnitPixel; - return result; + YGValue result = { + .value = value, + .defined = !YGFloatIsUndefined(value), + .unit = YGUnitPixel, + }; + return result; } YGValue YGPercent(const float value){ - YGValue result; - result.value = value; - result.defined = !YGFloatIsUndefined(value); - result.unit = YGUnitPercent; - return result; + YGValue result = { + .value = value, + .defined = !YGFloatIsUndefined(value), + .unit = YGUnitPercent, + }; + return result; } YGNodeRef YGNodeNew(void) { -- 2.50.1.windows.1 From a6bdf6abf12f8a8dce93a21c565fa5e96462f7bf Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:35:29 +0100 Subject: [PATCH 17/39] fix more tests calls --- tests/YGMeasureCacheTest.cpp | 4 ++-- tests/YGMeasureModeTest.cpp | 36 ++++++++++++++++++------------------ tests/YGMeasureTest.cpp | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/YGMeasureCacheTest.cpp b/tests/YGMeasureCacheTest.cpp index ca932b25..65b043c3 100644 --- a/tests/YGMeasureCacheTest.cpp +++ b/tests/YGMeasureCacheTest.cpp @@ -43,8 +43,8 @@ TEST(YogaTest, measure_once_single_flexible_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index cd5aedba..ad766043 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -49,8 +49,8 @@ TEST(YogaTest, exactly_measure_stretched_child_column) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -76,8 +76,8 @@ TEST(YogaTest, exactly_measure_stretched_child_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -102,8 +102,8 @@ TEST(YogaTest, at_most_main_axis_column) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -129,8 +129,8 @@ TEST(YogaTest, at_most_cross_axis_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -156,8 +156,8 @@ TEST(YogaTest, at_most_main_axis_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -184,8 +184,8 @@ TEST(YogaTest, at_most_cross_axis_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -210,7 +210,7 @@ TEST(YogaTest, flex_child) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -239,7 +239,7 @@ TEST(YogaTest, flex_child_with_flex_basis) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -268,8 +268,8 @@ TEST(YogaTest, overflow_scroll_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetOverflow(root, YGOverflowScroll); - YGNodeStyleSetHeight(root, 100); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -300,8 +300,8 @@ TEST(YogaTest, overflow_scroll_row) { YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowScroll); - YGNodeStyleSetHeight(root, 100); - YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); diff --git a/tests/YGMeasureTest.cpp b/tests/YGMeasureTest.cpp index 911f0c51..b7eb6585 100644 --- a/tests/YGMeasureTest.cpp +++ b/tests/YGMeasureTest.cpp @@ -28,8 +28,8 @@ static YGSize _measure(YGNodeRef node, TEST(YogaTest, dont_measure_single_grow_shrink_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); int measureCount = 0; -- 2.50.1.windows.1 From fae6b6352f6fb0be5126f6285733415200edc9e0 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 19:41:50 +0100 Subject: [PATCH 18/39] update styletest --- tests/YGStyleTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index 65747337..bc1d13fc 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -26,16 +26,16 @@ TEST(YogaTest, copy_style_modified) { const YGNodeRef node0 = YGNodeNew(); ASSERT_FALSE(YGNodeIsDirty(node0)); ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); - ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetMaxHeight(node0))); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).defined); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node1, 10); + YGNodeStyleSetMaxHeight(node1, YGPx(10)); YGNodeCopyStyle(node0, node1); ASSERT_TRUE(YGNodeIsDirty(node0)); ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0)); - ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0)); + ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0).value); YGNodeFree(node0); YGNodeFree(node1); @@ -44,13 +44,13 @@ TEST(YogaTest, copy_style_modified) { TEST(YogaTest, copy_style_modified_same) { const YGNodeRef node0 = YGNodeNew(); YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node0, 10); + YGNodeStyleSetMaxHeight(node0, YGPx(10)); YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FALSE(YGNodeIsDirty(node0)); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node1, 10); + YGNodeStyleSetMaxHeight(node1, YGPx(10)); YGNodeCopyStyle(node0, node1); ASSERT_FALSE(YGNodeIsDirty(node0)); -- 2.50.1.windows.1 From cac8d3715b7a58620c8ad28890ca468ed3b4af13 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 21:11:02 +0100 Subject: [PATCH 19/39] code review --- tests/YGLayoutDefaultValuesTest.cpp | 34 +++++++------- tests/YGStyleTest.cpp | 2 +- yoga/Yoga.c | 72 ++++++++++++++--------------- yoga/Yoga.h | 10 ++-- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index 67906ac4..64ec5b2d 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -27,28 +27,28 @@ TEST(YogaTest, assert_default_values) { ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); - ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).defined); + ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).defined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).defined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).defined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).defined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).defined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).defined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).isDefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom).value); - ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).defined); - ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).defined); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).isDefined); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).isDefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom).value); - ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).defined); - ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).defined); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).isDefined); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).isDefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); @@ -57,12 +57,12 @@ TEST(YogaTest, assert_default_values) { ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); - ASSERT_FALSE(YGNodeStyleGetWidth(root).defined); - ASSERT_FALSE(YGNodeStyleGetHeight(root).defined); - ASSERT_FALSE(YGNodeStyleGetMinWidth(root).defined); - ASSERT_FALSE(YGNodeStyleGetMinHeight(root).defined); - ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).defined); - ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).defined); + ASSERT_FALSE(YGNodeStyleGetWidth(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetHeight(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetMinWidth(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetMinHeight(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).isDefined); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index bc1d13fc..68995bc6 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -26,7 +26,7 @@ TEST(YogaTest, copy_style_modified) { const YGNodeRef node0 = YGNodeNew(); ASSERT_FALSE(YGNodeIsDirty(node0)); ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); - ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).defined); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).isDefined); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index e387a5fd..3566c7d1 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -115,7 +115,7 @@ YGFree gYGFree = &free; static YGValue YGValueUndefined = { .value = YGUndefined, - .defined = false, + .isDefined = false, .unit = YGUnitPixel }; @@ -167,20 +167,20 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const float defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (edges[edge].defined) { + if (edges[edge].isDefined) { return edges[edge]; } - if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].defined) { + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].isDefined) { return edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && - edges[YGEdgeHorizontal].defined) { + edges[YGEdgeHorizontal].isDefined) { return edges[YGEdgeHorizontal]; } - if (edges[YGEdgeAll].defined) { + if (edges[YGEdgeAll].isDefined) { return edges[YGEdgeAll]; } @@ -190,7 +190,7 @@ static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], YGValue result = { .value = defaultValue, - .defined = (defaultValue < 0 || defaultValue >= 0), /* is faster than a nan function call and enough at this point */ + .isDefined = (defaultValue < 0 || defaultValue >= 0), /* is faster than a nan function call and enough at this point */ .unit = YGUnitPixel, }; return result; @@ -263,7 +263,7 @@ int32_t gNodeInstanceCount = 0; YGValue YGPx(const float value){ YGValue result = { .value = value, - .defined = !YGFloatIsUndefined(value), + .isDefined = !YGFloatIsUndefined(value), .unit = YGUnitPixel, }; return result; @@ -272,7 +272,7 @@ YGValue YGPx(const float value){ YGValue YGPercent(const float value){ YGValue result = { .value = value, - .defined = !YGFloatIsUndefined(value), + .isDefined = !YGFloatIsUndefined(value), .unit = YGUnitPercent, }; return result; @@ -413,7 +413,7 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { } inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { - if (node->style.flexBasis.defined) { + if (node->style.flexBasis.isDefined) { return node->style.flexBasis; } if (!YGFloatIsUndefined(node->style.flex)) { @@ -447,10 +447,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ - void YGNodeStyleSet##name##(const YGNodeRef node, const type paramName) { \ + void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ node->style.instanceName.value = paramName.value; \ - node->style.instanceName.defined = !YGFloatIsUndefined(paramName.value); \ + node->style.instanceName.isDefined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName.unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -466,21 +466,21 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ \ - type YGNodeStyleGet##name##(const YGNodeRef node) { \ + type YGNodeStyleGet##name(const YGNodeRef node) { \ return node->style.instanceName; \ } #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName, defaultValue) \ - void YGNodeStyleSet##name##(const YGNodeRef node, const YGEdge edge, const type paramName) { \ + void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const type paramName) { \ if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ node->style.instanceName[edge].value = paramName.value; \ - node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName.value); \ + node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName.value); \ node->style.instanceName[edge].unit = paramName.unit; \ YGNodeMarkDirtyInternal(node); \ } \ } \ \ - type YGNodeStyleGet##name##(const YGNodeRef node, const YGEdge edge) { \ + type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue); \ } \ @@ -489,7 +489,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].defined = !YGFloatIsUndefined(paramName); \ + node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName); \ node->style.instanceName[edge].unit = YGUnitPixel; \ YGNodeMarkDirtyInternal(node); \ } \ @@ -567,8 +567,8 @@ static inline bool YGValueEqual(const YGValue a, const YGValue b) { return false; } - if (!a.defined) { - return !b.defined; + if (!a.isDefined) { + return !b.isDefined; } return fabs(a.value - b.value) < 0.0001; } @@ -599,7 +599,7 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { } static void YGPrintNumberIfNotUndefined(const char *str, const YGValue number) { - if (number.defined) { + if (number.isDefined) { YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); } } @@ -805,7 +805,7 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) } static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].defined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].isDefined) { return YGValueResolve(node->style.margin[YGEdgeStart], widthSize); } @@ -813,7 +813,7 @@ static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirect } static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].defined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].isDefined) { return YGValueResolve(node->style.margin[YGEdgeEnd], widthSize); } @@ -821,7 +821,7 @@ static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].defined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].isDefined && YGValueResolve(node->style.padding[YGEdgeStart], widthSize) >= 0) { return YGValueResolve(node->style.padding[YGEdgeStart], widthSize); } @@ -830,7 +830,7 @@ static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].defined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].isDefined && YGValueResolve(node->style.padding[YGEdgeEnd], widthSize) >= 0) { return YGValueResolve(node->style.padding[YGEdgeEnd], widthSize); } @@ -839,7 +839,7 @@ static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection a } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].defined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].isDefined && node->style.border[YGEdgeStart].value >= 0) { return node->style.border[YGEdgeStart].value; } @@ -848,7 +848,7 @@ static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axi } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].defined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].isDefined && node->style.border[YGEdgeEnd].value >= 0) { return node->style.border[YGEdgeEnd].value; } @@ -920,7 +920,7 @@ static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirect static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const YGValue value = node->style.dimensions[dim[axis]]; - return value.defined && value.value >= 0.0; + return value.isDefined && value.value >= 0.0; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -930,21 +930,21 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined).defined) || - YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined).defined; + YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined).isDefined) || + YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined).isDefined; } static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined).defined) || - YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined).defined; + YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined).isDefined) || + YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined).isDefined; } static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); - if (leadingPosition.defined) { + if (leadingPosition.isDefined) { return YGValueResolve(leadingPosition, axisSize); } } @@ -952,14 +952,14 @@ static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection a const YGValue leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined); - return !leadingPosition.defined ? 0 : YGValueResolve(leadingPosition, axisSize); + return !leadingPosition.isDefined ? 0 : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); - if (trailingPosition.defined) { + if (trailingPosition.isDefined) { return YGValueResolve(trailingPosition, axisSize); } } @@ -967,7 +967,7 @@ static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection const YGValue trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined); - return !trailingPosition.defined ? 0 : YGValueResolve(trailingPosition, axisSize); + return !trailingPosition.isDefined ? 0 : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -1077,7 +1077,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (YGNodeStyleGetFlexBasis(child).defined && + if (YGNodeStyleGetFlexBasis(child).isDefined && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && @@ -2009,7 +2009,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // constraint by the min size defined for the main axis. if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { - if (node->style.minDimensions[dim[mainAxis]].defined && + if (node->style.minDimensions[dim[mainAxis]].isDefined && YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 358d217f..24015056 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -41,7 +41,7 @@ typedef struct YGSize { typedef struct YGValue { float value; YGUnit unit; - bool defined; + bool isDefined; } YGValue; WIN_EXPORT YGValue YGPx(const float value); @@ -117,8 +117,8 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ - WIN_EXPORT void YGNodeStyleSet##name##(const YGNodeRef node, const type paramName); \ - WIN_EXPORT type YGNodeStyleGet##name##(const YGNodeRef node); + WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ + WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ @@ -127,10 +127,10 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ - WIN_EXPORT void YGNodeStyleSet##name##(const YGNodeRef node, \ + WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ const YGEdge edge, \ const type paramName); \ - WIN_EXPORT type YGNodeStyleGet##name##(const YGNodeRef node, const YGEdge edge); + WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_LAYOUT_PROPERTY(type, name) \ WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node); -- 2.50.1.windows.1 From e2c586490a1d40108991f2b9c4578be2ccd34061 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 23:01:31 +0100 Subject: [PATCH 20/39] update c# interop to use percentage --- csharp/Facebook.Yoga/Border.cs | 31 ++ csharp/Facebook.Yoga/Native.cs | 40 +-- csharp/Facebook.Yoga/Spacing.cs | 16 +- csharp/Facebook.Yoga/YogaConstants.cs | 5 + csharp/Facebook.Yoga/YogaNode.Create.cs | 16 +- csharp/Facebook.Yoga/YogaNode.cs | 27 +- csharp/Facebook.Yoga/YogaUnit.cs | 17 ++ csharp/Facebook.Yoga/YogaValue.cs | 67 +++++ csharp/Facebook.Yoga/YogaValueExtensions.cs | 34 +++ .../Facebook.Yoga/YGAbsolutePositionTest.cs | 108 +++---- .../tests/Facebook.Yoga/YGAlignContentTest.cs | 86 +++--- .../tests/Facebook.Yoga/YGAlignItemsTest.cs | 30 +- csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs | 32 +- csharp/tests/Facebook.Yoga/YGBorderTest.cs | 64 ++-- .../Facebook.Yoga/YGFlexDirectionTest.cs | 56 ++-- csharp/tests/Facebook.Yoga/YGFlexTest.cs | 82 ++--- csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs | 72 ++--- .../Facebook.Yoga/YGJustifyContentTest.cs | 98 +++--- csharp/tests/Facebook.Yoga/YGMarginTest.cs | 80 ++--- .../Facebook.Yoga/YGMinMaxDimensionTest.cs | 92 +++--- csharp/tests/Facebook.Yoga/YGPaddingTest.cs | 80 ++--- .../tests/Facebook.Yoga/YGPercentageTest.cs | 280 +++++++++--------- csharp/tests/Facebook.Yoga/YGRoundingTest.cs | 170 +++++------ .../tests/Facebook.Yoga/YogaNodeCreateTest.cs | 52 ++-- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 2 +- gentest/gentest-cs.js | 38 ++- 26 files changed, 919 insertions(+), 756 deletions(-) create mode 100644 csharp/Facebook.Yoga/Border.cs create mode 100644 csharp/Facebook.Yoga/YogaUnit.cs create mode 100644 csharp/Facebook.Yoga/YogaValue.cs create mode 100644 csharp/Facebook.Yoga/YogaValueExtensions.cs diff --git a/csharp/Facebook.Yoga/Border.cs b/csharp/Facebook.Yoga/Border.cs new file mode 100644 index 00000000..27c15cf4 --- /dev/null +++ b/csharp/Facebook.Yoga/Border.cs @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.Yoga +{ + public class Border + { + public float? Top; + public float? Bottom; + public float? Left; + public float? Right; + + public Border( + float? top = null, + float? bottom = null, + float? left = null, + float? right = null) + { + Top = top; + Bottom = bottom; + Left = left; + Right = right; + } + } +} \ No newline at end of file diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 7786b8cf..0d68360e 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -181,46 +181,46 @@ namespace Facebook.Yoga public static extern float YGNodeStyleGetFlexShrink(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis); + public static extern void YGNodeStyleSetFlexBasis(IntPtr node, YogaValue flexBasis); [DllImport(DllName)] - public static extern float YGNodeStyleGetFlexBasis(IntPtr node); + public static extern YogaValue YGNodeStyleGetFlexBasis(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetWidth(IntPtr node, float width); + public static extern void YGNodeStyleSetWidth(IntPtr node, YogaValue width); [DllImport(DllName)] - public static extern float YGNodeStyleGetWidth(IntPtr node); + public static extern YogaValue YGNodeStyleGetWidth(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetHeight(IntPtr node, float height); + public static extern void YGNodeStyleSetHeight(IntPtr node, YogaValue height); [DllImport(DllName)] - public static extern float YGNodeStyleGetHeight(IntPtr node); + public static extern YogaValue YGNodeStyleGetHeight(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth); + public static extern void YGNodeStyleSetMinWidth(IntPtr node, YogaValue minWidth); [DllImport(DllName)] - public static extern float YGNodeStyleGetMinWidth(IntPtr node); + public static extern YogaValue YGNodeStyleGetMinWidth(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight); + public static extern void YGNodeStyleSetMinHeight(IntPtr node, YogaValue minHeight); [DllImport(DllName)] - public static extern float YGNodeStyleGetMinHeight(IntPtr node); + public static extern YogaValue YGNodeStyleGetMinHeight(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth); + public static extern void YGNodeStyleSetMaxWidth(IntPtr node, YogaValue maxWidth); [DllImport(DllName)] - public static extern float YGNodeStyleGetMaxWidth(IntPtr node); + public static extern YogaValue YGNodeStyleGetMaxWidth(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight); + public static extern void YGNodeStyleSetMaxHeight(IntPtr node, YogaValue maxHeight); [DllImport(DllName)] - public static extern float YGNodeStyleGetMaxHeight(IntPtr node); + public static extern YogaValue YGNodeStyleGetMaxHeight(IntPtr node); [DllImport(DllName)] public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio); @@ -233,22 +233,22 @@ namespace Facebook.Yoga #region YG_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName)] - public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position); + public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, YogaValue position); [DllImport(DllName)] - public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge); + public static extern YogaValue YGNodeStyleGetPosition(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin); + public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, YogaValue margin); [DllImport(DllName)] - public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge); + public static extern YogaValue YGNodeStyleGetMargin(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding); + public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, YogaValue padding); [DllImport(DllName)] - public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge); + public static extern YogaValue YGNodeStyleGetPadding(IntPtr node, YogaEdge edge); [DllImport(DllName)] public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border); diff --git a/csharp/Facebook.Yoga/Spacing.cs b/csharp/Facebook.Yoga/Spacing.cs index c1c53c96..7f5dffbd 100644 --- a/csharp/Facebook.Yoga/Spacing.cs +++ b/csharp/Facebook.Yoga/Spacing.cs @@ -11,16 +11,16 @@ namespace Facebook.Yoga { public class Spacing { - public float? Top; - public float? Bottom; - public float? Left; - public float? Right; + public YogaValue? Top; + public YogaValue? Bottom; + public YogaValue? Left; + public YogaValue? Right; public Spacing( - float? top = null, - float? bottom = null, - float? left = null, - float? right = null) + YogaValue? top = null, + YogaValue? bottom = null, + YogaValue? left = null, + YogaValue? right = null) { Top = top; Bottom = bottom; diff --git a/csharp/Facebook.Yoga/YogaConstants.cs b/csharp/Facebook.Yoga/YogaConstants.cs index 3e12aa14..76e51f9c 100644 --- a/csharp/Facebook.Yoga/YogaConstants.cs +++ b/csharp/Facebook.Yoga/YogaConstants.cs @@ -17,5 +17,10 @@ namespace Facebook.Yoga { return float.IsNaN(value); } + + public static bool IsUndefined(YogaValue value) + { + return !value.IsDefined; + } } } diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs index a7df02d0..d40d9732 100644 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -26,17 +26,17 @@ namespace Facebook.Yoga float? flex = null, float? flexGrow = null, float? flexShrink = null, - float? flexBasis = null, + YogaValue? flexBasis = null, Spacing position = null, Spacing margin = null, Spacing padding = null, - Spacing border = null, - float? Width = null, - float? Height = null, - float? MaxWidth = null, - float? MaxHeight = null, - float? MinWidth = null, - float? MinHeight = null) + Border border = null, + YogaValue? Width = null, + YogaValue? Height = null, + YogaValue? MaxWidth = null, + YogaValue? MaxHeight = null, + YogaValue? MinWidth = null, + YogaValue? MinHeight = null) { YogaNode node = new YogaNode(); diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 9211b28e..5948f852 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -10,7 +10,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; namespace Facebook.Yoga @@ -233,7 +232,7 @@ namespace Facebook.Yoga } } - public float FlexBasis + public YogaValue FlexBasis { get { @@ -246,22 +245,22 @@ namespace Facebook.Yoga } } - public float GetMargin(YogaEdge edge) + public YogaValue GetMargin(YogaEdge edge) { return Native.YGNodeStyleGetMargin(_ygNode, edge); } - public void SetMargin(YogaEdge edge, float value) + public void SetMargin(YogaEdge edge, YogaValue value) { Native.YGNodeStyleSetMargin(_ygNode, edge, value); } - public float GetPadding(YogaEdge edge) + public YogaValue GetPadding(YogaEdge edge) { return Native.YGNodeStyleGetPadding(_ygNode, edge); } - public void SetPadding(YogaEdge edge, float padding) + public void SetPadding(YogaEdge edge, YogaValue padding) { Native.YGNodeStyleSetPadding(_ygNode, edge, padding); } @@ -276,17 +275,17 @@ namespace Facebook.Yoga Native.YGNodeStyleSetBorder(_ygNode, edge, border); } - public float GetPosition(YogaEdge edge) + public YogaValue GetPosition(YogaEdge edge) { return Native.YGNodeStyleGetPosition(_ygNode, edge); } - public void SetPosition(YogaEdge edge, float position) + public void SetPosition(YogaEdge edge, YogaValue position) { Native.YGNodeStyleSetPosition(_ygNode, edge, position); } - public float Width + public YogaValue Width { get { @@ -299,7 +298,7 @@ namespace Facebook.Yoga } } - public float Height + public YogaValue Height { get { @@ -312,7 +311,7 @@ namespace Facebook.Yoga } } - public float MaxWidth + public YogaValue MaxWidth { get { @@ -325,7 +324,7 @@ namespace Facebook.Yoga } } - public float MaxHeight + public YogaValue MaxHeight { get { @@ -338,7 +337,7 @@ namespace Facebook.Yoga } } - public float MinWidth + public YogaValue MinWidth { get { @@ -351,7 +350,7 @@ namespace Facebook.Yoga } } - public float MinHeight + public YogaValue MinHeight { get { diff --git a/csharp/Facebook.Yoga/YogaUnit.cs b/csharp/Facebook.Yoga/YogaUnit.cs new file mode 100644 index 00000000..660cb9d6 --- /dev/null +++ b/csharp/Facebook.Yoga/YogaUnit.cs @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.Yoga +{ + public enum YogaUnit + { + Pixel, + Percent + } +} \ No newline at end of file diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs new file mode 100644 index 00000000..15d60e65 --- /dev/null +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +using System.Runtime.InteropServices; + +namespace Facebook.Yoga +{ + [StructLayout(LayoutKind.Sequential)] + public struct YogaValue + { + private float Value; + private YogaUnit Unit; + private byte isDefined; + + public bool IsDefined => isDefined != 0; + + public static YogaValue Pixel(float value) + { + return new YogaValue + { + Value = value, + isDefined = 1, + Unit = YogaUnit.Pixel + }; + } + + public bool Equals(YogaValue other) + { + return Value.Equals(other.Value) && Unit == other.Unit; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + return obj is YogaValue && Equals((YogaValue) obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Value.GetHashCode() * 397) ^ (int) Unit; + } + } + + public static YogaValue Percent(float value) + { + return new YogaValue + { + Value = value, + isDefined = 1, + Unit = YogaUnit.Percent + }; + } + + public static implicit operator YogaValue(float pixelValue) + { + return Pixel(pixelValue); + } + } +} \ No newline at end of file diff --git a/csharp/Facebook.Yoga/YogaValueExtensions.cs b/csharp/Facebook.Yoga/YogaValueExtensions.cs new file mode 100644 index 00000000..9ccee62a --- /dev/null +++ b/csharp/Facebook.Yoga/YogaValueExtensions.cs @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.Yoga +{ + public static class YogaValueExtensions + { + public static YogaValue Percent(this float value) + { + return YogaValue.Percent(value); + } + + public static YogaValue Px(this float value) + { + return YogaValue.Pixel(value); + } + + public static YogaValue Percent(this int value) + { + return YogaValue.Percent(value); + } + + public static YogaValue Px(this int value) + { + return YogaValue.Pixel(value); + } + } +} \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index c9d49cc0..65806462 100644 --- a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -21,15 +21,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_start_top() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10f); - root_child0.SetPosition(YogaEdge.Top, 10f); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.SetPosition(YogaEdge.Start, 10.Px()); + root_child0.SetPosition(YogaEdge.Top, 10.Px()); + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -62,15 +62,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.End, 10f); - root_child0.SetPosition(YogaEdge.Bottom, 10f); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.SetPosition(YogaEdge.End, 10.Px()); + root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -103,15 +103,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_start_top_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10f); - root_child0.SetPosition(YogaEdge.Top, 10f); - root_child0.SetPosition(YogaEdge.End, 10f); - root_child0.SetPosition(YogaEdge.Bottom, 10f); + root_child0.SetPosition(YogaEdge.Start, 10.Px()); + root_child0.SetPosition(YogaEdge.Top, 10.Px()); + root_child0.SetPosition(YogaEdge.End, 10.Px()); + root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -144,17 +144,17 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_start_top_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10f); - root_child0.SetPosition(YogaEdge.Top, 10f); - root_child0.SetPosition(YogaEdge.End, 10f); - root_child0.SetPosition(YogaEdge.Bottom, 10f); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.SetPosition(YogaEdge.Start, 10.Px()); + root_child0.SetPosition(YogaEdge.Top, 10.Px()); + root_child0.SetPosition(YogaEdge.End, 10.Px()); + root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -189,18 +189,18 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Overflow = YogaOverflow.Hidden; - root.Width = 50f; - root.Height = 50f; + root.Width = 50.Px(); + root.Height = 50.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 0f); - root_child0.SetPosition(YogaEdge.Top, 0f); + root_child0.SetPosition(YogaEdge.Start, 0.Px()); + root_child0.SetPosition(YogaEdge.Top, 0.Px()); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 100f; - root_child0_child0.Height = 100f; + root_child0_child0.Width = 100.Px(); + root_child0_child0.Height = 100.Px(); root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -243,35 +243,35 @@ namespace Facebook.Yoga public void Test_absolute_layout_within_border() { YogaNode root = new YogaNode(); - root.SetMargin(YogaEdge.Left, 10f); - root.SetMargin(YogaEdge.Top, 10f); - root.SetMargin(YogaEdge.Right, 10f); - root.SetMargin(YogaEdge.Bottom, 10f); - root.SetPadding(YogaEdge.Left, 10f); - root.SetPadding(YogaEdge.Top, 10f); - root.SetPadding(YogaEdge.Right, 10f); - root.SetPadding(YogaEdge.Bottom, 10f); - root.SetBorder(YogaEdge.Left, 10f); - root.SetBorder(YogaEdge.Top, 10f); - root.SetBorder(YogaEdge.Right, 10f); - root.SetBorder(YogaEdge.Bottom, 10f); - root.Width = 100f; - root.Height = 100f; + root.SetMargin(YogaEdge.Left, 10.Px()); + root.SetMargin(YogaEdge.Top, 10.Px()); + root.SetMargin(YogaEdge.Right, 10.Px()); + root.SetMargin(YogaEdge.Bottom, 10.Px()); + root.SetPadding(YogaEdge.Left, 10.Px()); + root.SetPadding(YogaEdge.Top, 10.Px()); + root.SetPadding(YogaEdge.Right, 10.Px()); + root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.SetBorder(YogaEdge.Left, 10); + root.SetBorder(YogaEdge.Top, 10); + root.SetBorder(YogaEdge.Right, 10); + root.SetBorder(YogaEdge.Bottom, 10); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Left, 0f); - root_child0.SetPosition(YogaEdge.Top, 0f); - root_child0.Width = 50f; - root_child0.Height = 50f; + root_child0.SetPosition(YogaEdge.Left, 0.Px()); + root_child0.SetPosition(YogaEdge.Top, 0.Px()); + root_child0.Width = 50.Px(); + root_child0.Height = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.PositionType = YogaPositionType.Absolute; - root_child1.SetPosition(YogaEdge.Right, 0f); - root_child1.SetPosition(YogaEdge.Bottom, 0f); - root_child1.Width = 50f; - root_child1.Height = 50f; + root_child1.SetPosition(YogaEdge.Right, 0.Px()); + root_child1.SetPosition(YogaEdge.Bottom, 0.Px()); + root_child1.Width = 50.Px(); + root_child1.Height = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs index 598b1dd7..42f0a6ac 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs @@ -22,32 +22,32 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; - root_child0.Height = 10f; + root_child0.Width = 50.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; - root_child1.Height = 10f; + root_child1.Width = 50.Px(); + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; - root_child2.Height = 10f; + root_child2.Width = 50.Px(); + root_child2.Height = 10.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50f; - root_child3.Height = 10f; + root_child3.Width = 50.Px(); + root_child3.Height = 10.Px(); root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50f; - root_child4.Height = 10f; + root_child4.Width = 50.Px(); + root_child4.Height = 10.Px(); root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -122,32 +122,32 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; - root_child0.Height = 10f; + root_child0.Width = 50.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; - root_child1.Height = 10f; + root_child1.Width = 50.Px(); + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; - root_child2.Height = 10f; + root_child2.Width = 50.Px(); + root_child2.Height = 10.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50f; - root_child3.Height = 10f; + root_child3.Width = 50.Px(); + root_child3.Height = 10.Px(); root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50f; - root_child4.Height = 10f; + root_child4.Width = 50.Px(); + root_child4.Height = 10.Px(); root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -222,32 +222,32 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; - root_child0.Height = 10f; + root_child0.Width = 50.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; - root_child1.Height = 10f; + root_child1.Width = 50.Px(); + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; - root_child2.Height = 10f; + root_child2.Width = 50.Px(); + root_child2.Height = 10.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50f; - root_child3.Height = 10f; + root_child3.Width = 50.Px(); + root_child3.Height = 10.Px(); root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50f; - root_child4.Height = 10f; + root_child4.Width = 50.Px(); + root_child4.Height = 10.Px(); root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -322,27 +322,27 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; + root_child0.Width = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; + root_child1.Width = 50.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; + root_child2.Width = 50.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50f; + root_child3.Width = 50.Px(); root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50f; + root_child4.Width = 50.Px(); root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index 33b4c0d2..daac3786 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -21,11 +21,11 @@ namespace Facebook.Yoga public void Test_align_items_stretch() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -59,12 +59,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -98,12 +98,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -137,12 +137,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexEnd; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs index c564cf93..acf64a83 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs @@ -21,13 +21,13 @@ namespace Facebook.Yoga public void Test_align_self_center() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.Center; - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,13 +60,13 @@ namespace Facebook.Yoga public void Test_align_self_flex_end() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -99,13 +99,13 @@ namespace Facebook.Yoga public void Test_align_self_flex_start() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexStart; - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -139,13 +139,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs index 613fe115..324411ae 100644 --- a/csharp/tests/Facebook.Yoga/YGBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -21,10 +21,10 @@ namespace Facebook.Yoga public void Test_border_no_size() { YogaNode root = new YogaNode(); - root.SetBorder(YogaEdge.Left, 10f); - root.SetBorder(YogaEdge.Top, 10f); - root.SetBorder(YogaEdge.Right, 10f); - root.SetBorder(YogaEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10); + root.SetBorder(YogaEdge.Top, 10); + root.SetBorder(YogaEdge.Right, 10); + root.SetBorder(YogaEdge.Bottom, 10); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -46,14 +46,14 @@ namespace Facebook.Yoga public void Test_border_container_match_child() { YogaNode root = new YogaNode(); - root.SetBorder(YogaEdge.Left, 10f); - root.SetBorder(YogaEdge.Top, 10f); - root.SetBorder(YogaEdge.Right, 10f); - root.SetBorder(YogaEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10); + root.SetBorder(YogaEdge.Top, 10); + root.SetBorder(YogaEdge.Right, 10); + root.SetBorder(YogaEdge.Bottom, 10); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -86,16 +86,16 @@ namespace Facebook.Yoga public void Test_border_flex_child() { YogaNode root = new YogaNode(); - root.SetBorder(YogaEdge.Left, 10f); - root.SetBorder(YogaEdge.Top, 10f); - root.SetBorder(YogaEdge.Right, 10f); - root.SetBorder(YogaEdge.Bottom, 10f); - root.Width = 100f; - root.Height = 100f; + root.SetBorder(YogaEdge.Left, 10); + root.SetBorder(YogaEdge.Top, 10); + root.SetBorder(YogaEdge.Right, 10); + root.SetBorder(YogaEdge.Bottom, 10); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.Width = 10f; + root_child0.FlexGrow = 1; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -128,15 +128,15 @@ namespace Facebook.Yoga public void Test_border_stretch_child() { YogaNode root = new YogaNode(); - root.SetBorder(YogaEdge.Left, 10f); - root.SetBorder(YogaEdge.Top, 10f); - root.SetBorder(YogaEdge.Right, 10f); - root.SetBorder(YogaEdge.Bottom, 10f); - root.Width = 100f; - root.Height = 100f; + root.SetBorder(YogaEdge.Left, 10); + root.SetBorder(YogaEdge.Top, 10); + root.SetBorder(YogaEdge.Right, 10); + root.SetBorder(YogaEdge.Bottom, 10); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -171,15 +171,15 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; - root.SetBorder(YogaEdge.Start, 10f); - root.SetBorder(YogaEdge.End, 20f); - root.SetBorder(YogaEdge.Bottom, 20f); - root.Width = 100f; - root.Height = 100f; + root.SetBorder(YogaEdge.Start, 10); + root.SetBorder(YogaEdge.End, 20); + root.SetBorder(YogaEdge.Bottom, 20); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs index 10a1257a..dfbd5c23 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs @@ -21,18 +21,18 @@ namespace Facebook.Yoga public void Test_flex_direction_column_no_height() { YogaNode root = new YogaNode(); - root.Width = 100f; + root.Width = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -86,18 +86,18 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Height = 100f; + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -150,19 +150,19 @@ namespace Facebook.Yoga public void Test_flex_direction_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -216,19 +216,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -282,19 +282,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.ColumnReverse; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -348,19 +348,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.RowReverse; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGFlexTest.cs b/csharp/tests/Facebook.Yoga/YGFlexTest.cs index 05036680..850e0969 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexTest.cs @@ -21,16 +21,16 @@ namespace Facebook.Yoga public void Test_flex_basis_flex_grow_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -74,16 +74,16 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -126,16 +126,16 @@ namespace Facebook.Yoga public void Test_flex_basis_flex_shrink_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexShrink = 1f; - root_child0.FlexBasis = 100f; + root_child0.FlexShrink = 1; + root_child0.FlexBasis = 100.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 50f; + root_child1.FlexBasis = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -179,16 +179,16 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexShrink = 1f; - root_child0.FlexBasis = 100f; + root_child0.FlexShrink = 1; + root_child0.FlexBasis = 100.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 50f; + root_child1.FlexBasis = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -231,22 +231,22 @@ namespace Facebook.Yoga public void Test_flex_shrink_to_zero() { YogaNode root = new YogaNode(); - root.Height = 75f; + root.Height = 75.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; - root_child0.Height = 50f; + root_child0.Width = 50.Px(); + root_child0.Height = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexShrink = 1f; - root_child1.Width = 50f; - root_child1.Height = 50f; + root_child1.FlexShrink = 1; + root_child1.Width = 50.Px(); + root_child1.Height = 50.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; - root_child2.Height = 50f; + root_child2.Width = 50.Px(); + root_child2.Height = 50.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -299,23 +299,23 @@ namespace Facebook.Yoga public void Test_flex_basis_overrides_main_size() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -368,15 +368,15 @@ namespace Facebook.Yoga public void Test_flex_grow_shrink_at_most() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.FlexGrow = 1f; - root_child0_child0.FlexShrink = 1f; + root_child0_child0.FlexGrow = 1; + root_child0_child0.FlexShrink = 1; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs index d5c88f7f..aae223ab 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs @@ -22,26 +22,26 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; - root.Height = 100f; + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30f; - root_child0.Height = 30f; + root_child0.Width = 30.Px(); + root_child0.Height = 30.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30f; - root_child1.Height = 30f; + root_child1.Width = 30.Px(); + root_child1.Height = 30.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30f; - root_child2.Height = 30f; + root_child2.Width = 30.Px(); + root_child2.Height = 30.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30f; - root_child3.Height = 30f; + root_child3.Width = 30.Px(); + root_child3.Height = 30.Px(); root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -106,26 +106,26 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; + root.Width = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30f; - root_child0.Height = 30f; + root_child0.Width = 30.Px(); + root_child0.Height = 30.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30f; - root_child1.Height = 30f; + root_child1.Width = 30.Px(); + root_child1.Height = 30.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30f; - root_child2.Height = 30f; + root_child2.Width = 30.Px(); + root_child2.Height = 30.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30f; - root_child3.Height = 30f; + root_child3.Width = 30.Px(); + root_child3.Height = 30.Px(); root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -191,26 +191,26 @@ namespace Facebook.Yoga root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; + root.Width = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30f; - root_child0.Height = 10f; + root_child0.Width = 30.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30f; - root_child1.Height = 20f; + root_child1.Width = 30.Px(); + root_child1.Height = 20.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30f; - root_child2.Height = 30f; + root_child2.Width = 30.Px(); + root_child2.Height = 30.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30f; - root_child3.Height = 30f; + root_child3.Width = 30.Px(); + root_child3.Height = 30.Px(); root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -276,26 +276,26 @@ namespace Facebook.Yoga root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; - root.Width = 100f; + root.Width = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30f; - root_child0.Height = 10f; + root_child0.Width = 30.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30f; - root_child1.Height = 20f; + root_child1.Width = 30.Px(); + root_child1.Height = 20.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30f; - root_child2.Height = 30f; + root_child2.Width = 30.Px(); + root_child2.Height = 30.Px(); root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30f; - root_child3.Height = 30f; + root_child3.Width = 30.Px(); + root_child3.Height = 30.Px(); root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs index 7c8bb4d1..060a2899 100644 --- a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs @@ -22,19 +22,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -89,19 +89,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -156,19 +156,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.Center; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -223,19 +223,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceBetween; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -290,19 +290,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceAround; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10f; + root_child1.Width = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10f; + root_child2.Width = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -355,18 +355,18 @@ namespace Facebook.Yoga public void Test_justify_content_column_flex_start() { YogaNode root = new YogaNode(); - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -420,19 +420,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -486,19 +486,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -552,19 +552,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceBetween; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -618,19 +618,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceAround; - root.Width = 102f; - root.Height = 102f; + root.Width = 102.Px(); + root.Height = 102.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10f; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs index fa9ddee2..9c070235 100644 --- a/csharp/tests/Facebook.Yoga/YGMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -22,12 +22,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Start, 10f); - root_child0.Width = 10f; + root_child0.SetMargin(YogaEdge.Start, 10.Px()); + root_child0.Width = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.Yoga public void Test_margin_top() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Top, 10f); - root_child0.Height = 10f; + root_child0.SetMargin(YogaEdge.Top, 10.Px()); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -100,12 +100,12 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.End, 10f); - root_child0.Width = 10f; + root_child0.SetMargin(YogaEdge.End, 10.Px()); + root_child0.Width = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -139,12 +139,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Bottom, 10f); - root_child0.Height = 10f; + root_child0.SetMargin(YogaEdge.Bottom, 10.Px()); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -178,12 +178,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetMargin(YogaEdge.Start, 10f); + root_child0.FlexGrow = 1; + root_child0.SetMargin(YogaEdge.Start, 10.Px()); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -216,12 +216,12 @@ namespace Facebook.Yoga public void Test_margin_and_flex_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetMargin(YogaEdge.Top, 10f); + root_child0.FlexGrow = 1; + root_child0.SetMargin(YogaEdge.Top, 10.Px()); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -255,12 +255,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetMargin(YogaEdge.Top, 10f); + root_child0.FlexGrow = 1; + root_child0.SetMargin(YogaEdge.Top, 10.Px()); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -293,12 +293,12 @@ namespace Facebook.Yoga public void Test_margin_and_stretch_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetMargin(YogaEdge.Start, 10f); + root_child0.FlexGrow = 1; + root_child0.SetMargin(YogaEdge.Start, 10.Px()); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -332,15 +332,15 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -383,15 +383,15 @@ namespace Facebook.Yoga public void Test_margin_with_sibling_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index 04413d41..7abcfd6c 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -21,12 +21,12 @@ namespace Facebook.Yoga public void Test_max_width() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.MaxWidth = 50f; - root_child0.Height = 10f; + root_child0.MaxWidth = 50.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.MaxHeight = 50f; + root_child0.Width = 10.Px(); + root_child0.MaxHeight = 50.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -98,16 +98,16 @@ namespace Facebook.Yoga public void Test_min_height() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.MinHeight = 60f; + root_child0.FlexGrow = 1; + root_child0.MinHeight = 60.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -151,16 +151,16 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.MinWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.MinWidth = 60.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -204,13 +204,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.Width = 100f; - root.MinHeight = 100f; - root.MaxHeight = 200f; + root.Width = 100.Px(); + root.MinHeight = 100.Px(); + root.MaxHeight = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 60f; - root_child0.Height = 60f; + root_child0.Width = 60.Px(); + root_child0.Height = 60.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -244,13 +244,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; - root.MinWidth = 100f; - root.MaxWidth = 200f; - root.Height = 100f; + root.MinWidth = 100.Px(); + root.MaxWidth = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 60f; - root_child0.Height = 60f; + root_child0.Width = 60.Px(); + root_child0.Height = 60.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -284,22 +284,22 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.MinHeight = 100f; - root.MaxHeight = 110f; + root.MinHeight = 100.Px(); + root.MaxHeight = 110.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50f; - root_child0.Height = 50f; + root_child0.Width = 50.Px(); + root_child0.Height = 50.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; - root_child1.Height = 50f; + root_child1.Width = 50.Px(); + root_child1.Height = 50.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50f; - root_child2.Height = 50f; + root_child2.Width = 50.Px(); + root_child2.Height = 50.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -352,17 +352,17 @@ namespace Facebook.Yoga public void Test_flex_grow_within_max_width() { YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 100f; + root.Width = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 100f; + root_child0.MaxWidth = 100.Px(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.FlexGrow = 1f; - root_child0_child0.Height = 20f; + root_child0_child0.FlexGrow = 1; + root_child0_child0.Height = 20.Px(); root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -405,17 +405,17 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_width() { YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 100f; + root.Width = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 300f; + root_child0.MaxWidth = 300.Px(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.FlexGrow = 1f; - root_child0_child0.Height = 20f; + root_child0_child0.FlexGrow = 1; + root_child0_child0.Height = 20.Px(); root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs index 7fde4e5e..da05f23a 100644 --- a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -21,10 +21,10 @@ namespace Facebook.Yoga public void Test_padding_no_size() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10f); - root.SetPadding(YogaEdge.Top, 10f); - root.SetPadding(YogaEdge.Right, 10f); - root.SetPadding(YogaEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10.Px()); + root.SetPadding(YogaEdge.Top, 10.Px()); + root.SetPadding(YogaEdge.Right, 10.Px()); + root.SetPadding(YogaEdge.Bottom, 10.Px()); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -46,14 +46,14 @@ namespace Facebook.Yoga public void Test_padding_container_match_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10f); - root.SetPadding(YogaEdge.Top, 10f); - root.SetPadding(YogaEdge.Right, 10f); - root.SetPadding(YogaEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10.Px()); + root.SetPadding(YogaEdge.Top, 10.Px()); + root.SetPadding(YogaEdge.Right, 10.Px()); + root.SetPadding(YogaEdge.Bottom, 10.Px()); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -86,16 +86,16 @@ namespace Facebook.Yoga public void Test_padding_flex_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10f); - root.SetPadding(YogaEdge.Top, 10f); - root.SetPadding(YogaEdge.Right, 10f); - root.SetPadding(YogaEdge.Bottom, 10f); - root.Width = 100f; - root.Height = 100f; + root.SetPadding(YogaEdge.Left, 10.Px()); + root.SetPadding(YogaEdge.Top, 10.Px()); + root.SetPadding(YogaEdge.Right, 10.Px()); + root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.Width = 10f; + root_child0.FlexGrow = 1; + root_child0.Width = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -128,15 +128,15 @@ namespace Facebook.Yoga public void Test_padding_stretch_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10f); - root.SetPadding(YogaEdge.Top, 10f); - root.SetPadding(YogaEdge.Right, 10f); - root.SetPadding(YogaEdge.Bottom, 10f); - root.Width = 100f; - root.Height = 100f; + root.SetPadding(YogaEdge.Left, 10.Px()); + root.SetPadding(YogaEdge.Top, 10.Px()); + root.SetPadding(YogaEdge.Right, 10.Px()); + root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10f; + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -171,15 +171,15 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; - root.SetPadding(YogaEdge.Start, 10f); - root.SetPadding(YogaEdge.End, 20f); - root.SetPadding(YogaEdge.Bottom, 20f); - root.Width = 100f; - root.Height = 100f; + root.SetPadding(YogaEdge.Start, 10.Px()); + root.SetPadding(YogaEdge.End, 20.Px()); + root.SetPadding(YogaEdge.Bottom, 20.Px()); + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -214,16 +214,16 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; root.AlignItems = YogaAlign.FlexEnd; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetPadding(YogaEdge.Left, 20f); - root_child0.SetPadding(YogaEdge.Top, 20f); - root_child0.SetPadding(YogaEdge.Right, 20f); - root_child0.SetPadding(YogaEdge.Bottom, 20f); - root_child0.Width = 100f; - root_child0.Height = 100f; + root_child0.SetPadding(YogaEdge.Left, 20.Px()); + root_child0.SetPadding(YogaEdge.Top, 20.Px()); + root_child0.SetPadding(YogaEdge.Right, 20.Px()); + root_child0.SetPadding(YogaEdge.Bottom, 20.Px()); + root_child0.Width = 100.Px(); + root_child0.Height = 100.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index 7a7f4cc9..277df479 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -24,12 +24,12 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30f; - root_child0.Height = 30f; + root_child0.Width = 30.Percent(); + root_child0.Height = 30.Percent(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -67,14 +67,14 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 400f; - root.Height = 400f; + root.Width = 400.Px(); + root.Height = 400.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetPosition(YogaEdge.Left, 10f); - root_child0.SetPosition(YogaEdge.Top, 20f); - root_child0.Width = 45f; - root_child0.Height = 55f; + root_child0.SetPosition(YogaEdge.Left, 10.Percent()); + root_child0.SetPosition(YogaEdge.Top, 20.Percent()); + root_child0.Width = 45.Percent(); + root_child0.Height = 55.Percent(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -112,14 +112,14 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 500f; - root.Height = 500f; + root.Width = 500.Px(); + root.Height = 500.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.SetPosition(YogaEdge.Right, 20f); - root_child0.SetPosition(YogaEdge.Bottom, 10f); - root_child0.Width = 55f; - root_child0.Height = 15f; + root_child0.SetPosition(YogaEdge.Right, 20.Percent()); + root_child0.SetPosition(YogaEdge.Bottom, 10.Percent()); + root_child0.Width = 55.Percent(); + root_child0.Height = 15.Percent(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -157,17 +157,17 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.FlexBasis = 25f; + root_child1.FlexGrow = 1; + root_child1.FlexBasis = 25.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -214,17 +214,17 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.FlexBasis = 25f; + root_child1.FlexGrow = 1; + root_child1.FlexBasis = 25.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -271,17 +271,17 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.MinHeight = 60f; + root_child0.FlexGrow = 1; + root_child0.MinHeight = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 2f; - root_child1.MinHeight = 10f; + root_child1.FlexGrow = 2; + root_child1.MinHeight = 10.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -329,19 +329,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 10f; - root_child0.MaxHeight = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 10.Percent(); + root_child0.MaxHeight = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 10f; - root_child1.MaxHeight = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 10.Percent(); + root_child1.MaxHeight = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -388,19 +388,19 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 10f; - root_child0.MaxHeight = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 10.Percent(); + root_child0.MaxHeight = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 10f; - root_child1.MaxHeight = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 10.Percent(); + root_child1.MaxHeight = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -448,19 +448,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 15f; - root_child0.MaxWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 15.Percent(); + root_child0.MaxWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 10f; - root_child1.MaxWidth = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 10.Percent(); + root_child1.MaxWidth = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -507,19 +507,19 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 10f; - root_child0.MaxWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 10.Percent(); + root_child0.MaxWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 15f; - root_child1.MaxWidth = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 15.Percent(); + root_child1.MaxWidth = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -567,19 +567,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 15f; - root_child0.MinWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 15.Percent(); + root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 10f; - root_child1.MinWidth = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 10.Percent(); + root_child1.MinWidth = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -626,19 +626,19 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 10f; - root_child0.MinWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 10.Percent(); + root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 15f; - root_child1.MinWidth = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 15.Percent(); + root_child1.MinWidth = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -685,51 +685,51 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 200f; + root.Width = 200.Px(); + root.Height = 200.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 10f; - root_child0.SetMargin(YogaEdge.Left, 5f); - root_child0.SetMargin(YogaEdge.Top, 5f); - root_child0.SetMargin(YogaEdge.Right, 5f); - root_child0.SetMargin(YogaEdge.Bottom, 5f); - root_child0.SetPadding(YogaEdge.Left, 3f); - root_child0.SetPadding(YogaEdge.Top, 3f); - root_child0.SetPadding(YogaEdge.Right, 3f); - root_child0.SetPadding(YogaEdge.Bottom, 3f); - root_child0.MinWidth = 60f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 10.Percent(); + root_child0.SetMargin(YogaEdge.Left, 5.Px()); + root_child0.SetMargin(YogaEdge.Top, 5.Px()); + root_child0.SetMargin(YogaEdge.Right, 5.Px()); + root_child0.SetMargin(YogaEdge.Bottom, 5.Px()); + root_child0.SetPadding(YogaEdge.Left, 3.Px()); + root_child0.SetPadding(YogaEdge.Top, 3.Px()); + root_child0.SetPadding(YogaEdge.Right, 3.Px()); + root_child0.SetPadding(YogaEdge.Bottom, 3.Px()); + root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.SetMargin(YogaEdge.Left, 5f); - root_child0_child0.SetMargin(YogaEdge.Top, 5f); - root_child0_child0.SetMargin(YogaEdge.Right, 5f); - root_child0_child0.SetMargin(YogaEdge.Bottom, 5f); - root_child0_child0.SetPadding(YogaEdge.Left, 3f); - root_child0_child0.SetPadding(YogaEdge.Top, 3f); - root_child0_child0.SetPadding(YogaEdge.Right, 3f); - root_child0_child0.SetPadding(YogaEdge.Bottom, 3f); - root_child0_child0.Width = 50f; + root_child0_child0.SetMargin(YogaEdge.Left, 5.Px()); + root_child0_child0.SetMargin(YogaEdge.Top, 5.Px()); + root_child0_child0.SetMargin(YogaEdge.Right, 5.Px()); + root_child0_child0.SetMargin(YogaEdge.Bottom, 5.Px()); + root_child0_child0.SetPadding(YogaEdge.Left, 3.Percent()); + root_child0_child0.SetPadding(YogaEdge.Top, 3.Percent()); + root_child0_child0.SetPadding(YogaEdge.Right, 3.Percent()); + root_child0_child0.SetPadding(YogaEdge.Bottom, 3.Percent()); + root_child0_child0.Width = 50.Percent(); root_child0.Insert(0, root_child0_child0); YogaNode root_child0_child0_child0 = new YogaNode(); - root_child0_child0_child0.SetMargin(YogaEdge.Left, 5f); - root_child0_child0_child0.SetMargin(YogaEdge.Top, 5f); - root_child0_child0_child0.SetMargin(YogaEdge.Right, 5f); - root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5f); - root_child0_child0_child0.SetPadding(YogaEdge.Left, 3f); - root_child0_child0_child0.SetPadding(YogaEdge.Top, 3f); - root_child0_child0_child0.SetPadding(YogaEdge.Right, 3f); - root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3f); - root_child0_child0_child0.Width = 45f; + root_child0_child0_child0.SetMargin(YogaEdge.Left, 5.Percent()); + root_child0_child0_child0.SetMargin(YogaEdge.Top, 5.Percent()); + root_child0_child0_child0.SetMargin(YogaEdge.Right, 5.Percent()); + root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5.Percent()); + root_child0_child0_child0.SetPadding(YogaEdge.Left, 3.Px()); + root_child0_child0_child0.SetPadding(YogaEdge.Top, 3.Px()); + root_child0_child0_child0.SetPadding(YogaEdge.Right, 3.Px()); + root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3.Px()); + root_child0_child0_child0.Width = 45.Percent(); root_child0_child0.Insert(0, root_child0_child0_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 4f; - root_child1.FlexBasis = 15f; - root_child1.MinWidth = 20f; + root_child1.FlexGrow = 4; + root_child1.FlexBasis = 15.Percent(); + root_child1.MinWidth = 20.Percent(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -796,20 +796,20 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 100f; + root.Width = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetMargin(YogaEdge.Left, 10f); - root_child0.SetMargin(YogaEdge.Top, 10f); - root_child0.SetMargin(YogaEdge.Right, 10f); - root_child0.SetMargin(YogaEdge.Bottom, 10f); + root_child0.FlexGrow = 1; + root_child0.SetMargin(YogaEdge.Left, 10.Percent()); + root_child0.SetMargin(YogaEdge.Top, 10.Percent()); + root_child0.SetMargin(YogaEdge.Right, 10.Percent()); + root_child0.SetMargin(YogaEdge.Bottom, 10.Percent()); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 10f; - root_child0_child0.Height = 10f; + root_child0_child0.Width = 10.Px(); + root_child0_child0.Height = 10.Px(); root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -856,20 +856,20 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 100f; + root.Width = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.SetPadding(YogaEdge.Left, 10f); - root_child0.SetPadding(YogaEdge.Top, 10f); - root_child0.SetPadding(YogaEdge.Right, 10f); - root_child0.SetPadding(YogaEdge.Bottom, 10f); + root_child0.FlexGrow = 1; + root_child0.SetPadding(YogaEdge.Left, 10.Percent()); + root_child0.SetPadding(YogaEdge.Top, 10.Percent()); + root_child0.SetPadding(YogaEdge.Right, 10.Percent()); + root_child0.SetPadding(YogaEdge.Bottom, 10.Percent()); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 10f; - root_child0_child0.Height = 10f; + root_child0_child0.Width = 10.Px(); + root_child0_child0.Height = 10.Px(); root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -916,15 +916,15 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200f; - root.Height = 100f; + root.Width = 200.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Left, 30f); - root_child0.SetPosition(YogaEdge.Top, 10f); - root_child0.Width = 10f; - root_child0.Height = 10f; + root_child0.SetPosition(YogaEdge.Left, 30.Percent()); + root_child0.SetPosition(YogaEdge.Top, 10.Percent()); + root_child0.Width = 10.Px(); + root_child0.Height = 10.Px(); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs index 62da0f0c..88c8c5a1 100644 --- a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs @@ -24,19 +24,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100f; - root.Height = 100f; + root.Width = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; + root_child2.FlexGrow = 1; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -94,27 +94,27 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 113f; - root.Height = 100f; + root.Width = 113.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; + root_child1.FlexGrow = 1; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; + root_child2.FlexGrow = 1; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.FlexGrow = 1f; + root_child3.FlexGrow = 1; root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.FlexGrow = 1f; + root_child4.FlexGrow = 1; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -192,20 +192,20 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 101f; - root.Height = 100f; + root.Width = 101.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexShrink = 1f; - root_child0.FlexBasis = 100f; + root_child0.FlexShrink = 1; + root_child0.FlexBasis = 100.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 25f; + root_child1.FlexBasis = 25.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexBasis = 25f; + root_child2.FlexBasis = 25.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -262,23 +262,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 113f; + root.Width = 100.Px(); + root.Height = 113.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -335,23 +335,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 87.4f; - root.Height = 113.4f; + root.Width = 87.4f.Px(); + root.Height = 113.4f.Px(); YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; - root_child0.FlexBasis = 50.3f; - root_child0.Height = 20.3f; + root_child0.FlexBasis = 50.3f.Px(); + root_child0.Height = 20.3f.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; - root_child2.Height = 10.7f; + root_child2.Height = 10.7f.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -408,37 +408,37 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 87.4f; - root.Height = 113.4f; + root.Width = 87.4f.Px(); + root.Height = 113.4f.Px(); YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; - root_child0.FlexBasis = 50.3f; - root_child0.Height = 20.3f; + root_child0.FlexBasis = 50.3f.Px(); + root_child0.Height = 20.3f.Px(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.FlexGrow = 1f; - root_child0_child0.FlexBasis = 0.3f; - root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f); - root_child0_child0.Height = 9.9f; + root_child0_child0.FlexGrow = 1; + root_child0_child0.FlexBasis = 0.3f.Px(); + root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f.Px()); + root_child0_child0.Height = 9.9f.Px(); root_child0.Insert(0, root_child0_child0); YogaNode root_child0_child1 = new YogaNode(); - root_child0_child1.FlexGrow = 4f; - root_child0_child1.FlexBasis = 0.3f; - root_child0_child1.SetPosition(YogaEdge.Top, 13.3f); - root_child0_child1.Height = 1.1f; + root_child0_child1.FlexGrow = 4; + root_child0_child1.FlexBasis = 0.3f.Px(); + root_child0_child1.SetPosition(YogaEdge.Top, 13.3f.Px()); + root_child0_child1.Height = 1.1f.Px(); root_child0.Insert(1, root_child0_child1); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; - root_child1.Height = 10f; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; - root_child2.Height = 10.7f; + root_child2.Height = 10.7f.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -515,23 +515,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 113.4f; + root.Width = 100.Px(); + root.Height = 113.4f.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -588,23 +588,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100f; - root.Height = 113.6f; + root.Width = 100.Px(); + root.Height = 113.6f.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -661,24 +661,24 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.SetPosition(YogaEdge.Top, 0.3f); - root.Width = 100f; - root.Height = 113.4f; + root.SetPosition(YogaEdge.Top, 0.3f.Px()); + root.Width = 100.Px(); + root.Height = 113.4f.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -735,24 +735,24 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.SetPosition(YogaEdge.Top, 0.7f); - root.Width = 100f; - root.Height = 113.4f; + root.SetPosition(YogaEdge.Top, 0.7f.Px()); + root.Width = 100.Px(); + root.Height = 113.4f.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; - root_child0.FlexBasis = 50f; - root_child0.Height = 20f; + root_child0.FlexGrow = 1; + root_child0.FlexBasis = 50.Px(); + root_child0.Height = 20.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexGrow = 1f; - root_child1.Height = 10f; + root_child1.FlexGrow = 1; + root_child1.Height = 10.Px(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexGrow = 1f; - root_child2.Height = 10f; + root_child2.FlexGrow = 1; + root_child2.Height = 10.Px(); root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs index d7cd8d8e..8ebc3ce4 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs @@ -51,14 +51,14 @@ namespace Facebook.Yoga Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection); Assert.AreEqual(YogaPositionType.Absolute, node.PositionType); Assert.AreEqual(YogaWrap.Wrap, node.Wrap); - Assert.AreEqual(6, node.GetPosition(YogaEdge.Top)); + Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Top)); Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom))); - Assert.AreEqual(4, node.GetPosition(YogaEdge.Right)); + Assert.AreEqual(4.Px(), node.GetPosition(YogaEdge.Right)); Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left))); - Assert.AreEqual(0, node.GetMargin(YogaEdge.Top)); - Assert.AreEqual(5, node.GetMargin(YogaEdge.Bottom)); - Assert.AreEqual(3, node.GetMargin(YogaEdge.Left)); - Assert.AreEqual(0, node.GetMargin(YogaEdge.Right)); + Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Top)); + Assert.AreEqual(5.Px(), node.GetMargin(YogaEdge.Bottom)); + Assert.AreEqual(3.Px(), node.GetMargin(YogaEdge.Left)); + Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Right)); } [Test] @@ -85,7 +85,7 @@ namespace Facebook.Yoga position: new Spacing(top: 5, bottom: 6, left: 7, right: 8), margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12), padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), - border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), + border: new Border(top: 17, bottom: 18, left: 19, right: 20), Width: 21, Height: 22, @@ -108,36 +108,36 @@ namespace Facebook.Yoga Assert.AreEqual(2, node.FlexGrow); Assert.AreEqual(3, node.FlexShrink); - Assert.AreEqual(4, node.FlexBasis); + Assert.AreEqual(4.Px(), node.FlexBasis); node.FlexGrow = YogaConstants.Undefined; Assert.AreEqual(1, node.FlexGrow); - Assert.AreEqual(5, node.GetPosition(YogaEdge.Top)); - Assert.AreEqual(6, node.GetPosition(YogaEdge.Bottom)); - Assert.AreEqual(7, node.GetPosition(YogaEdge.Left)); - Assert.AreEqual(8, node.GetPosition(YogaEdge.Right)); + Assert.AreEqual(5.Px(), node.GetPosition(YogaEdge.Top)); + Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Bottom)); + Assert.AreEqual(7.Px(), node.GetPosition(YogaEdge.Left)); + Assert.AreEqual(8.Px(), node.GetPosition(YogaEdge.Right)); - Assert.AreEqual(9, node.GetMargin(YogaEdge.Top)); - Assert.AreEqual(10, node.GetMargin(YogaEdge.Bottom)); - Assert.AreEqual(11, node.GetMargin(YogaEdge.Left)); - Assert.AreEqual(12, node.GetMargin(YogaEdge.Right)); + Assert.AreEqual(9.Px(), node.GetMargin(YogaEdge.Top)); + Assert.AreEqual(10.Px(), node.GetMargin(YogaEdge.Bottom)); + Assert.AreEqual(11.Px(), node.GetMargin(YogaEdge.Left)); + Assert.AreEqual(12.Px(), node.GetMargin(YogaEdge.Right)); - Assert.AreEqual(13, node.GetPadding(YogaEdge.Top)); - Assert.AreEqual(14, node.GetPadding(YogaEdge.Bottom)); - Assert.AreEqual(15, node.GetPadding(YogaEdge.Left)); - Assert.AreEqual(16, node.GetPadding(YogaEdge.Right)); + Assert.AreEqual(13.Px(), node.GetPadding(YogaEdge.Top)); + Assert.AreEqual(14.Px(), node.GetPadding(YogaEdge.Bottom)); + Assert.AreEqual(15.Px(), node.GetPadding(YogaEdge.Left)); + Assert.AreEqual(16.Px(), node.GetPadding(YogaEdge.Right)); Assert.AreEqual(17, node.GetBorder(YogaEdge.Top)); Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom)); Assert.AreEqual(19, node.GetBorder(YogaEdge.Left)); Assert.AreEqual(20, node.GetBorder(YogaEdge.Right)); - Assert.AreEqual(21, node.Width); - Assert.AreEqual(22, node.Height); - Assert.AreEqual(23, node.MinWidth); - Assert.AreEqual(24, node.MinHeight); - Assert.AreEqual(25, node.MaxWidth); - Assert.AreEqual(26, node.MaxHeight); + Assert.AreEqual(21.Px(), node.Width); + Assert.AreEqual(22.Px(), node.Height); + Assert.AreEqual(23.Px(), node.MinWidth); + Assert.AreEqual(24.Px(), node.MinHeight); + Assert.AreEqual(25.Px(), node.MaxWidth); + Assert.AreEqual(26.Px(), node.MaxHeight); } } } diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index 5cf1002b..baacb1dc 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -225,7 +225,7 @@ namespace Facebook.Yoga node1.MaxHeight = 100; node0.CopyStyle(node1); - Assert.AreEqual(100, node0.MaxHeight); + Assert.AreEqual(100.Px(), node0.MaxHeight); } #if !UNITY_EDITOR diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 293b188c..59da4144 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -9,7 +9,17 @@ function toValueCs(value) { var n = value.toString().replace('px','').replace('%',''); - return n + (Number(n) == n && n % 1 !== 0 ? '' : ''); + return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); +} + +function toValueCsCs(value) { + var methodName = ''; + if(value.indexOf('px') >= 0){ + methodName = 'Px'; + }else if (value.indexOf('%') >= 0){ + methodName = 'Percent'; + } + return toValueCs(value) + '.' + methodName + '()'; } var CSEmitter = function() { @@ -160,7 +170,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + 'f);'); + this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + ');'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { @@ -168,7 +178,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push(nodeName + '.FlexBasis = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.FlexBasis = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -176,11 +186,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { @@ -188,7 +198,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.Height = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.Height = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -196,23 +206,23 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetMargin(' + edge + ', ' + toValueCs(value) + 'f);'); + this.push(nodeName + '.SetMargin(' + edge + ', ' + toValueCsCs(value) + ');'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.MaxHeight = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.MaxHeight = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.MaxWidth = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.MaxWidth = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.MinHeight = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.MinHeight = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.MinWidth = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.MinWidth = ' + toValueCsCs(value) + ';'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -220,11 +230,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPadding(' + edge + ', ' + toValueCs(value) + 'f);'); + this.push(nodeName + '.SetPadding(' + edge + ', ' + toValueCsCs(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPosition(' + edge + ', ' + toValueCs(value) + 'f);'); + this.push(nodeName + '.SetPosition(' + edge + ', ' + toValueCsCs(value) + ');'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -232,6 +242,6 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.Width = ' + toValueCs(value) + 'f;'); + this.push(nodeName + '.Width = ' + toValueCsCs(value) + ';'); }}, }); -- 2.50.1.windows.1 From d1d0618d4c7f333d3d0a930918d11a688f16bc9a Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 23:17:27 +0100 Subject: [PATCH 21/39] delete *orig --- csharp/Facebook.Yoga/YogaNode.Create.cs.orig | 243 ------------------- 1 file changed, 243 deletions(-) delete mode 100644 csharp/Facebook.Yoga/YogaNode.Create.cs.orig diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs.orig b/csharp/Facebook.Yoga/YogaNode.Create.cs.orig deleted file mode 100644 index 3cbc53fb..00000000 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs.orig +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -using System; - -namespace Facebook.Yoga -{ - public partial class YogaNode - { - public static YogaNode Create( - YogaDirection? styleDirection = null, - YogaFlexDirection? flexDirection = null, - YogaJustify? justifyContent = null, - YogaAlign? alignContent = null, - YogaAlign? alignItems = null, - YogaAlign? alignSelf = null, - YogaPositionType? positionType = null, - YogaWrap? wrap = null, - YogaOverflow? overflow = null, - float? flex = null, - float? flexGrow = null, - float? flexShrink = null, - YogaValue? flexBasis = null, - Spacing position = null, - Spacing margin = null, - Spacing padding = null, -<<<<<<< HEAD - Border border = null, - YogaValue? Width = null, - YogaValue? Height = null, - YogaValue? MaxWidth = null, - YogaValue? MaxHeight = null, - YogaValue? MinWidth = null, - YogaValue? MinHeight = null) -======= - Spacing border = null, - float? width = null, - float? height = null, - float? maxWidth = null, - float? maxHeight = null, - float? minWidth = null, - float? minHeight = null) ->>>>>>> refs/remotes/facebook/master - { - YogaNode node = new YogaNode(); - - if (styleDirection.HasValue) - { - node.StyleDirection = styleDirection.Value; - } - - if (flexDirection.HasValue) - { - node.FlexDirection = flexDirection.Value; - } - - if (justifyContent.HasValue) - { - node.JustifyContent = justifyContent.Value; - } - - if (alignContent.HasValue) - { - node.AlignContent = alignContent.Value; - } - - if (alignItems.HasValue) - { - node.AlignItems = alignItems.Value; - } - - if (alignSelf.HasValue) - { - node.AlignSelf = alignSelf.Value; - } - - if (positionType.HasValue) - { - node.PositionType = positionType.Value; - } - - if (wrap.HasValue) - { - node.Wrap = wrap.Value; - } - - if (overflow.HasValue) - { - node.Overflow = overflow.Value; - } - - if (flex.HasValue) - { - node.Flex = flex.Value; - } - - if (flexGrow.HasValue) - { - node.FlexGrow = flexGrow.Value; - } - - if (flexShrink.HasValue) - { - node.FlexShrink = flexShrink.Value; - } - - if (flexBasis.HasValue) - { - node.FlexBasis = flexBasis.Value; - } - - if (position != null) - { - if (position.Top.HasValue) - { - node.SetPosition(YogaEdge.Top, position.Top.Value); - } - - if (position.Bottom.HasValue) - { - node.SetPosition(YogaEdge.Bottom, position.Bottom.Value); - } - - if (position.Left.HasValue) - { - node.SetPosition(YogaEdge.Left, position.Left.Value); - } - - if (position.Right.HasValue) - { - node.SetPosition(YogaEdge.Right, position.Right.Value); - } - } - - if (margin != null) - { - if (margin.Top.HasValue) - { - node.SetMargin(YogaEdge.Top, margin.Top.Value); - } - - if (margin.Bottom.HasValue) - { - node.SetMargin(YogaEdge.Bottom, margin.Bottom.Value); - } - - if (margin.Left.HasValue) - { - node.SetMargin(YogaEdge.Left, margin.Left.Value); - } - - if (margin.Right.HasValue) - { - node.SetMargin(YogaEdge.Right, margin.Right.Value); - } - } - - if (padding != null) - { - if (padding.Top.HasValue) - { - node.SetPadding(YogaEdge.Top, padding.Top.Value); - } - - if (padding.Bottom.HasValue) - { - node.SetPadding(YogaEdge.Bottom, padding.Bottom.Value); - } - - if (padding.Left.HasValue) - { - node.SetPadding(YogaEdge.Left, padding.Left.Value); - } - - if (padding.Right.HasValue) - { - node.SetPadding(YogaEdge.Right, padding.Right.Value); - } - } - - if (border != null) - { - if (border.Top.HasValue) - { - node.SetBorder(YogaEdge.Top, border.Top.Value); - } - - if (border.Bottom.HasValue) - { - node.SetBorder(YogaEdge.Bottom, border.Bottom.Value); - } - - if (border.Left.HasValue) - { - node.SetBorder(YogaEdge.Left, border.Left.Value); - } - - if (border.Right.HasValue) - { - node.SetBorder(YogaEdge.Right, border.Right.Value); - } - } - - if (width.HasValue) - { - node.Width = width.Value; - } - - if (height.HasValue) - { - node.Height = height.Value; - } - - if (minWidth.HasValue) - { - node.MinWidth = minWidth.Value; - } - - if (minHeight.HasValue) - { - node.MinHeight = minHeight.Value; - } - - if (maxWidth.HasValue) - { - node.MaxWidth = maxWidth.Value; - } - - if (maxHeight.HasValue) - { - node.MaxHeight = maxHeight.Value; - } - - return node; - } - } -} -- 2.50.1.windows.1 From 08eb9ff8f7ed2e90e1667a08d72a95416f76efc8 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Mon, 19 Dec 2016 23:47:56 +0100 Subject: [PATCH 22/39] fix access violation on vprintf --- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 2 +- yoga/Yoga.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index baacb1dc..acf33f4b 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -212,7 +212,7 @@ namespace Facebook.Yoga parent.Insert(0, child0); parent.Insert(0, child1); parent.CalculateLayout(); - Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); + Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100px, height: 120px, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35px, height: 45px, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30px, height: 40px, },\n]},\n"); } [Test] diff --git a/yoga/Yoga.c b/yoga/Yoga.c index f38cb035..b2bfb79c 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -592,7 +592,7 @@ static void YGIndent(const uint32_t n) { static void YGPrintNumberIfNotZero(const char *str, const YGValue number) { if (!YGFloatsEqual(number.value, 0)) { - YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number.value, number.unit == YGUnitPixel ? "px" : "%"); } } @@ -604,7 +604,7 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { static void YGPrintNumberIfNotUndefined(const char *str, const YGValue number) { if (number.isDefined) { - YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number, number.unit == YGUnitPixel ? "px" : "%"); + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number.value, number.unit == YGUnitPixel ? "px" : "%"); } } -- 2.50.1.windows.1 From 2424fc2b12e98d433f046b4e3d3c52f981d73722 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 20 Dec 2016 07:32:47 +0100 Subject: [PATCH 23/39] fixed some cpp tests compilation issues, improved c# value struct --- csharp/Facebook.Yoga/YogaNode.Create.cs | 36 +++---- csharp/Facebook.Yoga/YogaValue.cs | 16 +++- tests/YGAspectRatioTest.cpp | 120 ++++++++++++------------ tests/YGMeasureModeTest.cpp | 2 +- 4 files changed, 92 insertions(+), 82 deletions(-) diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs index d40d9732..ee0726b5 100644 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -31,12 +31,12 @@ namespace Facebook.Yoga Spacing margin = null, Spacing padding = null, Border border = null, - YogaValue? Width = null, - YogaValue? Height = null, - YogaValue? MaxWidth = null, - YogaValue? MaxHeight = null, - YogaValue? MinWidth = null, - YogaValue? MinHeight = null) + YogaValue? width = null, + YogaValue? height = null, + YogaValue? maxWidth = null, + YogaValue? maxHeight = null, + YogaValue? minWidth = null, + YogaValue? minHeight = null) { YogaNode node = new YogaNode(); @@ -197,34 +197,34 @@ namespace Facebook.Yoga } } - if (Width.HasValue) + if (width.HasValue) { - node.Width = Width.Value; + node.Width = width.Value; } - if (Height.HasValue) + if (height.HasValue) { - node.Height = Height.Value; + node.Height = height.Value; } - if (MinWidth.HasValue) + if (minWidth.HasValue) { - node.MinWidth = MinWidth.Value; + node.MinWidth = minWidth.Value; } - if (MinHeight.HasValue) + if (minHeight.HasValue) { - node.MinHeight = MinHeight.Value; + node.MinHeight = minHeight.Value; } - if (MaxWidth.HasValue) + if (maxWidth.HasValue) { - node.MaxWidth = MaxWidth.Value; + node.MaxWidth = maxWidth.Value; } - if (MaxHeight.HasValue) + if (maxHeight.HasValue) { - node.MaxHeight = MaxHeight.Value; + node.MaxHeight = maxHeight.Value; } return node; diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs index 15d60e65..7e1acba8 100644 --- a/csharp/Facebook.Yoga/YogaValue.cs +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -16,7 +16,7 @@ namespace Facebook.Yoga { private float Value; private YogaUnit Unit; - private byte isDefined; + private byte isDefined; /* use byte to keep struct blitable */ public bool IsDefined => isDefined != 0; @@ -25,7 +25,7 @@ namespace Facebook.Yoga return new YogaValue { Value = value, - isDefined = 1, + isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1, Unit = YogaUnit.Pixel }; } @@ -49,12 +49,22 @@ namespace Facebook.Yoga } } + public static YogaValue Undefined() + { + return new YogaValue + { + Value = YogaConstants.Undefined, + isDefined = 0, + Unit = YogaUnit.Pixel + }; + } + public static YogaValue Percent(float value) { return new YogaValue { Value = value, - isDefined = 1, + isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1,, Unit = YogaUnit.Percent }; } diff --git a/tests/YGAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp index 22846c9b..7dd4ccc0 100644 --- a/tests/YGAspectRatioTest.cpp +++ b/tests/YGAspectRatioTest.cpp @@ -24,11 +24,11 @@ static YGSize _measure(YGNodeRef node, TEST(YogaTest, aspect_ratio_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetWidth(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -45,11 +45,11 @@ TEST(YogaTest, aspect_ratio_cross_defined) { TEST(YogaTest, aspect_ratio_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -65,11 +65,11 @@ TEST(YogaTest, aspect_ratio_main_defined) { TEST(YogaTest, aspect_ratio_both_dimensions_defined) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -85,8 +85,8 @@ TEST(YogaTest, aspect_ratio_both_dimensions_defined) { TEST(YogaTest, aspect_ratio_align_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAspectRatio(root_child0, 1); @@ -105,11 +105,11 @@ TEST(YogaTest, aspect_ratio_align_stretch) { TEST(YogaTest, aspect_ratio_flex_grow) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -127,11 +127,11 @@ TEST(YogaTest, aspect_ratio_flex_grow) { TEST(YogaTest, aspect_ratio_flex_shrink) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 150); + YGNodeStyleSetHeight(root_child0, YGPx(150)); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -149,11 +149,11 @@ TEST(YogaTest, aspect_ratio_flex_shrink) { TEST(YogaTest, aspect_ratio_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -169,14 +169,14 @@ TEST(YogaTest, aspect_ratio_basis) { TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetWidth(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -192,14 +192,14 @@ TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) { TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -216,12 +216,12 @@ TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) { TEST(YogaTest, aspect_ratio_with_max_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 50); - YGNodeStyleSetMaxWidth(root_child0, 40); + YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetMaxWidth(root_child0, YGPx(40)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -238,12 +238,12 @@ TEST(YogaTest, aspect_ratio_with_max_cross_defined) { TEST(YogaTest, aspect_ratio_with_max_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetMaxHeight(root_child0, 40); + YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetMaxHeight(root_child0, YGPx(40)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -260,12 +260,12 @@ TEST(YogaTest, aspect_ratio_with_max_main_defined) { TEST(YogaTest, aspect_ratio_with_min_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 30); - YGNodeStyleSetMinWidth(root_child0, 40); + YGNodeStyleSetHeight(root_child0, YGPx(30)); + YGNodeStyleSetMinWidth(root_child0, YGPx(40)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -282,12 +282,12 @@ TEST(YogaTest, aspect_ratio_with_min_cross_defined) { TEST(YogaTest, aspect_ratio_with_min_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 30); - YGNodeStyleSetMinHeight(root_child0, 40); + YGNodeStyleSetWidth(root_child0, YGPx(30)); + YGNodeStyleSetMinHeight(root_child0, YGPx(40)); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -304,11 +304,11 @@ TEST(YogaTest, aspect_ratio_with_min_main_defined) { TEST(YogaTest, aspect_ratio_double_cross) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetHeight(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); @@ -325,11 +325,11 @@ TEST(YogaTest, aspect_ratio_double_cross) { TEST(YogaTest, aspect_ratio_half_cross) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetHeight(root_child0, YGPx(100)); YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); @@ -346,11 +346,11 @@ TEST(YogaTest, aspect_ratio_half_cross) { TEST(YogaTest, aspect_ratio_double_main) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetWidth(root_child0, YGPx(50)); YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); @@ -367,11 +367,11 @@ TEST(YogaTest, aspect_ratio_double_main) { TEST(YogaTest, aspect_ratio_half_main) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetWidth(root_child0, YGPx(100)); YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); @@ -388,8 +388,8 @@ TEST(YogaTest, aspect_ratio_half_main) { TEST(YogaTest, aspect_ratio_with_measure_func) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetMeasureFunc(root_child0, _measure); diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index ad766043..9bbbbfa9 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -243,7 +243,7 @@ TEST(YogaTest, flex_child_with_flex_basis) { const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 0); + YGNodeStyleSetFlexBasis(root_child0, YGPx(0)); YGNodeSetContext(root_child0, &constraintList); YGNodeSetMeasureFunc(root_child0, _measure); YGNodeInsertChild(root, root_child0, 0); -- 2.50.1.windows.1 From 306e16fbb845bbb13b0d30f0327cf37c78ae1395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Tue, 20 Dec 2016 09:29:48 +0100 Subject: [PATCH 24/39] fix duplicate comma --- csharp/Facebook.Yoga/YogaValue.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs index 7e1acba8..9e2bc258 100644 --- a/csharp/Facebook.Yoga/YogaValue.cs +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -64,7 +64,7 @@ namespace Facebook.Yoga return new YogaValue { Value = value, - isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1,, + isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1, Unit = YogaUnit.Percent }; } @@ -74,4 +74,4 @@ namespace Facebook.Yoga return Pixel(pixelValue); } } -} \ No newline at end of file +} -- 2.50.1.windows.1 From abf97d6613f6250128e9ff196658d9f173e6faa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Tue, 20 Dec 2016 09:31:31 +0100 Subject: [PATCH 25/39] fix benchmarks --- benchmark/YGBenchmark.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index 2e816359..6f8e117a 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -26,8 +26,8 @@ YGBENCHMARKS({ YGBENCHMARK("Stack with flex", { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); @@ -45,7 +45,7 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); - YGNodeStyleSetHeight(child, 20); + YGNodeStyleSetHeight(child, YGPx(20)); YGNodeSetMeasureFunc(child, _measure); YGNodeInsertChild(root, child, 0); } @@ -80,31 +80,31 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); YGNodeStyleSetFlexGrow(child, 1); - YGNodeStyleSetWidth(child, 10); - YGNodeStyleSetHeight(child, 10); + YGNodeStyleSetWidth(child, YGPx(10)); + YGNodeStyleSetHeight(child, YGPx(10)); YGNodeInsertChild(root, child, 0); for (uint32_t ii = 0; ii < 10; ii++) { const YGNodeRef grandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandChild, 1); - YGNodeStyleSetWidth(grandChild, 10); - YGNodeStyleSetHeight(grandChild, 10); + YGNodeStyleSetWidth(grandChild, YGPx(10)); + YGNodeStyleSetHeight(grandChild, YGPx/10)); YGNodeInsertChild(child, grandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandChild = YGNodeNew(); YGNodeStyleSetFlexGrow(grandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandChild, 10); - YGNodeStyleSetHeight(grandGrandChild, 10); + YGNodeStyleSetWidth(grandGrandChild, YGPx(10)); + YGNodeStyleSetHeight(grandGrandChild, YGPx(10)); YGNodeInsertChild(grandChild, grandGrandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandGrandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandGrandChild, 10); - YGNodeStyleSetHeight(grandGrandGrandChild, 10); + YGNodeStyleSetWidth(grandGrandGrandChild, YGPx(10)); + YGNodeStyleSetHeight(grandGrandGrandChild, YGPx(10)); YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0); } } -- 2.50.1.windows.1 From dd63f7961e50c59718394b4c9b0e3d4d51fa030c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Tue, 20 Dec 2016 09:52:43 +0100 Subject: [PATCH 26/39] fix typo --- benchmark/YGBenchmark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index 6f8e117a..d824239e 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -89,7 +89,7 @@ YGBENCHMARKS({ YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandChild, 1); YGNodeStyleSetWidth(grandChild, YGPx(10)); - YGNodeStyleSetHeight(grandChild, YGPx/10)); + YGNodeStyleSetHeight(grandChild, YGPx(10)); YGNodeInsertChild(child, grandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { -- 2.50.1.windows.1 From 67785726425c1342270d978f982ff5173c704ece Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 20 Dec 2016 20:14:22 +0100 Subject: [PATCH 27/39] highly improved performance by reducing copying of structs --- yoga/Yoga.c | 271 ++++++++++++++++++++++++++-------------------------- 1 file changed, 133 insertions(+), 138 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index b2bfb79c..6d2cdf9d 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -115,8 +115,14 @@ YGFree gYGFree = &free; static YGValue YGValueUndefined = { .value = YGUndefined, - .isDefined = false, - .unit = YGUnitPixel + .isDefined = false, + .unit = YGUnitPixel +}; + +static YGValue YGValueZero = { + .value = 0, + .isDefined = true, + .unit = YGUnitPixel }; #ifdef ANDROID @@ -162,45 +168,40 @@ static int YGDefaultLog(YGLogLevel level, const char *format, va_list args) { static YGLogger gLogger = &YGDefaultLog; #endif -static inline YGValue YGComputedEdgeValue(const YGValue edges[YGEdgeCount], +static inline const YGValue * YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const YGEdge edge, - const float defaultValue) { + const YGValue * const defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); if (edges[edge].isDefined) { - return edges[edge]; + return &edges[edge]; } if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].isDefined) { - return edges[YGEdgeVertical]; + return &edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && edges[YGEdgeHorizontal].isDefined) { - return edges[YGEdgeHorizontal]; + return &edges[YGEdgeHorizontal]; } if (edges[YGEdgeAll].isDefined) { - return edges[YGEdgeAll]; + return &edges[YGEdgeAll]; } if (edge == YGEdgeStart || edge == YGEdgeEnd) { - return YGValueUndefined; + return &YGValueUndefined; } - YGValue result = { - .value = defaultValue, - .isDefined = (defaultValue < 0 || defaultValue >= 0), /* is faster than a nan function call and enough at this point */ - .unit = YGUnitPixel, - }; - return result; + return defaultValue; } -static inline float YGValueResolve(const YGValue unit, const float parentSize) { - if (unit.unit == YGUnitPixel){ - return unit.value; +static inline float YGValueResolve(const YGValue * const unit, const float parentSize) { + if (unit->unit == YGUnitPixel){ + return unit->value; } else { - return unit.value * parentSize / 100.0f; + return unit->value * parentSize / 100.0f; } } @@ -420,10 +421,20 @@ inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { if (node->style.flexBasis.isDefined) { return node->style.flexBasis; } - if (!YGFloatIsUndefined(node->style.flex)) { - return YGPx(node->style.flex > 0 ? 0 : YGUndefined); + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { + return YGValueZero; } - return YGPx(YGUndefined); + return YGValueUndefined; +} + +static inline YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { + if (node->style.flexBasis.isDefined) { + return &node->style.flexBasis; + } + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { + return &YGValueZero; + } + return &YGValueUndefined; } void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { @@ -485,7 +496,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } \ \ type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue); \ + return *YGComputedEdgeValue(node->style.instanceName, edge, &defaultValue); \ } \ @@ -500,7 +511,8 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } \ \ float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - return YGComputedEdgeValue(node->style.instanceName, edge, defaultValue).value; \ + YGValue defaultYGValue = YGPx(defaultValue); \ + return YGComputedEdgeValue(node->style.instanceName, edge, &defaultYGValue)->value; \ } #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ @@ -526,9 +538,9 @@ YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink); YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis); -YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGUndefined); -YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, 0); -YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding, 0); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGValueUndefined); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, YGValueZero); +YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding, YGValueZero); YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, 0); YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]); @@ -590,9 +602,9 @@ static void YGIndent(const uint32_t n) { } } -static void YGPrintNumberIfNotZero(const char *str, const YGValue number) { - if (!YGFloatsEqual(number.value, 0)) { - YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number.value, number.unit == YGUnitPixel ? "px" : "%"); +static void YGPrintNumberIfNotZero(const char *str, const YGValue * const number) { + if (!YGFloatsEqual(number->value, 0)) { + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number->value, number->unit == YGUnitPixel ? "px" : "%"); } } @@ -602,9 +614,9 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { } } -static void YGPrintNumberIfNotUndefined(const char *str, const YGValue number) { - if (number.isDefined) { - YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number.value, number.unit == YGUnitPixel ? "px" : "%"); +static void YGPrintNumberIfNotUndefined(const char *str, const YGValue * const number) { + if (number->isDefined) { + YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number->value, number->unit == YGUnitPixel ? "px" : "%"); } } @@ -681,7 +693,7 @@ static void YGNodePrintInternal(const YGNodeRef node, YGPrintNumberIfNotUndefinedf("flexGrow", YGNodeStyleGetFlexGrow(node)); YGPrintNumberIfNotUndefinedf("flexShrink", YGNodeStyleGetFlexShrink(node)); - YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasis(node)); + YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasisPtr(node)); if (node->style.overflow == YGOverflowHidden) { YGLog(YGLogLevelDebug, "overflow: 'hidden', "); @@ -692,70 +704,53 @@ static void YGNodePrintInternal(const YGNodeRef node, } if (YGFourValuesEqual(node->style.margin)) { - YGPrintNumberIfNotZero("margin", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, 0)); + YGPrintNumberIfNotZero("margin", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, &YGValueZero)); } else { - YGPrintNumberIfNotZero("marginLeft", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, 0)); - YGPrintNumberIfNotZero("marginRight", - YGComputedEdgeValue(node->style.margin, YGEdgeRight, 0)); - YGPrintNumberIfNotZero("marginTop", YGComputedEdgeValue(node->style.margin, YGEdgeTop, 0)); - YGPrintNumberIfNotZero("marginBottom", - YGComputedEdgeValue(node->style.margin, YGEdgeBottom, 0)); - YGPrintNumberIfNotZero("marginStart", - YGComputedEdgeValue(node->style.margin, YGEdgeStart, 0)); - YGPrintNumberIfNotZero("marginEnd", YGComputedEdgeValue(node->style.margin, YGEdgeEnd, 0)); + YGPrintNumberIfNotZero("marginLeft", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, &YGValueZero)); + YGPrintNumberIfNotZero("marginRight", YGComputedEdgeValue(node->style.margin, YGEdgeRight, &YGValueZero)); + YGPrintNumberIfNotZero("marginTop", YGComputedEdgeValue(node->style.margin, YGEdgeTop, &YGValueZero)); + YGPrintNumberIfNotZero("marginBottom", YGComputedEdgeValue(node->style.margin, YGEdgeBottom, &YGValueZero)); + YGPrintNumberIfNotZero("marginStart", YGComputedEdgeValue(node->style.margin, YGEdgeStart, &YGValueZero)); + YGPrintNumberIfNotZero("marginEnd", YGComputedEdgeValue(node->style.margin, YGEdgeEnd, &YGValueZero)); } if (YGFourValuesEqual(node->style.padding)) { - YGPrintNumberIfNotZero("padding", YGComputedEdgeValue(node->style.padding, YGEdgeLeft, 0)); + YGPrintNumberIfNotZero("padding", YGComputedEdgeValue(node->style.padding, YGEdgeLeft, &YGValueZero)); } else { - YGPrintNumberIfNotZero("paddingLeft", - YGComputedEdgeValue(node->style.padding, YGEdgeLeft, 0)); - YGPrintNumberIfNotZero("paddingRight", - YGComputedEdgeValue(node->style.padding, YGEdgeRight, 0)); - YGPrintNumberIfNotZero("paddingTop", YGComputedEdgeValue(node->style.padding, YGEdgeTop, 0)); - YGPrintNumberIfNotZero("paddingBottom", - YGComputedEdgeValue(node->style.padding, YGEdgeBottom, 0)); - YGPrintNumberIfNotZero("paddingStart", - YGComputedEdgeValue(node->style.padding, YGEdgeStart, 0)); - YGPrintNumberIfNotZero("paddingEnd", YGComputedEdgeValue(node->style.padding, YGEdgeEnd, 0)); + YGPrintNumberIfNotZero("paddingLeft", YGComputedEdgeValue(node->style.padding, YGEdgeLeft, &YGValueZero)); + YGPrintNumberIfNotZero("paddingRight", YGComputedEdgeValue(node->style.padding, YGEdgeRight, &YGValueZero)); + YGPrintNumberIfNotZero("paddingTop", YGComputedEdgeValue(node->style.padding, YGEdgeTop, &YGValueZero)); + YGPrintNumberIfNotZero("paddingBottom", YGComputedEdgeValue(node->style.padding, YGEdgeBottom, &YGValueZero)); + YGPrintNumberIfNotZero("paddingStart", YGComputedEdgeValue(node->style.padding, YGEdgeStart, &YGValueZero)); + YGPrintNumberIfNotZero("paddingEnd", YGComputedEdgeValue(node->style.padding, YGEdgeEnd, &YGValueZero)); } if (YGFourValuesEqual(node->style.border)) { - YGPrintNumberIfNotZero("borderWidth", YGComputedEdgeValue(node->style.border, YGEdgeLeft, 0)); + YGPrintNumberIfNotZero("borderWidth", YGComputedEdgeValue(node->style.border, YGEdgeLeft, &YGValueZero)); } else { - YGPrintNumberIfNotZero("borderLeftWidth", - YGComputedEdgeValue(node->style.border, YGEdgeLeft, 0)); - YGPrintNumberIfNotZero("borderRightWidth", - YGComputedEdgeValue(node->style.border, YGEdgeRight, 0)); - YGPrintNumberIfNotZero("borderTopWidth", - YGComputedEdgeValue(node->style.border, YGEdgeTop, 0)); - YGPrintNumberIfNotZero("borderBottomWidth", - YGComputedEdgeValue(node->style.border, YGEdgeBottom, 0)); - YGPrintNumberIfNotZero("borderStartWidth", - YGComputedEdgeValue(node->style.border, YGEdgeStart, 0)); - YGPrintNumberIfNotZero("borderEndWidth", - YGComputedEdgeValue(node->style.border, YGEdgeEnd, 0)); + YGPrintNumberIfNotZero("borderLeftWidth", YGComputedEdgeValue(node->style.border, YGEdgeLeft, &YGValueZero)); + YGPrintNumberIfNotZero("borderRightWidth",YGComputedEdgeValue(node->style.border, YGEdgeRight, &YGValueZero)); + YGPrintNumberIfNotZero("borderTopWidth", YGComputedEdgeValue(node->style.border, YGEdgeTop, &YGValueZero)); + YGPrintNumberIfNotZero("borderBottomWidth", YGComputedEdgeValue(node->style.border, YGEdgeBottom, &YGValueZero)); + YGPrintNumberIfNotZero("borderStartWidth", YGComputedEdgeValue(node->style.border, YGEdgeStart, &YGValueZero)); + YGPrintNumberIfNotZero("borderEndWidth", YGComputedEdgeValue(node->style.border, YGEdgeEnd, &YGValueZero)); } - YGPrintNumberIfNotUndefined("width", node->style.dimensions[YGDimensionWidth]); - YGPrintNumberIfNotUndefined("height", node->style.dimensions[YGDimensionHeight]); - YGPrintNumberIfNotUndefined("maxWidth", node->style.maxDimensions[YGDimensionWidth]); - YGPrintNumberIfNotUndefined("maxHeight", node->style.maxDimensions[YGDimensionHeight]); - YGPrintNumberIfNotUndefined("minWidth", node->style.minDimensions[YGDimensionWidth]); - YGPrintNumberIfNotUndefined("minHeight", node->style.minDimensions[YGDimensionHeight]); + YGPrintNumberIfNotUndefined("width", &node->style.dimensions[YGDimensionWidth]); + YGPrintNumberIfNotUndefined("height", &node->style.dimensions[YGDimensionHeight]); + YGPrintNumberIfNotUndefined("maxWidth", &node->style.maxDimensions[YGDimensionWidth]); + YGPrintNumberIfNotUndefined("maxHeight", &node->style.maxDimensions[YGDimensionHeight]); + YGPrintNumberIfNotUndefined("minWidth", &node->style.minDimensions[YGDimensionWidth]); + YGPrintNumberIfNotUndefined("minHeight", &node->style.minDimensions[YGDimensionHeight]); if (node->style.positionType == YGPositionTypeAbsolute) { YGLog(YGLogLevelDebug, "position: 'absolute', "); } - YGPrintNumberIfNotUndefined("left", - YGComputedEdgeValue(node->style.position, YGEdgeLeft, YGUndefined)); - YGPrintNumberIfNotUndefined( - "right", YGComputedEdgeValue(node->style.position, YGEdgeRight, YGUndefined)); - YGPrintNumberIfNotUndefined("top", - YGComputedEdgeValue(node->style.position, YGEdgeTop, YGUndefined)); - YGPrintNumberIfNotUndefined( - "bottom", YGComputedEdgeValue(node->style.position, YGEdgeBottom, YGUndefined)); + YGPrintNumberIfNotUndefined("left", YGComputedEdgeValue(node->style.position, YGEdgeLeft, &YGValueUndefined)); + YGPrintNumberIfNotUndefined("right", YGComputedEdgeValue(node->style.position, YGEdgeRight, &YGValueUndefined)); + YGPrintNumberIfNotUndefined("top", YGComputedEdgeValue(node->style.position, YGEdgeTop, &YGValueUndefined)); + YGPrintNumberIfNotUndefined("bottom", YGComputedEdgeValue(node->style.position, YGEdgeBottom, &YGValueUndefined)); } const uint32_t childCount = YGNodeListCount(node->children); @@ -810,36 +805,36 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].isDefined) { - return YGValueResolve(node->style.margin[YGEdgeStart], widthSize); + return YGValueResolve(&node->style.margin[YGEdgeStart], widthSize); } - return YGValueResolve(YGComputedEdgeValue(node->style.margin, leading[axis], 0), widthSize); + return YGValueResolve(YGComputedEdgeValue(node->style.margin, leading[axis], &YGValueZero), widthSize); } static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].isDefined) { - return YGValueResolve(node->style.margin[YGEdgeEnd], widthSize); + return YGValueResolve(&node->style.margin[YGEdgeEnd], widthSize); } - return YGValueResolve(YGComputedEdgeValue(node->style.margin, trailing[axis], 0), widthSize); + return YGValueResolve(YGComputedEdgeValue(node->style.margin, trailing[axis], &YGValueZero), widthSize); } static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].isDefined && - YGValueResolve(node->style.padding[YGEdgeStart], widthSize) >= 0) { - return YGValueResolve(node->style.padding[YGEdgeStart], widthSize); + YGValueResolve(&node->style.padding[YGEdgeStart], widthSize) >= 0) { + return YGValueResolve(&node->style.padding[YGEdgeStart], widthSize); } - return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, leading[axis], 0), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, leading[axis], &YGValueZero), widthSize), 0); } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].isDefined && - YGValueResolve(node->style.padding[YGEdgeEnd], widthSize) >= 0) { - return YGValueResolve(node->style.padding[YGEdgeEnd], widthSize); + YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize) >= 0) { + return YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize); } - return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, trailing[axis], &YGValueZero), widthSize), 0); } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { @@ -848,7 +843,7 @@ static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axi return node->style.border[YGEdgeStart].value; } - return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], 0).value, 0); + return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], &YGValueZero)->value, 0); } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { @@ -857,7 +852,7 @@ static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection ax return node->style.border[YGEdgeEnd].value; } - return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], 0).value, 0); + return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], &YGValueZero)->value, 0); } static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node, @@ -934,44 +929,44 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined).isDefined) || - YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined).isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->isDefined) || + YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->isDefined; } static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined).isDefined) || - YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined).isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->isDefined) || + YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->isDefined; } static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { - const YGValue leadingPosition = - YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); - if (leadingPosition.isDefined) { + const YGValue * leadingPosition = + YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined); + if (leadingPosition->isDefined) { return YGValueResolve(leadingPosition, axisSize); } } - const YGValue leadingPosition = - YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined); + const YGValue * leadingPosition = + YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined); - return !leadingPosition.isDefined ? 0 : YGValueResolve(leadingPosition, axisSize); + return !leadingPosition->isDefined ? 0 : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { - const YGValue trailingPosition = - YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); - if (trailingPosition.isDefined) { + const YGValue * trailingPosition = + YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined); + if (trailingPosition->isDefined) { return YGValueResolve(trailingPosition, axisSize); } } - const YGValue trailingPosition = - YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined); + const YGValue * trailingPosition = + YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined); - return !trailingPosition.isDefined ? 0 : YGValueResolve(trailingPosition, axisSize); + return !trailingPosition->isDefined ? 0 : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -981,11 +976,11 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, float max = YGUndefined; if (YGFlexDirectionIsColumn(axis)) { - min = YGValueResolve(node->style.minDimensions[YGDimensionHeight], axisSize); - max = YGValueResolve(node->style.maxDimensions[YGDimensionHeight], axisSize); + min = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], axisSize); + max = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], axisSize); } else if (YGFlexDirectionIsRow(axis)) { - min = YGValueResolve(node->style.minDimensions[YGDimensionWidth], axisSize); - max = YGValueResolve(node->style.maxDimensions[YGDimensionWidth], axisSize); + min = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], axisSize); + max = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], axisSize); } float boundValue = value; @@ -1081,23 +1076,23 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (YGNodeStyleGetFlexBasis(child).isDefined && + if (YGNodeStyleGetFlexBasisPtr(child)->isDefined && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(YGValueResolve(YGNodeStyleGetFlexBasis(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); + fmaxf(YGValueResolve(YGNodeStyleGetFlexBasisPtr(child), mainAxisParentSize), YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueResolve(child->style.dimensions[YGDimensionWidth], parentWidth), + fmaxf(YGValueResolve(&child->style.dimensions[YGDimensionWidth], parentWidth), YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. child->layout.computedFlexBasis = - fmaxf(YGValueResolve(child->style.dimensions[YGDimensionHeight], parentHeight), + fmaxf(YGValueResolve(&child->style.dimensions[YGDimensionHeight], parentHeight), YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped @@ -1108,12 +1103,12 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { - childWidth = YGValueResolve(child->style.dimensions[YGDimensionWidth], parentWidth) + + childWidth = YGValueResolve(&child->style.dimensions[YGDimensionWidth], parentWidth) + YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth); childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = YGValueResolve(child->style.dimensions[YGDimensionHeight], parentHeight) + + childHeight = YGValueResolve(&child->style.dimensions[YGDimensionHeight], parentHeight) + YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1164,10 +1159,10 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, } } - YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionWidth], parentWidth), + YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionWidth], parentWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionHeight], parentHeight), + YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionHeight], parentHeight), &childHeightMeasureMode, &childHeight); @@ -1208,7 +1203,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) { - childWidth = YGValueResolve(child->style.dimensions[YGDimensionWidth], width) + + childWidth = YGValueResolve(&child->style.dimensions[YGDimensionWidth], width) + YGNodeMarginForAxis(child, YGFlexDirectionRow, width); } else { // If the child doesn't have a specified width, compute the width based @@ -1226,7 +1221,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, } if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) { - childHeight = YGValueResolve(child->style.dimensions[YGDimensionHeight], height) + + childHeight = YGValueResolve(&child->style.dimensions[YGDimensionHeight], height) + YGNodeMarginForAxis(child, YGFlexDirectionColumn, width); } else { // If the child doesn't have a specified height, compute the height @@ -1930,7 +1925,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, childHeightMeasureMode = YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = YGValueResolve(currentRelativeChild->style.dimensions[YGDimensionHeight], availableInnerHeight) + + childHeight = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionHeight], availableInnerHeight) + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1950,7 +1945,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, childWidthMeasureMode = YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = YGValueResolve(currentRelativeChild->style.dimensions[YGDimensionWidth], availableInnerWidth) + + childWidth = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionWidth], availableInnerWidth) + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth); childWidthMeasureMode = YGMeasureModeExactly; } @@ -1970,10 +1965,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, } } - YGConstrainMaxSizeForMode(YGValueResolve(currentRelativeChild->style.maxDimensions[YGDimensionWidth], availableInnerWidth), + YGConstrainMaxSizeForMode(YGValueResolve(¤tRelativeChild->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueResolve(currentRelativeChild->style.maxDimensions[YGDimensionHeight], availableInnerHeight), + YGConstrainMaxSizeForMode(YGValueResolve(¤tRelativeChild->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2014,9 +2009,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { if (node->style.minDimensions[dim[mainAxis]].isDefined && - YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { + YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, - YGValueResolve(node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - + YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - (availableInnerMainDim - remainingFreeSpace)); } else { remainingFreeSpace = 0; @@ -2170,10 +2165,10 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth); } - YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionWidth], availableInnerWidth), + YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionWidth], availableInnerWidth), &childWidthMeasureMode, &childWidth); - YGConstrainMaxSizeForMode(YGValueResolve(child->style.maxDimensions[YGDimensionHeight], availableInnerHeight), + YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionHeight], availableInnerHeight), &childHeightMeasureMode, &childHeight); @@ -2711,22 +2706,22 @@ void YGNodeCalculateLayout(const YGNodeRef node, if (!YGFloatIsUndefined(width)) { widthMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow)) { - width = YGValueResolve(node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + + width = YGValueResolve(&node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); widthMeasureMode = YGMeasureModeExactly; - } else if (YGValueResolve(node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { - width = YGValueResolve(node->style.maxDimensions[YGDimensionWidth], availableWidth); + } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { + width = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], availableWidth); widthMeasureMode = YGMeasureModeAtMost; } if (!YGFloatIsUndefined(height)) { heightMeasureMode = YGMeasureModeExactly; } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { - height = YGValueResolve(node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + + height = YGValueResolve(&node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); heightMeasureMode = YGMeasureModeExactly; - } else if (YGValueResolve(node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { - height = YGValueResolve(node->style.maxDimensions[YGDimensionHeight], availableHeight); + } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { + height = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], availableHeight); heightMeasureMode = YGMeasureModeAtMost; } -- 2.50.1.windows.1 From a6dcd54070df9947c6cb284f379d21d9d02a6b51 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 20 Dec 2016 20:24:02 +0100 Subject: [PATCH 28/39] no need to compute edge value on get --- yoga/Yoga.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 6d2cdf9d..049acffe 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -511,8 +511,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } \ \ float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - YGValue defaultYGValue = YGPx(defaultValue); \ - return YGComputedEdgeValue(node->style.instanceName, edge, &defaultYGValue)->value; \ + return YGComputedEdgeValue(node->style.instanceName, edge, &defaultValue)->value; \ } #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ @@ -541,7 +540,7 @@ YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGValueUndefined); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, YGValueZero); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding, YGValueZero); -YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, 0); +YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, YGValueZero); YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]); YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, Height, height, dimensions[YGDimensionHeight]); -- 2.50.1.windows.1 From 7e4a6f0e644bea95d39abe3d6737c6822c4cf92a Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 20 Dec 2016 20:45:44 +0100 Subject: [PATCH 29/39] minor tweaks --- yoga/Yoga.c | 80 +++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 049acffe..73fc40c9 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -401,37 +401,37 @@ inline float YGNodeStyleGetFlexGrow(const YGNodeRef node) { if (!YGFloatIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; } - if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { return node->style.flex; } - return 0; + return 0.0f; } inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { if (!YGFloatIsUndefined(node->style.flexShrink)) { return node->style.flexShrink; } - if (!YGFloatIsUndefined(node->style.flex) && node->style.flex < 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex < 0.0f) { return -node->style.flex; } - return 0; + return 0.0f; } inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { if (node->style.flexBasis.isDefined) { return node->style.flexBasis; } - if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { return YGValueZero; } return YGValueUndefined; } -static inline YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { +static inline const YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { if (node->style.flexBasis.isDefined) { return &node->style.flexBasis; } - if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0) { + if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { return &YGValueZero; } return &YGValueUndefined; @@ -578,21 +578,18 @@ inline bool YGFloatIsUndefined(const float value) { } static inline bool YGValueEqual(const YGValue a, const YGValue b) { - if (a.unit != b.unit){ + if (a.isDefined != b.isDefined || a.unit != b.unit) { return false; } - - if (!a.isDefined) { - return !b.isDefined; - } - return fabs(a.value - b.value) < 0.0001; + + return fabs(a.value - b.value) < 0.0001f; } static inline bool YGFloatsEqual(const float a, const float b) { if (YGFloatIsUndefined(a)) { return YGFloatIsUndefined(b); } - return fabs(a - b) < 0.0001; + return fabs(a - b) < 0.0001f; } static void YGIndent(const uint32_t n) { @@ -820,38 +817,38 @@ static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection ax static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].isDefined && - YGValueResolve(&node->style.padding[YGEdgeStart], widthSize) >= 0) { + YGValueResolve(&node->style.padding[YGEdgeStart], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeStart], widthSize); } - return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, leading[axis], &YGValueZero), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, leading[axis], &YGValueZero), widthSize), 0.0f); } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].isDefined && - YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize) >= 0) { + YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize); } - return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, trailing[axis], &YGValueZero), widthSize), 0); + return fmaxf(YGValueResolve(YGComputedEdgeValue(node->style.padding, trailing[axis], &YGValueZero), widthSize), 0.0f); } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].isDefined && - node->style.border[YGEdgeStart].value >= 0) { + node->style.border[YGEdgeStart].value >= 0.0f) { return node->style.border[YGEdgeStart].value; } - return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], &YGValueZero)->value, 0); + return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], &YGValueZero)->value, 0.0f); } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].isDefined && - node->style.border[YGEdgeEnd].value >= 0) { + node->style.border[YGEdgeEnd].value >= 0.0f) { return node->style.border[YGEdgeEnd].value; } - return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], &YGValueZero)->value, 0); + return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], &YGValueZero)->value, 0.0f); } static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node, @@ -908,7 +905,7 @@ static YGFlexDirection YGFlexDirectionCross(const YGFlexDirection flexDirection, static inline bool YGNodeIsFlex(const YGNodeRef node) { return (node->style.positionType == YGPositionTypeRelative && - (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); + (node->style.flexGrow != 0.0f || node->style.flexShrink != 0.0f || node->style.flex != 0.0f)); } static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { @@ -917,13 +914,12 @@ static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirect } static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { - const YGValue value = node->style.dimensions[dim[axis]]; - return value.isDefined && value.value >= 0.0; + return node->style.dimensions[dim[axis]].isDefined && node->style.dimensions[dim[axis]].value >= 0.0f; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const float value = node->layout.measuredDimensions[dim[axis]]; - return !YGFloatIsUndefined(value) && value >= 0.0; + return !YGFloatIsUndefined(value) && value >= 0.0f; } static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -950,7 +946,7 @@ static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection a const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined); - return !leadingPosition->isDefined ? 0 : YGValueResolve(leadingPosition, axisSize); + return !leadingPosition->isDefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { @@ -965,7 +961,7 @@ static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined); - return !trailingPosition->isDefined ? 0 : YGValueResolve(trailingPosition, axisSize); + return !trailingPosition->isDefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -984,11 +980,11 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, float boundValue = value; - if (!YGFloatIsUndefined(max) && max >= 0.0 && boundValue > max) { + if (!YGFloatIsUndefined(max) && max >= 0.0f && boundValue > max) { boundValue = max; } - if (!YGFloatIsUndefined(min) && min >= 0.0 && boundValue < min) { + if (!YGFloatIsUndefined(min) && min >= 0.0f && boundValue < min) { boundValue = min; } @@ -1331,13 +1327,13 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, availableHeight, availableWidth); - } else if (innerWidth <= 0 || innerHeight <= 0) { + } else if (innerWidth <= 0.0f || innerHeight <= 0.0f) { // Don't bother sizing the text if there's no horizontal or vertical // space. node->layout.measuredDimensions[YGDimensionWidth] = - YGNodeBoundAxis(node, YGFlexDirectionRow, 0, availableWidth, availableWidth); + YGNodeBoundAxis(node, YGFlexDirectionRow, 0.0f, availableWidth, availableWidth); node->layout.measuredDimensions[YGDimensionHeight] = - YGNodeBoundAxis(node, YGFlexDirectionColumn, 0, availableHeight, availableWidth); + YGNodeBoundAxis(node, YGFlexDirectionColumn, 0.0f, availableHeight, availableWidth); } else { // Measure the text under the current constraints. const YGSize measuredSize = @@ -1398,8 +1394,8 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, const YGMeasureMode heightMeasureMode, const float parentWidth, const float parentHeight) { - if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0) || - (heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0) || + if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0.0f) || + (heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) || (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly)) { const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth); @@ -1407,15 +1403,15 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(node, YGFlexDirectionRow, - YGFloatIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) - ? 0 + YGFloatIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0.0f) + ? 0.0f : availableWidth - marginAxisRow, parentWidth, parentWidth); node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(node, YGFlexDirectionColumn, - YGFloatIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) - ? 0 + YGFloatIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0.0f) + ? 0.0f : availableHeight - marginAxisColumn, parentHeight, parentWidth); return true; @@ -1625,7 +1621,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, singleFlexChild = NULL; break; } - } else if (YGNodeStyleGetFlexGrow(child) > 0 && YGNodeStyleGetFlexShrink(child) > 0) { + } else if (YGNodeStyleGetFlexGrow(child) > 0.0f && YGNodeStyleGetFlexShrink(child) > 0.0f) { singleFlexChild = child; } } @@ -2708,7 +2704,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, width = YGValueResolve(&node->style.dimensions[dim[YGFlexDirectionRow]], availableWidth) + YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth); widthMeasureMode = YGMeasureModeExactly; - } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0) { + } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], availableWidth) >= 0.0f) { width = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], availableWidth); widthMeasureMode = YGMeasureModeAtMost; } @@ -2719,7 +2715,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, height = YGValueResolve(&node->style.dimensions[dim[YGFlexDirectionColumn]], availableHeight) + YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth); heightMeasureMode = YGMeasureModeExactly; - } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0) { + } else if (YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], availableHeight) >= 0.0f) { height = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], availableHeight); heightMeasureMode = YGMeasureModeAtMost; } -- 2.50.1.windows.1 From 34c97b03f6bd881a88dc86cbe00ba11e22aafead Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Wed, 21 Dec 2016 07:25:23 +0100 Subject: [PATCH 30/39] dedup code --- yoga/Yoga.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 73fc40c9..722f9b56 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -417,16 +417,6 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { return 0.0f; } -inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { - if (node->style.flexBasis.isDefined) { - return node->style.flexBasis; - } - if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { - return YGValueZero; - } - return YGValueUndefined; -} - static inline const YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { if (node->style.flexBasis.isDefined) { return &node->style.flexBasis; @@ -437,6 +427,10 @@ static inline const YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { return &YGValueUndefined; } +inline YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) { + return *YGNodeStyleGetFlexBasisPtr(node); +} + void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { if (node->style.flex != flex) { node->style.flex = flex; -- 2.50.1.windows.1 From ca4481258c918f26f223d5bc15cbdac49cfe03e5 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Wed, 21 Dec 2016 22:22:21 +0100 Subject: [PATCH 31/39] regen unittests and small fixes after merge --- .../Facebook.Yoga/YGMinMaxDimensionTest.cs | 36 +++++++++---------- tests/YGMinMaxDimensionTest.cpp | 28 +++++++-------- yoga/Yoga.c | 18 ++++------ 3 files changed, 38 insertions(+), 44 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index bcaf0a38..857e65b7 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -459,15 +459,15 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.MinWidth = 100f; - root.Height = 100f; + root.MinWidth = 100.Px(); + root.Height = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50f; + root_child1.Width = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -510,14 +510,14 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_min_column() { YogaNode root = new YogaNode(); - root.MinHeight = 100f; + root.MinHeight = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexGrow = 1f; + root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 50f; + root_child1.Height = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -560,21 +560,21 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_row() { YogaNode root = new YogaNode(); - root.Width = 200f; + root.Width = 200.Px(); YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 100f; - root_child0.Height = 100f; + root_child0.MaxWidth = 100.Px(); + root_child0.Height = 100.Px(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.FlexShrink = 1f; - root_child0_child0.FlexBasis = 100f; + root_child0_child0.FlexShrink = 1; + root_child0_child0.FlexBasis = 100.Px(); root_child0.Insert(0, root_child0_child0); YogaNode root_child0_child1 = new YogaNode(); - root_child0_child1.Width = 50f; + root_child0_child1.Width = 50.Px(); root_child0.Insert(1, root_child0_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -627,16 +627,16 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_column() { YogaNode root = new YogaNode(); - root.Width = 100f; - root.MaxHeight = 100f; + root.Width = 100.Px(); + root.MaxHeight = 100.Px(); YogaNode root_child0 = new YogaNode(); - root_child0.FlexShrink = 1f; - root_child0.FlexBasis = 100f; + root_child0.FlexShrink = 1; + root_child0.FlexBasis = 100.Px(); root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 50f; + root_child1.Height = 50.Px(); root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index d2eb526a..00df60e3 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -434,15 +434,15 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) { TEST(YogaTest, flex_grow_within_constrained_min_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetMinWidth(root, 100); - YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetMinWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetWidth(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -483,14 +483,14 @@ TEST(YogaTest, flex_grow_within_constrained_min_row) { TEST(YogaTest, flex_grow_within_constrained_min_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMinHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetHeight(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -531,21 +531,21 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) { TEST(YogaTest, flex_grow_within_constrained_max_row) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetWidth(root, YGPx(200)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); + YGNodeStyleSetHeight(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, 100); + YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(100)); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child1, 50); + YGNodeStyleSetWidth(root_child0_child1, YGPx(50)); YGNodeInsertChild(root_child0, root_child0_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -596,16 +596,16 @@ TEST(YogaTest, flex_grow_within_constrained_max_row) { TEST(YogaTest, flex_grow_within_constrained_max_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetMaxHeight(root, 100); + YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetMaxHeight(root, YGPx(100)); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetHeight(root_child1, YGPx(50)); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 3fc62bf3..324eee51 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1597,8 +1597,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS - float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; const float minInnerWidth = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], parentWidth) - marginAxisRow - paddingAndBorderAxisRow; const float maxInnerWidth = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], parentWidth) - marginAxisRow - paddingAndBorderAxisRow; const float minInnerHeight = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], parentHeight) - marginAxisColumn - paddingAndBorderAxisColumn; @@ -1607,15 +1605,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight; // Max dimension overrides predefined dimension value; Min dimension in turn overrides both of the above - if (!YGFloatIsUndefined(availableInnerWidth)) { - availableInnerWidth = fmaxf(fminf(availableInnerWidth, maxInnerWidth), minInnerWidth); - } - if (!YGFloatIsUndefined(availableInnerHeight)) { - availableInnerHeight = fmaxf(fminf(availableInnerHeight, maxInnerHeight), minInnerHeight); - } + const float availableInnerWidth = fmaxf(fminf(availableWidth - marginAxisRow - paddingAndBorderAxisRow, maxInnerWidth), minInnerWidth); + const float availableInnerHeight = fmaxf(fminf(availableHeight - marginAxisColumn - paddingAndBorderAxisColumn, maxInnerHeight), minInnerHeight); float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; - const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; + float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; // If there is only one child with flexGrow + flexShrink it means we can set the // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly @@ -1772,11 +1766,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, // the line length, so there's no more space left to distribute. // We resolve main dimension to fit minimum and maximum values - if (YGValueIsUndefined(availableInnerMainDim)) { - if (!YGValueIsUndefined(minInnerMainDim) && + if (YGFloatIsUndefined(availableInnerMainDim)) { + if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) { availableInnerMainDim = minInnerMainDim; - } else if (!YGValueIsUndefined(maxInnerMainDim) && + } else if (!YGFloatIsUndefined(maxInnerMainDim) && sizeConsumedOnCurrentLine > maxInnerMainDim) { availableInnerMainDim = maxInnerMainDim; } -- 2.50.1.windows.1 From 878a6c4b08882f3c5b427dc8ca43a47c3b0a3e6e Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Wed, 21 Dec 2016 22:23:28 +0100 Subject: [PATCH 32/39] keep const --- yoga/Yoga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 324eee51..87090ac9 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1609,7 +1609,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float availableInnerHeight = fmaxf(fminf(availableHeight - marginAxisColumn - paddingAndBorderAxisColumn, maxInnerHeight), minInnerHeight); float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; - float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; + const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; // If there is only one child with flexGrow + flexShrink it means we can set the // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly -- 2.50.1.windows.1 From d182ab1b09d26a45824f85462fc2e7e7ed795a27 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 21:57:47 +0100 Subject: [PATCH 33/39] changed function signature based on latest decision --- .gitignore | 6 + benchmark/YGBenchmark.c | 22 +-- enums.py | 1 + gentest/gentest-cpp.js | 31 ++-- tests/YGAbsolutePositionTest.cpp | 100 ++++++------- tests/YGAlignContentTest.cpp | 86 +++++------ tests/YGAlignItemsTest.cpp | 30 ++-- tests/YGAlignSelfTest.cpp | 32 ++--- tests/YGBorderTest.cpp | 24 ++-- tests/YGDirtyMarkingTest.cpp | 36 ++--- tests/YGEdgeTest.cpp | 66 ++++----- tests/YGFlexDirectionTest.cpp | 56 ++++---- tests/YGFlexTest.cpp | 58 ++++---- tests/YGFlexWrapTest.cpp | 72 +++++----- tests/YGJustifyContentTest.cpp | 98 ++++++------- tests/YGMarginTest.cpp | 64 ++++----- tests/YGMinMaxDimensionTest.cpp | 108 +++++++------- tests/YGPaddingTest.cpp | 78 +++++----- tests/YGPercentageTest.cpp | 236 +++++++++++++++---------------- tests/YGRelayoutTest.cpp | 4 +- tests/YGRoundingTest.cpp | 118 ++++++++-------- yoga/YGEnums.h | 3 +- yoga/Yoga.c | 153 +++++++++++--------- yoga/Yoga.h | 12 +- 24 files changed, 761 insertions(+), 733 deletions(-) diff --git a/.gitignore b/.gitignore index fca97a4b..65f01a65 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,12 @@ # Visual studio code .vscode +*.pdb +*.tlog +*.obj +*.pch +*.log +*.orig # Xcode ## Build generated diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index d824239e..2e816359 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -26,8 +26,8 @@ YGBENCHMARKS({ YGBENCHMARK("Stack with flex", { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); @@ -45,7 +45,7 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); - YGNodeStyleSetHeight(child, YGPx(20)); + YGNodeStyleSetHeight(child, 20); YGNodeSetMeasureFunc(child, _measure); YGNodeInsertChild(root, child, 0); } @@ -80,31 +80,31 @@ YGBENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const YGNodeRef child = YGNodeNew(); YGNodeStyleSetFlexGrow(child, 1); - YGNodeStyleSetWidth(child, YGPx(10)); - YGNodeStyleSetHeight(child, YGPx(10)); + YGNodeStyleSetWidth(child, 10); + YGNodeStyleSetHeight(child, 10); YGNodeInsertChild(root, child, 0); for (uint32_t ii = 0; ii < 10; ii++) { const YGNodeRef grandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandChild, 1); - YGNodeStyleSetWidth(grandChild, YGPx(10)); - YGNodeStyleSetHeight(grandChild, YGPx(10)); + YGNodeStyleSetWidth(grandChild, 10); + YGNodeStyleSetHeight(grandChild, 10); YGNodeInsertChild(child, grandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandChild = YGNodeNew(); YGNodeStyleSetFlexGrow(grandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandChild, YGPx(10)); - YGNodeStyleSetHeight(grandGrandChild, YGPx(10)); + YGNodeStyleSetWidth(grandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandChild, 10); YGNodeInsertChild(grandChild, grandGrandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { const YGNodeRef grandGrandGrandChild = YGNodeNew(); YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); - YGNodeStyleSetWidth(grandGrandGrandChild, YGPx(10)); - YGNodeStyleSetHeight(grandGrandGrandChild, YGPx(10)); + YGNodeStyleSetWidth(grandGrandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandGrandChild, 10); YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0); } } diff --git a/enums.py b/enums.py index c8caf95b..0eaca23d 100644 --- a/enums.py +++ b/enums.py @@ -18,6 +18,7 @@ ENUMS = { 'RTL', ], 'Unit': [ + 'Undefined', 'Pixel', 'Percent', ], diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index b66eb10a..008a5b32 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -12,14 +12,11 @@ function toValueCpp(value) { return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); } -function toValueCppCpp(value) { - var methodName = ''; - if(value.indexOf('px') >= 0){ - methodName = 'YGPx'; - }else if (value.indexOf('%') >= 0){ - methodName = 'YGPercent'; +function toFunctionName(value) { + if (value.indexOf('%') >= 0){ + return 'Percent'; } - return methodName + '(' + toValueCpp(value) + ')'; + return ''; } var CPPEmitter = function() { @@ -164,7 +161,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetFlexBasis' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -184,7 +181,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -192,23 +189,23 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMargin' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMaxHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMaxWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMinHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetMinWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -216,11 +213,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetPadding' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetPosition' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -228,6 +225,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toValueCppCpp(value) + ');'); + this.push('YGNodeStyleSetWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');'); }}, }); diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index 9187c37b..c5a3891b 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -14,15 +14,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -53,15 +53,15 @@ TEST(YogaTest, absolute_layout_width_height_start_top) { TEST(YogaTest, absolute_layout_width_height_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -92,15 +92,15 @@ TEST(YogaTest, absolute_layout_width_height_end_bottom) { TEST(YogaTest, absolute_layout_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -131,17 +131,17 @@ TEST(YogaTest, absolute_layout_start_top_end_bottom) { TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -174,18 +174,18 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowHidden); - YGNodeStyleSetWidth(root, YGPx(50)); - YGNodeStyleSetHeight(root, YGPx(50)); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeStart, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(100)); + YGNodeStyleSetWidth(root_child0_child0, 100); + YGNodeStyleSetHeight(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -226,35 +226,35 @@ TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hi TEST(YogaTest, absolute_layout_within_border) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMargin(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetMargin(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetMargin(root, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root, YGEdgeTop, 10); + YGNodeStyleSetMargin(root, YGEdgeRight, 10); + YGNodeStyleSetMargin(root, YGEdgeBottom, 10); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); YGNodeStyleSetBorder(root, YGEdgeLeft, 10); YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child1, YGEdgeRight, YGPx(0)); - YGNodeStyleSetPosition(root_child1, YGEdgeBottom, YGPx(0)); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index d5e09f93..6c2aaa40 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -15,32 +15,32 @@ TEST(YogaTest, align_content_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -113,32 +113,32 @@ TEST(YogaTest, align_content_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -211,32 +211,32 @@ TEST(YogaTest, align_content_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); - YGNodeStyleSetHeight(root_child3, YGPx(10)); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); - YGNodeStyleSetHeight(root_child4, YGPx(10)); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,27 +309,27 @@ TEST(YogaTest, align_content_stretch) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignContent(root, YGAlignStretch); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(50)); + YGNodeStyleSetWidth(root_child3, 50); YGNodeInsertChild(root, root_child3, 3); const YGNodeRef root_child4 = YGNodeNew(); - YGNodeStyleSetWidth(root_child4, YGPx(50)); + YGNodeStyleSetWidth(root_child4, 50); YGNodeInsertChild(root, root_child4, 4); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index 90a7cee6..e80ae1d4 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -14,11 +14,11 @@ TEST(YogaTest, align_items_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -50,12 +50,12 @@ TEST(YogaTest, align_items_stretch) { TEST(YogaTest, align_items_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, align_items_center) { TEST(YogaTest, align_items_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -124,12 +124,12 @@ TEST(YogaTest, align_items_flex_start) { TEST(YogaTest, align_items_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index 6293c725..436d78b4 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -14,13 +14,13 @@ TEST(YogaTest, align_self_center) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,13 +51,13 @@ TEST(YogaTest, align_self_center) { TEST(YogaTest, align_self_flex_end) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -88,13 +88,13 @@ TEST(YogaTest, align_self_flex_end) { TEST(YogaTest, align_self_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,13 +126,13 @@ TEST(YogaTest, align_self_flex_start) { TEST(YogaTest, align_self_flex_end_override_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 3b8743e1..41673414 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -43,8 +43,8 @@ TEST(YogaTest, border_container_match_child) { YGNodeStyleSetBorder(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -79,12 +79,12 @@ TEST(YogaTest, border_flex_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -119,11 +119,11 @@ TEST(YogaTest, border_stretch_child) { YGNodeStyleSetBorder(root, YGEdgeTop, 10); YGNodeStyleSetBorder(root, YGEdgeRight, 10); YGNodeStyleSetBorder(root, YGEdgeBottom, 10); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -159,12 +159,12 @@ TEST(YogaTest, border_center_child) { YGNodeStyleSetBorder(root, YGEdgeStart, 10); YGNodeStyleSetBorder(root, YGEdgeEnd, 20); YGNodeStyleSetBorder(root, YGEdgeBottom, 20); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp index e5035835..3888966e 100644 --- a/tests/YGDirtyMarkingTest.cpp +++ b/tests/YGDirtyMarkingTest.cpp @@ -13,22 +13,22 @@ TEST(YogaTest, dirty_propagation) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 20); EXPECT_TRUE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -46,22 +46,22 @@ TEST(YogaTest, dirty_propagation) { TEST(YogaTest, dirty_propagation_only_if_prop_changed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); EXPECT_FALSE(YGNodeIsDirty(root_child0)); EXPECT_FALSE(YGNodeIsDirty(root_child1)); @@ -73,12 +73,12 @@ TEST(YogaTest, dirty_propagation_only_if_prop_changed) { TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(50)); - YGNodeStyleSetHeight(root, YGPx(50)); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); const YGNodeRef child0 = YGNodeNew(); - YGNodeStyleSetWidth(child0, YGPx(50)); - YGNodeStyleSetHeight(child0, YGPx(25)); + YGNodeStyleSetWidth(child0, 50); + YGNodeStyleSetHeight(child0, 25); YGNodeInsertChild(root, child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index df6a0a55..4122b11b 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -13,14 +13,14 @@ TEST(YogaTest, start_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -37,14 +37,14 @@ TEST(YogaTest, start_overrides) { TEST(YogaTest, end_overrides) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -61,13 +61,13 @@ TEST(YogaTest, end_overrides) { TEST(YogaTest, horizontal_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,13 +80,13 @@ TEST(YogaTest, horizontal_overridden) { TEST(YogaTest, vertical_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -99,13 +99,13 @@ TEST(YogaTest, vertical_overridden) { TEST(YogaTest, horizontal_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -120,13 +120,13 @@ TEST(YogaTest, horizontal_overrides_all) { TEST(YogaTest, vertical_overrides_all) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeVertical, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -141,16 +141,16 @@ TEST(YogaTest, vertical_overrides_all) { TEST(YogaTest, all_overridden) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeAll, YGPx(20)); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index 30cb2a4b..b6016428 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -14,18 +14,18 @@ TEST(YogaTest, flex_direction_column_no_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -77,18 +77,18 @@ TEST(YogaTest, flex_direction_column_no_height) { TEST(YogaTest, flex_direction_row_no_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -139,19 +139,19 @@ TEST(YogaTest, flex_direction_row_no_width) { TEST(YogaTest, flex_direction_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -203,19 +203,19 @@ TEST(YogaTest, flex_direction_column) { TEST(YogaTest, flex_direction_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -267,19 +267,19 @@ TEST(YogaTest, flex_direction_row) { TEST(YogaTest, flex_direction_column_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,19 +331,19 @@ TEST(YogaTest, flex_direction_column_reverse) { TEST(YogaTest, flex_direction_row_reverse) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index 69cf569a..559025f7 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -65,12 +65,12 @@ TEST(YogaTest, flex_basis_flex_grow_column) { TEST(YogaTest, flex_basis_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -115,16 +115,16 @@ TEST(YogaTest, flex_basis_flex_grow_row) { TEST(YogaTest, flex_basis_flex_shrink_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -166,16 +166,16 @@ TEST(YogaTest, flex_basis_flex_shrink_column) { TEST(YogaTest, flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -216,22 +216,22 @@ TEST(YogaTest, flex_basis_flex_shrink_row) { TEST(YogaTest, flex_shrink_to_zero) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, YGPx(75)); + YGNodeStyleSetHeight(root, 75); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child1, 1); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -282,23 +282,23 @@ TEST(YogaTest, flex_shrink_to_zero) { TEST(YogaTest, flex_basis_overrides_main_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -349,8 +349,8 @@ TEST(YogaTest, flex_basis_overrides_main_size) { TEST(YogaTest, flex_grow_shrink_at_most) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeInsertChild(root, root_child0, 0); diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index 32e86a6e..03d07a82 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -15,26 +15,26 @@ TEST(YogaTest, wrap_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -97,26 +97,26 @@ TEST(YogaTest, wrap_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(30)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(30)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -180,26 +180,26 @@ TEST(YogaTest, wrap_row_align_items_flex_end) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -263,26 +263,26 @@ TEST(YogaTest, wrap_row_align_items_center) { YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignCenter); YGNodeStyleSetFlexWrap(root, YGWrapWrap); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(30)); - YGNodeStyleSetHeight(root_child1, YGPx(20)); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(30)); - YGNodeStyleSetHeight(root_child2, YGPx(30)); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); YGNodeInsertChild(root, root_child2, 2); const YGNodeRef root_child3 = YGNodeNew(); - YGNodeStyleSetWidth(root_child3, YGPx(30)); - YGNodeStyleSetHeight(root_child3, YGPx(30)); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); YGNodeInsertChild(root, root_child3, 3); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index 260d3914..b7afe1b6 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -15,19 +15,19 @@ TEST(YogaTest, justify_content_row_flex_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -80,19 +80,19 @@ TEST(YogaTest, justify_content_row_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -145,19 +145,19 @@ TEST(YogaTest, justify_content_row_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -210,19 +210,19 @@ TEST(YogaTest, justify_content_row_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -275,19 +275,19 @@ TEST(YogaTest, justify_content_row_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(10)); + YGNodeStyleSetWidth(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(10)); + YGNodeStyleSetWidth(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -338,18 +338,18 @@ TEST(YogaTest, justify_content_row_space_around) { TEST(YogaTest, justify_content_column_flex_start) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -401,19 +401,19 @@ TEST(YogaTest, justify_content_column_flex_start) { TEST(YogaTest, justify_content_column_flex_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -465,19 +465,19 @@ TEST(YogaTest, justify_content_column_flex_end) { TEST(YogaTest, justify_content_column_center) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -529,19 +529,19 @@ TEST(YogaTest, justify_content_column_center) { TEST(YogaTest, justify_content_column_space_between) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -593,19 +593,19 @@ TEST(YogaTest, justify_content_column_space_between) { TEST(YogaTest, justify_content_column_space_around) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - YGNodeStyleSetWidth(root, YGPx(102)); - YGNodeStyleSetHeight(root, YGPx(102)); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index 17de3e78..724b2eef 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -15,12 +15,12 @@ TEST(YogaTest, margin_start) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, margin_start) { TEST(YogaTest, margin_top) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -89,12 +89,12 @@ TEST(YogaTest, margin_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeEnd, YGPx(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -126,12 +126,12 @@ TEST(YogaTest, margin_end) { TEST(YogaTest, margin_bottom) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -163,12 +163,12 @@ TEST(YogaTest, margin_bottom) { TEST(YogaTest, margin_and_flex_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,12 +199,12 @@ TEST(YogaTest, margin_and_flex_row) { TEST(YogaTest, margin_and_flex_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -236,12 +236,12 @@ TEST(YogaTest, margin_and_flex_column) { TEST(YogaTest, margin_and_stretch_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -272,12 +272,12 @@ TEST(YogaTest, margin_and_stretch_row) { TEST(YogaTest, margin_and_stretch_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeStart, YGPx(10)); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -309,8 +309,8 @@ TEST(YogaTest, margin_and_stretch_column) { TEST(YogaTest, margin_with_sibling_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -358,8 +358,8 @@ TEST(YogaTest, margin_with_sibling_row) { TEST(YogaTest, margin_with_sibling_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 00df60e3..b1463e52 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -14,12 +14,12 @@ TEST(YogaTest, max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetMaxWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -51,12 +51,12 @@ TEST(YogaTest, max_width) { TEST(YogaTest, max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetMaxHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -87,12 +87,12 @@ TEST(YogaTest, max_height) { TEST(YogaTest, min_height) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeight(root_child0, YGPx(60)); + YGNodeStyleSetMinHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -138,12 +138,12 @@ TEST(YogaTest, min_height) { TEST(YogaTest, min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinWidth(root_child0, YGPx(60)); + YGNodeStyleSetMinWidth(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); @@ -189,13 +189,13 @@ TEST(YogaTest, min_width) { TEST(YogaTest, justify_content_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetMinHeight(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(60)); - YGNodeStyleSetHeight(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -227,13 +227,13 @@ TEST(YogaTest, justify_content_min_max) { TEST(YogaTest, align_items_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetMinWidth(root, YGPx(100)); - YGNodeStyleSetMaxWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetMaxWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(60)); - YGNodeStyleSetHeight(root_child0, YGPx(60)); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -265,22 +265,22 @@ TEST(YogaTest, align_items_min_max) { TEST(YogaTest, justify_content_overflow_min_max) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); - YGNodeStyleSetMinHeight(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(110)); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 110); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetWidth(root_child2, YGPx(50)); - YGNodeStyleSetHeight(root_child2, YGPx(50)); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -331,17 +331,17 @@ TEST(YogaTest, justify_content_overflow_min_max) { TEST(YogaTest, flex_grow_within_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); + YGNodeStyleSetMaxWidth(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -382,17 +382,17 @@ TEST(YogaTest, flex_grow_within_max_width) { TEST(YogaTest, flex_grow_within_constrained_max_width) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(300)); + YGNodeStyleSetMaxWidth(root_child0, 300); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetHeight(root_child0_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0_child0, 20); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -434,15 +434,15 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) { TEST(YogaTest, flex_grow_within_constrained_min_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetMinWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -483,14 +483,14 @@ TEST(YogaTest, flex_grow_within_constrained_min_row) { TEST(YogaTest, flex_grow_within_constrained_min_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetMinHeight(root, YGPx(100)); + YGNodeStyleSetMinHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -531,21 +531,21 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) { TEST(YogaTest, flex_grow_within_constrained_max_row) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - YGNodeStyleSetMaxWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(100)); + YGNodeStyleSetMaxWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0_child0, 100); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child1, YGPx(50)); + YGNodeStyleSetWidth(root_child0_child1, 50); YGNodeInsertChild(root_child0, root_child0_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -596,16 +596,16 @@ TEST(YogaTest, flex_grow_within_constrained_max_row) { TEST(YogaTest, flex_grow_within_constrained_max_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetMaxHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMaxHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(50)); + YGNodeStyleSetHeight(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index 9fe33ac0..aab6726b 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -14,10 +14,10 @@ TEST(YogaTest, padding_no_size) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); @@ -37,14 +37,14 @@ TEST(YogaTest, padding_no_size) { TEST(YogaTest, padding_container_match_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -75,16 +75,16 @@ TEST(YogaTest, padding_container_match_child) { TEST(YogaTest, padding_flex_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetWidth(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -115,15 +115,15 @@ TEST(YogaTest, padding_flex_child) { TEST(YogaTest, padding_stretch_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPadding(root, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeRight, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(10)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -156,15 +156,15 @@ TEST(YogaTest, padding_center_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyCenter); YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetPadding(root, YGEdgeStart, YGPx(10)); - YGNodeStyleSetPadding(root, YGEdgeEnd, YGPx(20)); - YGNodeStyleSetPadding(root, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetPadding(root, YGEdgeStart, 10); + YGNodeStyleSetPadding(root, YGEdgeEnd, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -197,16 +197,16 @@ TEST(YogaTest, child_with_padding_align_end) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(20)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(20)); - YGNodeStyleSetWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(100)); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp index 9d16db6f..80d2f4f7 100644 --- a/tests/YGPercentageTest.cpp +++ b/tests/YGPercentageTest.cpp @@ -17,12 +17,12 @@ TEST(YogaTest, percentage_width_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPercent(30)); - YGNodeStyleSetHeight(root_child0, YGPercent(30)); + YGNodeStyleSetWidthPercent(root_child0, 30); + YGNodeStyleSetHeightPercent(root_child0, 30); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -58,14 +58,14 @@ TEST(YogaTest, percentage_position_left_top) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(400)); - YGNodeStyleSetHeight(root, YGPx(400)); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(20)); - YGNodeStyleSetWidth(root_child0, YGPercent(45)); - YGNodeStyleSetHeight(root_child0, YGPercent(55)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20); + YGNodeStyleSetWidthPercent(root_child0, 45); + YGNodeStyleSetHeightPercent(root_child0, 55); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -101,14 +101,14 @@ TEST(YogaTest, percentage_position_bottom_right) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(500)); - YGNodeStyleSetHeight(root, YGPx(500)); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 500); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetPosition(root_child0, YGEdgeRight, YGPercent(20)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPercent(10)); - YGNodeStyleSetWidth(root_child0, YGPercent(55)); - YGNodeStyleSetHeight(root_child0, YGPercent(15)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidthPercent(root_child0, 55); + YGNodeStyleSetHeightPercent(root_child0, 15); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -144,17 +144,17 @@ TEST(YogaTest, percentage_flex_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -199,17 +199,17 @@ TEST(YogaTest, percentage_flex_basis_cross) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(50)); + YGNodeStyleSetFlexBasisPercent(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(25)); + YGNodeStyleSetFlexBasisPercent(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -254,17 +254,17 @@ TEST(YogaTest, percentage_flex_basis_cross_min_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMinHeight(root_child0, YGPercent(60)); + YGNodeStyleSetMinHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 2); - YGNodeStyleSetMinHeight(root_child1, YGPercent(10)); + YGNodeStyleSetMinHeightPercent(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -310,19 +310,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_height) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxHeightPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -367,19 +367,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_height) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxHeightPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxHeight(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxHeightPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -425,19 +425,19 @@ TEST(YogaTest, percentage_flex_basis_main_max_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); - YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 15); + YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMaxWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -482,19 +482,19 @@ TEST(YogaTest, percentage_flex_basis_cross_max_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMaxWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMaxWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMaxWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMaxWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -540,19 +540,19 @@ TEST(YogaTest, percentage_flex_basis_main_min_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 15); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(10)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 10); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -597,19 +597,19 @@ TEST(YogaTest, percentage_flex_basis_cross_min_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -654,51 +654,51 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetMinWidth(root_child0, YGPercent(60)); + YGNodeStyleSetFlexBasisPercent(root_child0, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetMinWidthPercent(root_child0, 60); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, YGPx(5)); - YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, YGPx(5)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, YGPercent(3)); - YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, YGPercent(3)); - YGNodeStyleSetWidth(root_child0_child0, YGPercent(50)); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0, 50); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child0_child0 = YGNodeNew(); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeLeft, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeTop, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeRight, YGPercent(5)); - YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeBottom, YGPercent(5)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, YGPx(3)); - YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, YGPx(3)); - YGNodeStyleSetWidth(root_child0_child0_child0, YGPercent(45)); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45); YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 4); - YGNodeStyleSetFlexBasis(root_child1, YGPercent(15)); - YGNodeStyleSetMinWidth(root_child1, YGPercent(20)); + YGNodeStyleSetFlexBasisPercent(root_child1, 15); + YGNodeStyleSetMinWidthPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -763,20 +763,20 @@ TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetMargin(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetMargin(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -821,20 +821,20 @@ TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetPadding(root_child0, YGEdgeLeft, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeRight, YGPercent(10)); - YGNodeStyleSetPadding(root_child0, YGEdgeBottom, YGPercent(10)); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(10)); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -879,15 +879,15 @@ TEST(YogaTest, percentage_absolute_position) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPercent(30)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPercent(10)); - YGNodeStyleSetWidth(root_child0, YGPx(10)); - YGNodeStyleSetHeight(root_child0, YGPx(10)); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRelayoutTest.cpp b/tests/YGRelayoutTest.cpp index b637d17c..de298325 100644 --- a/tests/YGRelayoutTest.cpp +++ b/tests/YGRelayoutTest.cpp @@ -16,8 +16,8 @@ TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { const YGNodeRef root = YGNodeNew(); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(10)); - YGNodeStyleSetFlexBasis(root_child0, YGPx(20)); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetFlexBasis(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index aaad141c..0ce9f5c0 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -17,8 +17,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -85,8 +85,8 @@ TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(113)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 113); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -181,20 +181,20 @@ TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(101)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 101); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(100)); + YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child1, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child1, 25); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child2, YGPx(25)); + YGNodeStyleSetFlexBasis(root_child2, 25); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -249,23 +249,23 @@ TEST(YogaTest, rounding_flex_basis_overrides_main_size) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -320,23 +320,23 @@ TEST(YogaTest, rounding_total_fractial) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(87.4f)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -391,37 +391,37 @@ TEST(YogaTest, rounding_total_fractial_nested) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(87.4f)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 0.7f); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50.3f)); - YGNodeStyleSetHeight(root_child0, YGPx(20.3f)); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child0_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexBasis(root_child0_child0, YGPx(0.3f)); - YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, YGPx(13.3f)); - YGNodeStyleSetHeight(root_child0_child0, YGPx(9.9f)); + YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); + YGNodeStyleSetHeight(root_child0_child0, 9.9f); YGNodeInsertChild(root_child0, root_child0_child0, 0); const YGNodeRef root_child0_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0_child1, 4); - YGNodeStyleSetFlexBasis(root_child0_child1, YGPx(0.3f)); - YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, YGPx(13.3f)); - YGNodeStyleSetHeight(root_child0_child1, YGPx(1.1f)); + YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f); + YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); + YGNodeStyleSetHeight(root_child0_child1, 1.1f); YGNodeInsertChild(root_child0, root_child0_child1, 1); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1.6f); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1.1f); - YGNodeStyleSetHeight(root_child2, YGPx(10.7f)); + YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -496,23 +496,23 @@ TEST(YogaTest, rounding_fractial_input_1) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -567,23 +567,23 @@ TEST(YogaTest, rounding_fractial_input_2) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.6f)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.6f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -638,24 +638,24 @@ TEST(YogaTest, rounding_fractial_input_3) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.3f)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -710,24 +710,24 @@ TEST(YogaTest, rounding_fractial_input_4) { YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetPosition(root, YGEdgeTop, YGPx(0.7f)); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(113.4f)); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(20)); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child1, 1); - YGNodeStyleSetHeight(root_child1, YGPx(10)); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child2, 1); - YGNodeStyleSetHeight(root_child2, YGPx(10)); + YGNodeStyleSetHeight(root_child2, 10); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 7f3af522..c1428afc 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -21,8 +21,9 @@ typedef enum YGFlexDirection { YGFlexDirectionRowReverse, } YGFlexDirection; -#define YGUnitCount 2 +#define YGUnitCount 3 typedef enum YGUnit { + YGUnitUndefined, YGUnitPixel, YGUnitPercent, } YGUnit; diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 64cf4ebb..90d1a5d9 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -106,6 +106,11 @@ typedef struct YGNode { void *context; } YGNode; +#define YG_UNDEFINED_VALUES { \ + .value = YGUndefined, \ + .unit = YGUnitUndefined \ +} + #define YG_DEFAULT_EDGE_VALUES { \ [YGEdgeLeft] = YGUndefined, \ [YGEdgeTop] = YGUndefined, \ @@ -118,11 +123,28 @@ typedef struct YGNode { [YGEdgeAll] = YGUndefined, \ } +#define YG_DEFAULT_EDGE_VALUES_UNIT { \ + [YGEdgeLeft] = YG_UNDEFINED_VALUES, \ + [YGEdgeTop] = YG_UNDEFINED_VALUES, \ + [YGEdgeRight] = YG_UNDEFINED_VALUES, \ + [YGEdgeBottom] = YG_UNDEFINED_VALUES, \ + [YGEdgeStart] = YG_UNDEFINED_VALUES, \ + [YGEdgeEnd] = YG_UNDEFINED_VALUES, \ + [YGEdgeHorizontal] = YG_UNDEFINED_VALUES, \ + [YGEdgeVertical] = YG_UNDEFINED_VALUES, \ + [YGEdgeAll] = YG_UNDEFINED_VALUES, \ +} + #define YG_DEFAULT_DIMENSION_VALUES { \ [YGDimensionWidth] = YGUndefined, \ [YGDimensionHeight] = YGUndefined, \ } +#define YG_DEFAULT_DIMENSION_VALUES_UNIT { \ + [YGDimensionWidth] = YG_UNDEFINED_VALUES, \ + [YGDimensionHeight] = YG_UNDEFINED_VALUES, \ +} + YGNode gYGNodeDefaults = { .parent = NULL, .children = NULL, @@ -133,19 +155,19 @@ YGNode gYGNodeDefaults = { .flex = YGUndefined, .flexGrow = YGUndefined, .flexShrink = YGUndefined, - .flexBasis = YGUndefined, + .flexBasis = YG_UNDEFINED_VALUES, .justifyContent = YGJustifyFlexStart, .alignItems = YGAlignStretch, .alignContent = YGAlignFlexStart, .direction = YGDirectionInherit, .flexDirection = YGFlexDirectionColumn, .overflow = YGOverflowVisible, - .dimensions = YG_DEFAULT_DIMENSION_VALUES, - .minDimensions = YG_DEFAULT_DIMENSION_VALUES, - .maxDimensions = YG_DEFAULT_DIMENSION_VALUES, - .position = YG_DEFAULT_EDGE_VALUES, - .margin = YG_DEFAULT_EDGE_VALUES, - .padding = YG_DEFAULT_EDGE_VALUES, + .dimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT, + .position = YG_DEFAULT_EDGE_VALUES_UNIT, + .margin = YG_DEFAULT_EDGE_VALUES_UNIT, + .padding = YG_DEFAULT_EDGE_VALUES_UNIT, .border = YG_DEFAULT_EDGE_VALUES, .aspectRatio = YGUndefined, }, @@ -175,13 +197,11 @@ YGFree gYGFree = &free; static YGValue YGValueUndefined = { .value = YGUndefined, - .isDefined = false, - .unit = YGUnitPixel + .unit = YGUnitUndefined }; static YGValue YGValueZero = { .value = 0, - .isDefined = true, .unit = YGUnitPixel }; @@ -231,20 +251,20 @@ static inline const YGValue * YGComputedEdgeValue(const YGValue edges[YGEdgeCoun const YGValue * const defaultValue) { YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (edges[edge].isDefined) { + if (edges[edge].unit != YGUnitUndefined) { return &edges[edge]; } - if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].isDefined) { + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && edges[YGEdgeVertical].unit != YGUnitUndefined) { return &edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && - edges[YGEdgeHorizontal].isDefined) { + edges[YGEdgeHorizontal].unit != YGUnitUndefined) { return &edges[YGEdgeHorizontal]; } - if (edges[YGEdgeAll].isDefined) { + if (edges[YGEdgeAll].unit != YGUnitUndefined) { return &edges[YGEdgeAll]; } @@ -265,24 +285,6 @@ static inline float YGValueResolve(const YGValue * const unit, const float paren int32_t gNodeInstanceCount = 0; -YGValue YGPx(const float value){ - YGValue result = { - .value = value, - .isDefined = !YGFloatIsUndefined(value), - .unit = YGUnitPixel, - }; - return result; -} - -YGValue YGPercent(const float value){ - YGValue result = { - .value = value, - .isDefined = !YGFloatIsUndefined(value), - .unit = YGUnitPercent, - }; - return result; -} - YGNodeRef YGNodeNew(void) { const YGNodeRef node = gYGMalloc(sizeof(YGNode)); YG_ASSERT(node, "Could not allocate memory for node"); @@ -421,7 +423,7 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { } static inline const YGValue * YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) { - if (node->style.flexBasis.isDefined) { + if (node->style.flexBasis.unit != YGUnitUndefined) { return &node->style.flexBasis; } if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) { @@ -460,10 +462,17 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ - if (node->style.instanceName.value != paramName.value || node->style.instanceName.unit != paramName.unit) { \ - node->style.instanceName.value = paramName.value; \ - node->style.instanceName.isDefined = !YGFloatIsUndefined(paramName.value); \ - node->style.instanceName.unit = paramName.unit; \ + if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPixel) { \ + node->style.instanceName.value = paramName; \ + node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const type paramName) { \ + if (node->style.instanceName.value != paramName || node->style.instanceName.unit != YGUnitPercent) { \ + node->style.instanceName.value = paramName; \ + node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } @@ -476,18 +485,25 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { } #define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ - YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(float, name, paramName, instanceName) \ \ type YGNodeStyleGet##name(const YGNodeRef node) { \ return node->style.instanceName; \ } #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName, defaultValue) \ - void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const type paramName) { \ - if (node->style.instanceName[edge].value != paramName.value || node->style.instanceName[edge].unit != paramName.unit ) { \ - node->style.instanceName[edge].value = paramName.value; \ - node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName.value); \ - node->style.instanceName[edge].unit = paramName.unit; \ + void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPercent ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -501,8 +517,15 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPixel ) { \ node->style.instanceName[edge].value = paramName; \ - node->style.instanceName[edge].isDefined = !YGFloatIsUndefined(paramName); \ - node->style.instanceName[edge].unit = YGUnitPixel; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGNodeMarkDirtyInternal(node); \ + } \ + } \ + \ + void YGNodeStyleSet##name##Percent(const YGNodeRef node, const YGEdge edge, const float paramName) { \ + if (node->style.instanceName[edge].value != paramName || node->style.instanceName[edge].unit != YGUnitPercent ) { \ + node->style.instanceName[edge].value = paramName; \ + node->style.instanceName[edge].unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -532,7 +555,7 @@ YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink); -YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(YGValue, FlexBasis, flexBasis, flexBasis); +YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(float, FlexBasis, flexBasis, flexBasis); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position, YGValueUndefined); YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin, YGValueZero); @@ -575,7 +598,7 @@ inline bool YGFloatIsUndefined(const float value) { } static inline bool YGValueEqual(const YGValue a, const YGValue b) { - if (a.isDefined != b.isDefined || a.unit != b.unit) { + if (a.unit != YGUnitUndefined != b.unit != YGUnitUndefined || a.unit != b.unit) { return false; } @@ -608,7 +631,7 @@ static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) { } static void YGPrintNumberIfNotUndefined(const char *str, const YGValue * const number) { - if (number->isDefined) { + if (number->unit != YGUnitUndefined) { YGLog(YGLogLevelDebug, "%s: %g%s, ", str, number->value, number->unit == YGUnitPixel ? "px" : "%"); } } @@ -797,7 +820,7 @@ static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) } static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].isDefined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].unit != YGUnitUndefined) { return YGValueResolve(&node->style.margin[YGEdgeStart], widthSize); } @@ -805,7 +828,7 @@ static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirect } static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].isDefined) { + if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].unit != YGUnitUndefined) { return YGValueResolve(&node->style.margin[YGEdgeEnd], widthSize); } @@ -813,7 +836,7 @@ static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].unit != YGUnitUndefined && YGValueResolve(&node->style.padding[YGEdgeStart], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeStart], widthSize); } @@ -822,7 +845,7 @@ static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection ax } static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].unit != YGUnitUndefined && YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize) >= 0.0f) { return YGValueResolve(&node->style.padding[YGEdgeEnd], widthSize); } @@ -831,7 +854,7 @@ static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection a } static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].unit != YGUnitUndefined && node->style.border[YGEdgeStart].value >= 0.0f) { return node->style.border[YGEdgeStart].value; } @@ -840,7 +863,7 @@ static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axi } static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { - if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].isDefined && + if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].unit != YGUnitUndefined && node->style.border[YGEdgeEnd].value >= 0.0f) { return node->style.border[YGEdgeEnd].value; } @@ -911,7 +934,7 @@ static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirect } static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { - return node->style.dimensions[dim[axis]].isDefined && node->style.dimensions[dim[axis]].value >= 0.0f; + return node->style.dimensions[dim[axis]].unit != YGUnitUndefined && node->style.dimensions[dim[axis]].value >= 0.0f; } static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { @@ -921,21 +944,21 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->isDefined) || - YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->unit != YGUnitUndefined) || + YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->unit != YGUnitUndefined; } static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) { return (YGFlexDirectionIsRow(axis) && - YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->isDefined) || - YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->isDefined; + YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->unit != YGUnitUndefined) || + YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->unit != YGUnitUndefined; } static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined); - if (leadingPosition->isDefined) { + if (leadingPosition->unit != YGUnitUndefined) { return YGValueResolve(leadingPosition, axisSize); } } @@ -943,14 +966,14 @@ static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection a const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined); - return !leadingPosition->isDefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); + return !leadingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { if (YGFlexDirectionIsRow(axis)) { const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined); - if (trailingPosition->isDefined) { + if (trailingPosition->unit != YGUnitUndefined) { return YGValueResolve(trailingPosition, axisSize); } } @@ -958,7 +981,7 @@ static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined); - return !trailingPosition->isDefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); + return !trailingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, @@ -1066,7 +1089,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (YGNodeStyleGetFlexBasisPtr(child)->isDefined && + if (YGNodeStyleGetFlexBasisPtr(child)->unit != YGUnitUndefined && !YGFloatIsUndefined(mainAxisSize)) { if (YGFloatIsUndefined(child->layout.computedFlexBasis) || (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && @@ -2026,7 +2049,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // constraint by the min size defined for the main axis. if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { - if (node->style.minDimensions[dim[mainAxis]].isDefined && + if (node->style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined && YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) { remainingFreeSpace = fmaxf(0, YGValueResolve(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) - diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 7172f9ea..095cece1 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -41,12 +41,8 @@ typedef struct YGSize { typedef struct YGValue { float value; YGUnit unit; - bool isDefined; } YGValue; -WIN_EXPORT YGValue YGPx(const float value); -WIN_EXPORT YGValue YGPercent(const float value); - typedef struct YGNode *YGNodeRef; typedef YGSize (*YGMeasureFunc)(YGNodeRef node, float width, @@ -118,7 +114,8 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ - WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ + WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \ + WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ @@ -130,7 +127,10 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ const YGEdge edge, \ - const type paramName); \ + const float paramName); \ + WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \ + const YGEdge edge, \ + const float paramName); \ WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_LAYOUT_PROPERTY(type, name) \ -- 2.50.1.windows.1 From d44ebab006be1114cc88890a563edb7b862ba0a3 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 22:33:06 +0100 Subject: [PATCH 34/39] changed the csharp interop code to use new functions --- csharp/Facebook.Yoga/Native.cs | 50 +++++++++--- csharp/Facebook.Yoga/YogaConstants.cs | 2 +- csharp/Facebook.Yoga/YogaNode.cs | 94 +++++++++++++++++++--- csharp/Facebook.Yoga/YogaUnit.cs | 1 + csharp/Facebook.Yoga/YogaValue.cs | 25 +++--- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 2 +- yoga/Yoga.c | 14 ++-- 7 files changed, 144 insertions(+), 44 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index a1cc0437..0f8d58cd 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -194,43 +194,64 @@ namespace Facebook.Yoga public static extern float YGNodeStyleGetFlexShrink(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, YogaValue flexBasis); + public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetFlexBasisPercent(YGNodeHandle node, float flexBasis); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetWidth(YGNodeHandle node, YogaValue width); + public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetWidthPercent(YGNodeHandle node, float width); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetHeight(YGNodeHandle node, YogaValue height); + public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, YogaValue minWidth); + public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, YogaValue minHeight); + public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, YogaValue maxWidth); + public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, YogaValue maxHeight); + public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node); @@ -246,19 +267,28 @@ namespace Facebook.Yoga #region YG_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName)] - public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, YogaValue position); + public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, YogaValue margin); + public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetMarginPercent(YGNodeHandle node, YogaEdge edge, float margin); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, YogaValue padding); + public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); + + [DllImport(DllName)] + public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding); [DllImport(DllName)] public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); diff --git a/csharp/Facebook.Yoga/YogaConstants.cs b/csharp/Facebook.Yoga/YogaConstants.cs index 76e51f9c..ca8ecfbb 100644 --- a/csharp/Facebook.Yoga/YogaConstants.cs +++ b/csharp/Facebook.Yoga/YogaConstants.cs @@ -20,7 +20,7 @@ namespace Facebook.Yoga public static bool IsUndefined(YogaValue value) { - return !value.IsDefined; + return value.Unit == YogaUnit.Undefined; } } } diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 02b1954c..7395102d 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -236,7 +236,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetFlexBasis(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetFlexBasisPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetFlexBasis(_ygNode, value.Value); + } } } @@ -247,7 +254,14 @@ namespace Facebook.Yoga public void SetMargin(YogaEdge edge, YogaValue value) { - Native.YGNodeStyleSetMargin(_ygNode, edge, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value); + } } public YogaValue GetPadding(YogaEdge edge) @@ -255,9 +269,16 @@ namespace Facebook.Yoga return Native.YGNodeStyleGetPadding(_ygNode, edge); } - public void SetPadding(YogaEdge edge, YogaValue padding) + public void SetPadding(YogaEdge edge, YogaValue value) { - Native.YGNodeStyleSetPadding(_ygNode, edge, padding); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value); + } } public float GetBorder(YogaEdge edge) @@ -275,9 +296,16 @@ namespace Facebook.Yoga return Native.YGNodeStyleGetPosition(_ygNode, edge); } - public void SetPosition(YogaEdge edge, YogaValue position) + public void SetPosition(YogaEdge edge, YogaValue value) { - Native.YGNodeStyleSetPosition(_ygNode, edge, position); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value); + } } public YogaValue Width @@ -289,7 +317,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetWidth(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetWidthPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetWidth(_ygNode, value.Value); + } } } @@ -302,7 +337,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetHeight(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetHeightPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetHeight(_ygNode, value.Value); + } } } @@ -315,7 +357,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetMaxWidth(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMaxWidthPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetMaxWidth(_ygNode, value.Value); + } } } @@ -328,7 +377,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetMaxHeight(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMaxHeightPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetMaxHeight(_ygNode, value.Value); + } } } @@ -341,7 +397,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetMinWidth(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMinWidthPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetMinWidth(_ygNode, value.Value); + } } } @@ -354,7 +417,14 @@ namespace Facebook.Yoga set { - Native.YGNodeStyleSetMinHeight(_ygNode, value); + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMinHeightPercent(_ygNode, value.Value); + } + else + { + Native.YGNodeStyleSetMinHeight(_ygNode, value.Value); + } } } diff --git a/csharp/Facebook.Yoga/YogaUnit.cs b/csharp/Facebook.Yoga/YogaUnit.cs index 660cb9d6..d8cfe2f8 100644 --- a/csharp/Facebook.Yoga/YogaUnit.cs +++ b/csharp/Facebook.Yoga/YogaUnit.cs @@ -11,6 +11,7 @@ namespace Facebook.Yoga { public enum YogaUnit { + Undefined, Pixel, Percent } diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs index 9e2bc258..055f7d68 100644 --- a/csharp/Facebook.Yoga/YogaValue.cs +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -14,25 +14,24 @@ namespace Facebook.Yoga [StructLayout(LayoutKind.Sequential)] public struct YogaValue { - private float Value; - private YogaUnit Unit; - private byte isDefined; /* use byte to keep struct blitable */ + private float value; + private YogaUnit unit; - public bool IsDefined => isDefined != 0; + public YogaUnit Unit => unit; + public float Value => value; public static YogaValue Pixel(float value) { return new YogaValue { - Value = value, - isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1, - Unit = YogaUnit.Pixel + value = value, + unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel }; } public bool Equals(YogaValue other) { - return Value.Equals(other.Value) && Unit == other.Unit; + return Unit == other.Unit && (Value.Equals(other.Value) || Unit == YogaUnit.Undefined); } public override bool Equals(object obj) @@ -53,9 +52,8 @@ namespace Facebook.Yoga { return new YogaValue { - Value = YogaConstants.Undefined, - isDefined = 0, - Unit = YogaUnit.Pixel + value = YogaConstants.Undefined, + unit = YogaUnit.Undefined }; } @@ -63,9 +61,8 @@ namespace Facebook.Yoga { return new YogaValue { - Value = value, - isDefined = YogaConstants.IsUndefined(value) ? (byte)0 : (byte)1, - Unit = YogaUnit.Percent + value = value, + unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Percent }; } diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index a404c5fc..69c4f177 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -212,7 +212,7 @@ namespace Facebook.Yoga parent.Insert(0, child0); parent.Insert(0, child1); parent.CalculateLayout(); - Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100px, height: 120px, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35px, height: 45px, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30px, height: 40px, },\n]},\n"); + Assert.AreEqual("{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100px, height: 120px, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35px, height: 45px, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30px, height: 40px, },\n]},\n", parent.Print()); } [Test] diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 90d1a5d9..316e77ae 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -145,7 +145,7 @@ typedef struct YGNode { [YGDimensionHeight] = YG_UNDEFINED_VALUES, \ } -YGNode gYGNodeDefaults = { +static YGNode gYGNodeDefaults = { .parent = NULL, .children = NULL, .hasNewLayout = true, @@ -195,10 +195,7 @@ YGCalloc gYGCalloc = &calloc; YGRealloc gYGRealloc = &realloc; YGFree gYGFree = &free; -static YGValue YGValueUndefined = { - .value = YGUndefined, - .unit = YGUnitUndefined -}; +static YGValue YGValueUndefined = YG_UNDEFINED_VALUES; static YGValue YGValueZero = { .value = 0, @@ -598,9 +595,14 @@ inline bool YGFloatIsUndefined(const float value) { } static inline bool YGValueEqual(const YGValue a, const YGValue b) { - if (a.unit != YGUnitUndefined != b.unit != YGUnitUndefined || a.unit != b.unit) { + if (a.unit != b.unit) { return false; } + + if(a.unit == YGUnitUndefined) + { + return true; + } return fabs(a.value - b.value) < 0.0001f; } -- 2.50.1.windows.1 From f9ffe89cbdd7ab73c1132abdd7cd446e7eaf33f3 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 22:53:08 +0100 Subject: [PATCH 35/39] fixed function call signature --- tests/YGAspectRatioTest.cpp | 206 +++++++++++++++++------------------ tests/YGMeasureCacheTest.cpp | 4 +- tests/YGMeasureModeTest.cpp | 38 +++---- tests/YGMeasureTest.cpp | 4 +- tests/YGStyleTest.cpp | 6 +- 5 files changed, 129 insertions(+), 129 deletions(-) diff --git a/tests/YGAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp index 67cc661b..b6e32de2 100644 --- a/tests/YGAspectRatioTest.cpp +++ b/tests/YGAspectRatioTest.cpp @@ -24,11 +24,11 @@ static YGSize _measure(YGNodeRef node, TEST(YogaTest, aspect_ratio_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -45,11 +45,11 @@ TEST(YogaTest, aspect_ratio_cross_defined) { TEST(YogaTest, aspect_ratio_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -67,12 +67,12 @@ TEST(YogaTest, aspect_ratio_both_dimensions_defined_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -89,12 +89,12 @@ TEST(YogaTest, aspect_ratio_both_dimensions_defined_row) { TEST(YogaTest, aspect_ratio_both_dimensions_defined_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(100)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -110,8 +110,8 @@ TEST(YogaTest, aspect_ratio_both_dimensions_defined_column) { TEST(YogaTest, aspect_ratio_align_stretch) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetAspectRatio(root_child0, 1); @@ -130,11 +130,11 @@ TEST(YogaTest, aspect_ratio_align_stretch) { TEST(YogaTest, aspect_ratio_flex_grow) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -152,11 +152,11 @@ TEST(YogaTest, aspect_ratio_flex_grow) { TEST(YogaTest, aspect_ratio_flex_shrink) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(150)); + YGNodeStyleSetHeight(root_child0, 150); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -174,11 +174,11 @@ TEST(YogaTest, aspect_ratio_flex_shrink) { TEST(YogaTest, aspect_ratio_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetFlexBasis(root_child0, YGPx(50)); + YGNodeStyleSetFlexBasis(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -194,14 +194,14 @@ TEST(YogaTest, aspect_ratio_basis) { TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -217,14 +217,14 @@ TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) { TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(0)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(0)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -241,12 +241,12 @@ TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) { TEST(YogaTest, aspect_ratio_with_max_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); - YGNodeStyleSetMaxWidth(root_child0, YGPx(40)); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetMaxWidth(root_child0, 40); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -263,12 +263,12 @@ TEST(YogaTest, aspect_ratio_with_max_cross_defined) { TEST(YogaTest, aspect_ratio_with_max_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetMaxHeight(root_child0, YGPx(40)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMaxHeight(root_child0, 40); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -285,12 +285,12 @@ TEST(YogaTest, aspect_ratio_with_max_main_defined) { TEST(YogaTest, aspect_ratio_with_min_cross_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(30)); - YGNodeStyleSetMinWidth(root_child0, YGPx(40)); + YGNodeStyleSetHeight(root_child0, 30); + YGNodeStyleSetMinWidth(root_child0, 40); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -307,12 +307,12 @@ TEST(YogaTest, aspect_ratio_with_min_cross_defined) { TEST(YogaTest, aspect_ratio_with_min_main_defined) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(30)); - YGNodeStyleSetMinHeight(root_child0, YGPx(40)); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetMinHeight(root_child0, 40); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -329,11 +329,11 @@ TEST(YogaTest, aspect_ratio_with_min_main_defined) { TEST(YogaTest, aspect_ratio_double_cross) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); @@ -350,11 +350,11 @@ TEST(YogaTest, aspect_ratio_double_cross) { TEST(YogaTest, aspect_ratio_half_cross) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(100)); + YGNodeStyleSetHeight(root_child0, 100); YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); @@ -371,11 +371,11 @@ TEST(YogaTest, aspect_ratio_half_cross) { TEST(YogaTest, aspect_ratio_double_main) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); @@ -392,11 +392,11 @@ TEST(YogaTest, aspect_ratio_double_main) { TEST(YogaTest, aspect_ratio_half_main) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(100)); + YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); @@ -413,8 +413,8 @@ TEST(YogaTest, aspect_ratio_half_main) { TEST(YogaTest, aspect_ratio_with_measure_func) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetMeasureFunc(root_child0, _measure); @@ -435,12 +435,12 @@ TEST(YogaTest, aspect_ratio_width_height_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -458,12 +458,12 @@ TEST(YogaTest, aspect_ratio_width_height_flex_grow_row) { TEST(YogaTest, aspect_ratio_width_height_flex_grow_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -482,17 +482,17 @@ TEST(YogaTest, aspect_ratio_height_as_flex_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetHeight(root_child1, YGPx(100)); + YGNodeStyleSetHeight(root_child1, 100); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetAspectRatio(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); @@ -515,17 +515,17 @@ TEST(YogaTest, aspect_ratio_height_as_flex_basis) { TEST(YogaTest, aspect_ratio_width_as_flex_basis) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(200)); - YGNodeStyleSetHeight(root, YGPx(200)); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNew(); - YGNodeStyleSetWidth(root_child1, YGPx(100)); + YGNodeStyleSetWidth(root_child1, 100); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetAspectRatio(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); @@ -549,11 +549,11 @@ TEST(YogaTest, aspect_ratio_overrides_flex_grow_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); @@ -571,11 +571,11 @@ TEST(YogaTest, aspect_ratio_overrides_flex_grow_row) { TEST(YogaTest, aspect_ratio_overrides_flex_grow_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); @@ -592,14 +592,14 @@ TEST(YogaTest, aspect_ratio_overrides_flex_grow_column) { TEST(YogaTest, aspect_ratio_left_right_absolute) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeRight, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 10); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -615,14 +615,14 @@ TEST(YogaTest, aspect_ratio_left_right_absolute) { TEST(YogaTest, aspect_ratio_top_bottom_absolute) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, YGPx(10)); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, YGPx(10)); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -639,11 +639,11 @@ TEST(YogaTest, aspect_ratio_top_bottom_absolute) { TEST(YogaTest, aspect_ratio_width_overrides_align_stretch_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetWidth(root_child0, YGPx(50)); + YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -659,11 +659,11 @@ TEST(YogaTest, aspect_ratio_width_overrides_align_stretch_row) { TEST(YogaTest, aspect_ratio_height_overrides_align_stretch_column) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); - YGNodeStyleSetHeight(root_child0, YGPx(50)); + YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); diff --git a/tests/YGMeasureCacheTest.cpp b/tests/YGMeasureCacheTest.cpp index 65b043c3..ca932b25 100644 --- a/tests/YGMeasureCacheTest.cpp +++ b/tests/YGMeasureCacheTest.cpp @@ -43,8 +43,8 @@ TEST(YogaTest, measure_once_single_flexible_child) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index 9bbbbfa9..cd5aedba 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -49,8 +49,8 @@ TEST(YogaTest, exactly_measure_stretched_child_column) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -76,8 +76,8 @@ TEST(YogaTest, exactly_measure_stretched_child_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -102,8 +102,8 @@ TEST(YogaTest, at_most_main_axis_column) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -129,8 +129,8 @@ TEST(YogaTest, at_most_cross_axis_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -156,8 +156,8 @@ TEST(YogaTest, at_most_main_axis_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -184,8 +184,8 @@ TEST(YogaTest, at_most_cross_axis_row) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -210,7 +210,7 @@ TEST(YogaTest, flex_child) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); @@ -239,11 +239,11 @@ TEST(YogaTest, flex_child_with_flex_basis) { }; const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetFlexGrow(root_child0, 1); - YGNodeStyleSetFlexBasis(root_child0, YGPx(0)); + YGNodeStyleSetFlexBasis(root_child0, 0); YGNodeSetContext(root_child0, &constraintList); YGNodeSetMeasureFunc(root_child0, _measure); YGNodeInsertChild(root, root_child0, 0); @@ -268,8 +268,8 @@ TEST(YogaTest, overflow_scroll_column) { const YGNodeRef root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetOverflow(root, YGOverflowScroll); - YGNodeStyleSetHeight(root, YGPx(100)); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); @@ -300,8 +300,8 @@ TEST(YogaTest, overflow_scroll_row) { YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetOverflow(root, YGOverflowScroll); - YGNodeStyleSetHeight(root, YGPx(100)); - YGNodeStyleSetWidth(root, YGPx(100)); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, 100); const YGNodeRef root_child0 = YGNodeNew(); YGNodeSetContext(root_child0, &constraintList); diff --git a/tests/YGMeasureTest.cpp b/tests/YGMeasureTest.cpp index b7eb6585..911f0c51 100644 --- a/tests/YGMeasureTest.cpp +++ b/tests/YGMeasureTest.cpp @@ -28,8 +28,8 @@ static YGSize _measure(YGNodeRef node, TEST(YogaTest, dont_measure_single_grow_shrink_child) { const YGNodeRef root = YGNodeNew(); - YGNodeStyleSetWidth(root, YGPx(100)); - YGNodeStyleSetHeight(root, YGPx(100)); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); int measureCount = 0; diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index 68995bc6..7e94e35c 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -30,7 +30,7 @@ TEST(YogaTest, copy_style_modified) { const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node1, YGPx(10)); + YGNodeStyleSetMaxHeight(node1, 10); YGNodeCopyStyle(node0, node1); ASSERT_TRUE(YGNodeIsDirty(node0)); @@ -44,13 +44,13 @@ TEST(YogaTest, copy_style_modified) { TEST(YogaTest, copy_style_modified_same) { const YGNodeRef node0 = YGNodeNew(); YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node0, YGPx(10)); + YGNodeStyleSetMaxHeight(node0, 10); YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FALSE(YGNodeIsDirty(node0)); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - YGNodeStyleSetMaxHeight(node1, YGPx(10)); + YGNodeStyleSetMaxHeight(node1, 10); YGNodeCopyStyle(node0, node1); ASSERT_FALSE(YGNodeIsDirty(node0)); -- 2.50.1.windows.1 From 2a57da06af0dd914d39d581848b11a89fb9665a0 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 22:55:51 +0100 Subject: [PATCH 36/39] indentation --- .hgignore | 6 ++++++ enums.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.hgignore b/.hgignore index fca97a4b..65f01a65 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,12 @@ # Visual studio code .vscode +*.pdb +*.tlog +*.obj +*.pch +*.log +*.orig # Xcode ## Build generated diff --git a/enums.py b/enums.py index 0eaca23d..978d6ff0 100644 --- a/enums.py +++ b/enums.py @@ -18,7 +18,7 @@ ENUMS = { 'RTL', ], 'Unit': [ - 'Undefined', + 'Undefined', 'Pixel', 'Percent', ], -- 2.50.1.windows.1 From b80d1fd893438808b132c8ed77ea7855b6e06964 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 22:58:41 +0100 Subject: [PATCH 37/39] another indent --- enums.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enums.py b/enums.py index 978d6ff0..f23fa164 100644 --- a/enums.py +++ b/enums.py @@ -17,7 +17,7 @@ ENUMS = { 'LTR', 'RTL', ], - 'Unit': [ + 'Unit': [ 'Undefined', 'Pixel', 'Percent', -- 2.50.1.windows.1 From 53040401618eab38cdba8489a4ac6f86c0a74d7f Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 23:22:48 +0100 Subject: [PATCH 38/39] fixups --- tests/YGDefaultValuesTest.cpp | 34 +++++++++++++++++----------------- tests/YGStyleTest.cpp | 2 +- yoga/Yoga.c | 18 +++--------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/tests/YGDefaultValuesTest.cpp b/tests/YGDefaultValuesTest.cpp index dfdf7cd7..b553a011 100644 --- a/tests/YGDefaultValuesTest.cpp +++ b/tests/YGDefaultValuesTest.cpp @@ -27,28 +27,28 @@ TEST(YogaTest, assert_default_values) { ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); - ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).unit != YGUnitUndefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).isDefined); - ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).isDefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).unit != YGUnitUndefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom).value); - ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).isDefined); - ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).isDefined); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).unit != YGUnitUndefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight).value); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom).value); - ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).isDefined); - ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).isDefined); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).unit != YGUnitUndefined); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); @@ -57,12 +57,12 @@ TEST(YogaTest, assert_default_values) { ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); - ASSERT_FALSE(YGNodeStyleGetWidth(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetHeight(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetMinWidth(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetMinHeight(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).isDefined); - ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).isDefined); + ASSERT_FALSE(YGNodeStyleGetWidth(root).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetHeight(root).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetMinWidth(root).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetMinHeight(root).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).unit != YGUnitUndefined); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).unit != YGUnitUndefined); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index 7e94e35c..83555edd 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -26,7 +26,7 @@ TEST(YogaTest, copy_style_modified) { const YGNodeRef node0 = YGNodeNew(); ASSERT_FALSE(YGNodeIsDirty(node0)); ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); - ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).isDefined); + ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).unit != YGUnitUndefined); const YGNodeRef node1 = YGNodeNew(); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 316e77ae..b9a3c1aa 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -111,18 +111,6 @@ typedef struct YGNode { .unit = YGUnitUndefined \ } -#define YG_DEFAULT_EDGE_VALUES { \ - [YGEdgeLeft] = YGUndefined, \ - [YGEdgeTop] = YGUndefined, \ - [YGEdgeRight] = YGUndefined, \ - [YGEdgeBottom] = YGUndefined, \ - [YGEdgeStart] = YGUndefined, \ - [YGEdgeEnd] = YGUndefined, \ - [YGEdgeHorizontal] = YGUndefined, \ - [YGEdgeVertical] = YGUndefined, \ - [YGEdgeAll] = YGUndefined, \ -} - #define YG_DEFAULT_EDGE_VALUES_UNIT { \ [YGEdgeLeft] = YG_UNDEFINED_VALUES, \ [YGEdgeTop] = YG_UNDEFINED_VALUES, \ @@ -168,7 +156,7 @@ static YGNode gYGNodeDefaults = { .position = YG_DEFAULT_EDGE_VALUES_UNIT, .margin = YG_DEFAULT_EDGE_VALUES_UNIT, .padding = YG_DEFAULT_EDGE_VALUES_UNIT, - .border = YG_DEFAULT_EDGE_VALUES, + .border = YG_DEFAULT_EDGE_VALUES_UNIT, .aspectRatio = YGUndefined, }, @@ -968,7 +956,7 @@ static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection a const YGValue * leadingPosition = YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined); - return !leadingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); + return leadingPosition->unit == YGUnitUndefined ? 0.0f : YGValueResolve(leadingPosition, axisSize); } static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis, const float axisSize) { @@ -983,7 +971,7 @@ static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection const YGValue * trailingPosition = YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined); - return !trailingPosition->unit != YGUnitUndefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); + return trailingPosition->unit == YGUnitUndefined ? 0.0f : YGValueResolve(trailingPosition, axisSize); } static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, -- 2.50.1.windows.1 From b3752efd052a4e3005ee67f98f92d8c9ead0b420 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Fri, 23 Dec 2016 23:26:48 +0100 Subject: [PATCH 39/39] remove explicit .Px() from c# unittests --- .../Facebook.Yoga/YGAbsolutePositionTest.cs | 100 +++++++-------- .../tests/Facebook.Yoga/YGAlignContentTest.cs | 86 ++++++------- .../tests/Facebook.Yoga/YGAlignItemsTest.cs | 30 ++--- csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs | 32 ++--- csharp/tests/Facebook.Yoga/YGBorderTest.cs | 24 ++-- .../Facebook.Yoga/YGFlexDirectionTest.cs | 56 ++++----- csharp/tests/Facebook.Yoga/YGFlexTest.cs | 58 ++++----- csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs | 72 +++++------ .../Facebook.Yoga/YGJustifyContentTest.cs | 98 +++++++-------- csharp/tests/Facebook.Yoga/YGMarginTest.cs | 64 +++++----- .../Facebook.Yoga/YGMinMaxDimensionTest.cs | 108 ++++++++-------- csharp/tests/Facebook.Yoga/YGPaddingTest.cs | 78 ++++++------ .../tests/Facebook.Yoga/YGPercentageTest.cs | 108 ++++++++-------- csharp/tests/Facebook.Yoga/YGRoundingTest.cs | 118 +++++++++--------- gentest/gentest-cs.js | 8 +- 15 files changed, 519 insertions(+), 521 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index 65806462..49f6605e 100644 --- a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -21,15 +21,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_start_top() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10.Px()); - root_child0.SetPosition(YogaEdge.Top, 10.Px()); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.SetPosition(YogaEdge.Start, 10); + root_child0.SetPosition(YogaEdge.Top, 10); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -62,15 +62,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.End, 10.Px()); - root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.SetPosition(YogaEdge.End, 10); + root_child0.SetPosition(YogaEdge.Bottom, 10); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -103,15 +103,15 @@ namespace Facebook.Yoga public void Test_absolute_layout_start_top_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10.Px()); - root_child0.SetPosition(YogaEdge.Top, 10.Px()); - root_child0.SetPosition(YogaEdge.End, 10.Px()); - root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); + root_child0.SetPosition(YogaEdge.Start, 10); + root_child0.SetPosition(YogaEdge.Top, 10); + root_child0.SetPosition(YogaEdge.End, 10); + root_child0.SetPosition(YogaEdge.Bottom, 10); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -144,17 +144,17 @@ namespace Facebook.Yoga public void Test_absolute_layout_width_height_start_top_end_bottom() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 10.Px()); - root_child0.SetPosition(YogaEdge.Top, 10.Px()); - root_child0.SetPosition(YogaEdge.End, 10.Px()); - root_child0.SetPosition(YogaEdge.Bottom, 10.Px()); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.SetPosition(YogaEdge.Start, 10); + root_child0.SetPosition(YogaEdge.Top, 10); + root_child0.SetPosition(YogaEdge.End, 10); + root_child0.SetPosition(YogaEdge.Bottom, 10); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -189,18 +189,18 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Overflow = YogaOverflow.Hidden; - root.Width = 50.Px(); - root.Height = 50.Px(); + root.Width = 50; + root.Height = 50; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Start, 0.Px()); - root_child0.SetPosition(YogaEdge.Top, 0.Px()); + root_child0.SetPosition(YogaEdge.Start, 0); + root_child0.SetPosition(YogaEdge.Top, 0); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 100.Px(); - root_child0_child0.Height = 100.Px(); + root_child0_child0.Width = 100; + root_child0_child0.Height = 100; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -243,35 +243,35 @@ namespace Facebook.Yoga public void Test_absolute_layout_within_border() { YogaNode root = new YogaNode(); - root.SetMargin(YogaEdge.Left, 10.Px()); - root.SetMargin(YogaEdge.Top, 10.Px()); - root.SetMargin(YogaEdge.Right, 10.Px()); - root.SetMargin(YogaEdge.Bottom, 10.Px()); - root.SetPadding(YogaEdge.Left, 10.Px()); - root.SetPadding(YogaEdge.Top, 10.Px()); - root.SetPadding(YogaEdge.Right, 10.Px()); - root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.SetMargin(YogaEdge.Left, 10); + root.SetMargin(YogaEdge.Top, 10); + root.SetMargin(YogaEdge.Right, 10); + root.SetMargin(YogaEdge.Bottom, 10); + root.SetPadding(YogaEdge.Left, 10); + root.SetPadding(YogaEdge.Top, 10); + root.SetPadding(YogaEdge.Right, 10); + root.SetPadding(YogaEdge.Bottom, 10); root.SetBorder(YogaEdge.Left, 10); root.SetBorder(YogaEdge.Top, 10); root.SetBorder(YogaEdge.Right, 10); root.SetBorder(YogaEdge.Bottom, 10); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.SetPosition(YogaEdge.Left, 0.Px()); - root_child0.SetPosition(YogaEdge.Top, 0.Px()); - root_child0.Width = 50.Px(); - root_child0.Height = 50.Px(); + root_child0.SetPosition(YogaEdge.Left, 0); + root_child0.SetPosition(YogaEdge.Top, 0); + root_child0.Width = 50; + root_child0.Height = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.PositionType = YogaPositionType.Absolute; - root_child1.SetPosition(YogaEdge.Right, 0.Px()); - root_child1.SetPosition(YogaEdge.Bottom, 0.Px()); - root_child1.Width = 50.Px(); - root_child1.Height = 50.Px(); + root_child1.SetPosition(YogaEdge.Right, 0); + root_child1.SetPosition(YogaEdge.Bottom, 0); + root_child1.Width = 50; + root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs index 42f0a6ac..288e30f8 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs @@ -22,32 +22,32 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 50; + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); - root_child1.Height = 10.Px(); + root_child1.Width = 50; + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); - root_child2.Height = 10.Px(); + root_child2.Width = 50; + root_child2.Height = 10; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50.Px(); - root_child3.Height = 10.Px(); + root_child3.Width = 50; + root_child3.Height = 10; root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50.Px(); - root_child4.Height = 10.Px(); + root_child4.Width = 50; + root_child4.Height = 10; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -122,32 +122,32 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 50; + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); - root_child1.Height = 10.Px(); + root_child1.Width = 50; + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); - root_child2.Height = 10.Px(); + root_child2.Width = 50; + root_child2.Height = 10; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50.Px(); - root_child3.Height = 10.Px(); + root_child3.Width = 50; + root_child3.Height = 10; root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50.Px(); - root_child4.Height = 10.Px(); + root_child4.Width = 50; + root_child4.Height = 10; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -222,32 +222,32 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 50; + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); - root_child1.Height = 10.Px(); + root_child1.Width = 50; + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); - root_child2.Height = 10.Px(); + root_child2.Width = 50; + root_child2.Height = 10; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50.Px(); - root_child3.Height = 10.Px(); + root_child3.Width = 50; + root_child3.Height = 10; root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50.Px(); - root_child4.Height = 10.Px(); + root_child4.Width = 50; + root_child4.Height = 10; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -322,27 +322,27 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); + root_child0.Width = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); + root_child1.Width = 50; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); + root_child2.Width = 50; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 50.Px(); + root_child3.Width = 50; root.Insert(3, root_child3); YogaNode root_child4 = new YogaNode(); - root_child4.Width = 50.Px(); + root_child4.Width = 50; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index daac3786..bcafe460 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -21,11 +21,11 @@ namespace Facebook.Yoga public void Test_align_items_stretch() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -59,12 +59,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -98,12 +98,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -137,12 +137,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexEnd; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs index acf64a83..b4ca0e13 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs @@ -21,13 +21,13 @@ namespace Facebook.Yoga public void Test_align_self_center() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.Center; - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,13 +60,13 @@ namespace Facebook.Yoga public void Test_align_self_flex_end() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -99,13 +99,13 @@ namespace Facebook.Yoga public void Test_align_self_flex_start() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexStart; - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -139,13 +139,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs index 324411ae..86029fca 100644 --- a/csharp/tests/Facebook.Yoga/YGBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -52,8 +52,8 @@ namespace Facebook.Yoga root.SetBorder(YogaEdge.Bottom, 10); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -90,12 +90,12 @@ namespace Facebook.Yoga root.SetBorder(YogaEdge.Top, 10); root.SetBorder(YogaEdge.Right, 10); root.SetBorder(YogaEdge.Bottom, 10); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -132,11 +132,11 @@ namespace Facebook.Yoga root.SetBorder(YogaEdge.Top, 10); root.SetBorder(YogaEdge.Right, 10); root.SetBorder(YogaEdge.Bottom, 10); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -174,12 +174,12 @@ namespace Facebook.Yoga root.SetBorder(YogaEdge.Start, 10); root.SetBorder(YogaEdge.End, 20); root.SetBorder(YogaEdge.Bottom, 20); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs index dfbd5c23..8063b48a 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs @@ -21,18 +21,18 @@ namespace Facebook.Yoga public void Test_flex_direction_column_no_height() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); + root.Width = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -86,18 +86,18 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Height = 100.Px(); + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -150,19 +150,19 @@ namespace Facebook.Yoga public void Test_flex_direction_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -216,19 +216,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -282,19 +282,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.ColumnReverse; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -348,19 +348,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.RowReverse; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGFlexTest.cs b/csharp/tests/Facebook.Yoga/YGFlexTest.cs index 850e0969..3826fa9a 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexTest.cs @@ -21,12 +21,12 @@ namespace Facebook.Yoga public void Test_flex_basis_flex_grow_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); + root_child0.FlexBasis = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); @@ -74,12 +74,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); + root_child0.FlexBasis = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); @@ -126,16 +126,16 @@ namespace Facebook.Yoga public void Test_flex_basis_flex_shrink_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100.Px(); + root_child0.FlexBasis = 100; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 50.Px(); + root_child1.FlexBasis = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -179,16 +179,16 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100.Px(); + root_child0.FlexBasis = 100; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 50.Px(); + root_child1.FlexBasis = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -231,22 +231,22 @@ namespace Facebook.Yoga public void Test_flex_shrink_to_zero() { YogaNode root = new YogaNode(); - root.Height = 75.Px(); + root.Height = 75; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); - root_child0.Height = 50.Px(); + root_child0.Width = 50; + root_child0.Height = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexShrink = 1; - root_child1.Width = 50.Px(); - root_child1.Height = 50.Px(); + root_child1.Width = 50; + root_child1.Height = 50; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); - root_child2.Height = 50.Px(); + root_child2.Width = 50; + root_child2.Height = 50; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -299,23 +299,23 @@ namespace Facebook.Yoga public void Test_flex_basis_overrides_main_size() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -368,8 +368,8 @@ namespace Facebook.Yoga public void Test_flex_grow_shrink_at_most() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root.Insert(0, root_child0); diff --git a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs index aae223ab..c4a0c352 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs @@ -22,26 +22,26 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; - root.Height = 100.Px(); + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30.Px(); - root_child0.Height = 30.Px(); + root_child0.Width = 30; + root_child0.Height = 30; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30.Px(); - root_child1.Height = 30.Px(); + root_child1.Width = 30; + root_child1.Height = 30; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30.Px(); - root_child2.Height = 30.Px(); + root_child2.Width = 30; + root_child2.Height = 30; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30.Px(); - root_child3.Height = 30.Px(); + root_child3.Width = 30; + root_child3.Height = 30; root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -106,26 +106,26 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); + root.Width = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30.Px(); - root_child0.Height = 30.Px(); + root_child0.Width = 30; + root_child0.Height = 30; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30.Px(); - root_child1.Height = 30.Px(); + root_child1.Width = 30; + root_child1.Height = 30; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30.Px(); - root_child2.Height = 30.Px(); + root_child2.Width = 30; + root_child2.Height = 30; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30.Px(); - root_child3.Height = 30.Px(); + root_child3.Width = 30; + root_child3.Height = 30; root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -191,26 +191,26 @@ namespace Facebook.Yoga root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); + root.Width = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 30; + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30.Px(); - root_child1.Height = 20.Px(); + root_child1.Width = 30; + root_child1.Height = 20; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30.Px(); - root_child2.Height = 30.Px(); + root_child2.Width = 30; + root_child2.Height = 30; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30.Px(); - root_child3.Height = 30.Px(); + root_child3.Width = 30; + root_child3.Height = 30; root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -276,26 +276,26 @@ namespace Facebook.Yoga root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; - root.Width = 100.Px(); + root.Width = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 30.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 30; + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 30.Px(); - root_child1.Height = 20.Px(); + root_child1.Width = 30; + root_child1.Height = 20; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 30.Px(); - root_child2.Height = 30.Px(); + root_child2.Width = 30; + root_child2.Height = 30; root.Insert(2, root_child2); YogaNode root_child3 = new YogaNode(); - root_child3.Width = 30.Px(); - root_child3.Height = 30.Px(); + root_child3.Width = 30; + root_child3.Height = 30; root.Insert(3, root_child3); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs index 060a2899..b36f9551 100644 --- a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs @@ -22,19 +22,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -89,19 +89,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -156,19 +156,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.Center; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -223,19 +223,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceBetween; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -290,19 +290,19 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceAround; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 10.Px(); + root_child1.Width = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 10.Px(); + root_child2.Width = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -355,18 +355,18 @@ namespace Facebook.Yoga public void Test_justify_content_column_flex_start() { YogaNode root = new YogaNode(); - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -420,19 +420,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -486,19 +486,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -552,19 +552,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceBetween; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -618,19 +618,19 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceAround; - root.Width = 102.Px(); - root.Height = 102.Px(); + root.Width = 102; + root.Height = 102; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs index 9c070235..cc017ac4 100644 --- a/csharp/tests/Facebook.Yoga/YGMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -22,12 +22,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Start, 10.Px()); - root_child0.Width = 10.Px(); + root_child0.SetMargin(YogaEdge.Start, 10); + root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.Yoga public void Test_margin_top() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Top, 10.Px()); - root_child0.Height = 10.Px(); + root_child0.SetMargin(YogaEdge.Top, 10); + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -100,12 +100,12 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.End, 10.Px()); - root_child0.Width = 10.Px(); + root_child0.SetMargin(YogaEdge.End, 10); + root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -139,12 +139,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.SetMargin(YogaEdge.Bottom, 10.Px()); - root_child0.Height = 10.Px(); + root_child0.SetMargin(YogaEdge.Bottom, 10); + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -178,12 +178,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.SetMargin(YogaEdge.Start, 10.Px()); + root_child0.SetMargin(YogaEdge.Start, 10); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -216,12 +216,12 @@ namespace Facebook.Yoga public void Test_margin_and_flex_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.SetMargin(YogaEdge.Top, 10.Px()); + root_child0.SetMargin(YogaEdge.Top, 10); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -255,12 +255,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.SetMargin(YogaEdge.Top, 10.Px()); + root_child0.SetMargin(YogaEdge.Top, 10); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -293,12 +293,12 @@ namespace Facebook.Yoga public void Test_margin_and_stretch_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.SetMargin(YogaEdge.Start, 10.Px()); + root_child0.SetMargin(YogaEdge.Start, 10); root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -332,8 +332,8 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -383,8 +383,8 @@ namespace Facebook.Yoga public void Test_margin_with_sibling_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index 857e65b7..47568b6e 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -21,12 +21,12 @@ namespace Facebook.Yoga public void Test_max_width() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.MaxWidth = 50.Px(); - root_child0.Height = 10.Px(); + root_child0.MaxWidth = 50; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.MaxHeight = 50.Px(); + root_child0.Width = 10; + root_child0.MaxHeight = 50; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -98,12 +98,12 @@ namespace Facebook.Yoga public void Test_min_height() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.MinHeight = 60.Px(); + root_child0.MinHeight = 60; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); @@ -151,12 +151,12 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.MinWidth = 60.Px(); + root_child0.MinWidth = 60; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); @@ -204,13 +204,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.Width = 100.Px(); - root.MinHeight = 100.Px(); - root.MaxHeight = 200.Px(); + root.Width = 100; + root.MinHeight = 100; + root.MaxHeight = 200; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 60.Px(); - root_child0.Height = 60.Px(); + root_child0.Width = 60; + root_child0.Height = 60; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -244,13 +244,13 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; - root.MinWidth = 100.Px(); - root.MaxWidth = 200.Px(); - root.Height = 100.Px(); + root.MinWidth = 100; + root.MaxWidth = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 60.Px(); - root_child0.Height = 60.Px(); + root_child0.Width = 60; + root_child0.Height = 60; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -284,22 +284,22 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; - root.MinHeight = 100.Px(); - root.MaxHeight = 110.Px(); + root.MinHeight = 100; + root.MaxHeight = 110; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 50.Px(); - root_child0.Height = 50.Px(); + root_child0.Width = 50; + root_child0.Height = 50; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); - root_child1.Height = 50.Px(); + root_child1.Width = 50; + root_child1.Height = 50; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.Width = 50.Px(); - root_child2.Height = 50.Px(); + root_child2.Width = 50; + root_child2.Height = 50; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -352,17 +352,17 @@ namespace Facebook.Yoga public void Test_flex_grow_within_max_width() { YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 100.Px(); + root.Width = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 100.Px(); + root_child0.MaxWidth = 100; root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1; - root_child0_child0.Height = 20.Px(); + root_child0_child0.Height = 20; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -405,17 +405,17 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_width() { YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 100.Px(); + root.Width = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 300.Px(); + root_child0.MaxWidth = 300; root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1; - root_child0_child0.Height = 20.Px(); + root_child0_child0.Height = 20; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -459,15 +459,15 @@ namespace Facebook.Yoga { YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.MinWidth = 100.Px(); - root.Height = 100.Px(); + root.MinWidth = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Width = 50.Px(); + root_child1.Width = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -510,14 +510,14 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_min_column() { YogaNode root = new YogaNode(); - root.MinHeight = 100.Px(); + root.MinHeight = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 50.Px(); + root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -560,21 +560,21 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_row() { YogaNode root = new YogaNode(); - root.Width = 200.Px(); + root.Width = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; - root_child0.MaxWidth = 100.Px(); - root_child0.Height = 100.Px(); + root_child0.MaxWidth = 100; + root_child0.Height = 100; root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexShrink = 1; - root_child0_child0.FlexBasis = 100.Px(); + root_child0_child0.FlexBasis = 100; root_child0.Insert(0, root_child0_child0); YogaNode root_child0_child1 = new YogaNode(); - root_child0_child1.Width = 50.Px(); + root_child0_child1.Width = 50; root_child0.Insert(1, root_child0_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -627,16 +627,16 @@ namespace Facebook.Yoga public void Test_flex_grow_within_constrained_max_column() { YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.MaxHeight = 100.Px(); + root.Width = 100; + root.MaxHeight = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100.Px(); + root_child0.FlexBasis = 100; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.Height = 50.Px(); + root_child1.Height = 50; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs index da05f23a..b3f17014 100644 --- a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -21,10 +21,10 @@ namespace Facebook.Yoga public void Test_padding_no_size() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10.Px()); - root.SetPadding(YogaEdge.Top, 10.Px()); - root.SetPadding(YogaEdge.Right, 10.Px()); - root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.SetPadding(YogaEdge.Left, 10); + root.SetPadding(YogaEdge.Top, 10); + root.SetPadding(YogaEdge.Right, 10); + root.SetPadding(YogaEdge.Bottom, 10); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -46,14 +46,14 @@ namespace Facebook.Yoga public void Test_padding_container_match_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10.Px()); - root.SetPadding(YogaEdge.Top, 10.Px()); - root.SetPadding(YogaEdge.Right, 10.Px()); - root.SetPadding(YogaEdge.Bottom, 10.Px()); + root.SetPadding(YogaEdge.Left, 10); + root.SetPadding(YogaEdge.Top, 10); + root.SetPadding(YogaEdge.Right, 10); + root.SetPadding(YogaEdge.Bottom, 10); YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -86,16 +86,16 @@ namespace Facebook.Yoga public void Test_padding_flex_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10.Px()); - root.SetPadding(YogaEdge.Top, 10.Px()); - root.SetPadding(YogaEdge.Right, 10.Px()); - root.SetPadding(YogaEdge.Bottom, 10.Px()); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.SetPadding(YogaEdge.Left, 10); + root.SetPadding(YogaEdge.Top, 10); + root.SetPadding(YogaEdge.Right, 10); + root.SetPadding(YogaEdge.Bottom, 10); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.Width = 10.Px(); + root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -128,15 +128,15 @@ namespace Facebook.Yoga public void Test_padding_stretch_child() { YogaNode root = new YogaNode(); - root.SetPadding(YogaEdge.Left, 10.Px()); - root.SetPadding(YogaEdge.Top, 10.Px()); - root.SetPadding(YogaEdge.Right, 10.Px()); - root.SetPadding(YogaEdge.Bottom, 10.Px()); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.SetPadding(YogaEdge.Left, 10); + root.SetPadding(YogaEdge.Top, 10); + root.SetPadding(YogaEdge.Right, 10); + root.SetPadding(YogaEdge.Bottom, 10); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Height = 10.Px(); + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -171,15 +171,15 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; - root.SetPadding(YogaEdge.Start, 10.Px()); - root.SetPadding(YogaEdge.End, 20.Px()); - root.SetPadding(YogaEdge.Bottom, 20.Px()); - root.Width = 100.Px(); - root.Height = 100.Px(); + root.SetPadding(YogaEdge.Start, 10); + root.SetPadding(YogaEdge.End, 20); + root.SetPadding(YogaEdge.Bottom, 20); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -214,16 +214,16 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; root.AlignItems = YogaAlign.FlexEnd; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); - root_child0.SetPadding(YogaEdge.Left, 20.Px()); - root_child0.SetPadding(YogaEdge.Top, 20.Px()); - root_child0.SetPadding(YogaEdge.Right, 20.Px()); - root_child0.SetPadding(YogaEdge.Bottom, 20.Px()); - root_child0.Width = 100.Px(); - root_child0.Height = 100.Px(); + root_child0.SetPadding(YogaEdge.Left, 20); + root_child0.SetPadding(YogaEdge.Top, 20); + root_child0.SetPadding(YogaEdge.Right, 20); + root_child0.SetPadding(YogaEdge.Bottom, 20); + root_child0.Width = 100; + root_child0.Height = 100; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index 277df479..7c9bc423 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -24,8 +24,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.Width = 30.Percent(); @@ -67,8 +67,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 400.Px(); - root.Height = 400.Px(); + root.Width = 400; + root.Height = 400; YogaNode root_child0 = new YogaNode(); root_child0.SetPosition(YogaEdge.Left, 10.Percent()); @@ -112,8 +112,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 500.Px(); - root.Height = 500.Px(); + root.Width = 500; + root.Height = 500; YogaNode root_child0 = new YogaNode(); root_child0.SetPosition(YogaEdge.Right, 20.Percent()); @@ -157,8 +157,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -214,8 +214,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -271,8 +271,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -329,8 +329,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -388,8 +388,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -448,8 +448,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -507,8 +507,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -567,8 +567,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -626,8 +626,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -685,28 +685,28 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 200.Px(); + root.Width = 200; + root.Height = 200; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; root_child0.FlexBasis = 10.Percent(); - root_child0.SetMargin(YogaEdge.Left, 5.Px()); - root_child0.SetMargin(YogaEdge.Top, 5.Px()); - root_child0.SetMargin(YogaEdge.Right, 5.Px()); - root_child0.SetMargin(YogaEdge.Bottom, 5.Px()); - root_child0.SetPadding(YogaEdge.Left, 3.Px()); - root_child0.SetPadding(YogaEdge.Top, 3.Px()); - root_child0.SetPadding(YogaEdge.Right, 3.Px()); - root_child0.SetPadding(YogaEdge.Bottom, 3.Px()); + root_child0.SetMargin(YogaEdge.Left, 5); + root_child0.SetMargin(YogaEdge.Top, 5); + root_child0.SetMargin(YogaEdge.Right, 5); + root_child0.SetMargin(YogaEdge.Bottom, 5); + root_child0.SetPadding(YogaEdge.Left, 3); + root_child0.SetPadding(YogaEdge.Top, 3); + root_child0.SetPadding(YogaEdge.Right, 3); + root_child0.SetPadding(YogaEdge.Bottom, 3); root_child0.MinWidth = 60.Percent(); root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.SetMargin(YogaEdge.Left, 5.Px()); - root_child0_child0.SetMargin(YogaEdge.Top, 5.Px()); - root_child0_child0.SetMargin(YogaEdge.Right, 5.Px()); - root_child0_child0.SetMargin(YogaEdge.Bottom, 5.Px()); + root_child0_child0.SetMargin(YogaEdge.Left, 5); + root_child0_child0.SetMargin(YogaEdge.Top, 5); + root_child0_child0.SetMargin(YogaEdge.Right, 5); + root_child0_child0.SetMargin(YogaEdge.Bottom, 5); root_child0_child0.SetPadding(YogaEdge.Left, 3.Percent()); root_child0_child0.SetPadding(YogaEdge.Top, 3.Percent()); root_child0_child0.SetPadding(YogaEdge.Right, 3.Percent()); @@ -719,10 +719,10 @@ namespace Facebook.Yoga root_child0_child0_child0.SetMargin(YogaEdge.Top, 5.Percent()); root_child0_child0_child0.SetMargin(YogaEdge.Right, 5.Percent()); root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5.Percent()); - root_child0_child0_child0.SetPadding(YogaEdge.Left, 3.Px()); - root_child0_child0_child0.SetPadding(YogaEdge.Top, 3.Px()); - root_child0_child0_child0.SetPadding(YogaEdge.Right, 3.Px()); - root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3.Px()); + root_child0_child0_child0.SetPadding(YogaEdge.Left, 3); + root_child0_child0_child0.SetPadding(YogaEdge.Top, 3); + root_child0_child0_child0.SetPadding(YogaEdge.Right, 3); + root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3); root_child0_child0_child0.Width = 45.Percent(); root_child0_child0.Insert(0, root_child0_child0_child0); @@ -796,8 +796,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 100.Px(); + root.Width = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -808,8 +808,8 @@ namespace Facebook.Yoga root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 10.Px(); - root_child0_child0.Height = 10.Px(); + root_child0_child0.Width = 10; + root_child0_child0.Height = 10; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -856,8 +856,8 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 100.Px(); + root.Width = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -868,8 +868,8 @@ namespace Facebook.Yoga root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); - root_child0_child0.Width = 10.Px(); - root_child0_child0.Height = 10.Px(); + root_child0_child0.Width = 10; + root_child0_child0.Height = 10; root_child0.Insert(0, root_child0_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -916,15 +916,15 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 200.Px(); - root.Height = 100.Px(); + root.Width = 200; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Left, 30.Percent()); root_child0.SetPosition(YogaEdge.Top, 10.Percent()); - root_child0.Width = 10.Px(); - root_child0.Height = 10.Px(); + root_child0.Width = 10; + root_child0.Height = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs index 88c8c5a1..2ed2c39d 100644 --- a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs @@ -24,8 +24,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 100.Px(); - root.Height = 100.Px(); + root.Width = 100; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -94,8 +94,8 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 113.Px(); - root.Height = 100.Px(); + root.Width = 113; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; @@ -192,20 +192,20 @@ namespace Facebook.Yoga YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; - root.Width = 101.Px(); - root.Height = 100.Px(); + root.Width = 101; + root.Height = 100; YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100.Px(); + root_child0.FlexBasis = 100; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); - root_child1.FlexBasis = 25.Px(); + root_child1.FlexBasis = 25; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); - root_child2.FlexBasis = 25.Px(); + root_child2.FlexBasis = 25; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -262,23 +262,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 113.Px(); + root.Width = 100; + root.Height = 113; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -335,23 +335,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 87.4f.Px(); - root.Height = 113.4f.Px(); + root.Width = 87.4f; + root.Height = 113.4f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; - root_child0.FlexBasis = 50.3f.Px(); - root_child0.Height = 20.3f.Px(); + root_child0.FlexBasis = 50.3f; + root_child0.Height = 20.3f; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; - root_child2.Height = 10.7f.Px(); + root_child2.Height = 10.7f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -408,37 +408,37 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 87.4f.Px(); - root.Height = 113.4f.Px(); + root.Width = 87.4f; + root.Height = 113.4f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; - root_child0.FlexBasis = 50.3f.Px(); - root_child0.Height = 20.3f.Px(); + root_child0.FlexBasis = 50.3f; + root_child0.Height = 20.3f; root.Insert(0, root_child0); YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1; - root_child0_child0.FlexBasis = 0.3f.Px(); - root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f.Px()); - root_child0_child0.Height = 9.9f.Px(); + root_child0_child0.FlexBasis = 0.3f; + root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f); + root_child0_child0.Height = 9.9f; root_child0.Insert(0, root_child0_child0); YogaNode root_child0_child1 = new YogaNode(); root_child0_child1.FlexGrow = 4; - root_child0_child1.FlexBasis = 0.3f.Px(); - root_child0_child1.SetPosition(YogaEdge.Top, 13.3f.Px()); - root_child0_child1.Height = 1.1f.Px(); + root_child0_child1.FlexBasis = 0.3f; + root_child0_child1.SetPosition(YogaEdge.Top, 13.3f); + root_child0_child1.Height = 1.1f; root_child0.Insert(1, root_child0_child1); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; - root_child2.Height = 10.7f.Px(); + root_child2.Height = 10.7f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -515,23 +515,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 113.4f.Px(); + root.Width = 100; + root.Height = 113.4f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -588,23 +588,23 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.Width = 100.Px(); - root.Height = 113.6f.Px(); + root.Width = 100; + root.Height = 113.6f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -661,24 +661,24 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.SetPosition(YogaEdge.Top, 0.3f.Px()); - root.Width = 100.Px(); - root.Height = 113.4f.Px(); + root.SetPosition(YogaEdge.Top, 0.3f); + root.Width = 100; + root.Height = 113.4f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -735,24 +735,24 @@ namespace Facebook.Yoga YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode root = new YogaNode(); - root.SetPosition(YogaEdge.Top, 0.7f.Px()); - root.Width = 100.Px(); - root.Height = 113.4f.Px(); + root.SetPosition(YogaEdge.Top, 0.7f); + root.Width = 100; + root.Height = 113.4f; YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50.Px(); - root_child0.Height = 20.Px(); + root_child0.FlexBasis = 50; + root_child0.Height = 20; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1; - root_child1.Height = 10.Px(); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1; - root_child2.Height = 10.Px(); + root_child2.Height = 10; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 59da4144..3a647d94 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -14,12 +14,10 @@ function toValueCs(value) { function toValueCsCs(value) { var methodName = ''; - if(value.indexOf('px') >= 0){ - methodName = 'Px'; - }else if (value.indexOf('%') >= 0){ - methodName = 'Percent'; + if (value.indexOf('%') >= 0){ + methodName = '.Percent()'; } - return toValueCs(value) + '.' + methodName + '()'; + return toValueCs(value) + methodName; } var CSEmitter = function() { -- 2.50.1.windows.1