diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h deleted file mode 100644 index 62f5b16c..00000000 --- a/CSSLayout/CSSLayout.h +++ /dev/null @@ -1,183 +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. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#ifndef __cplusplus -#include -#endif - -// Not defined in MSVC++ -#ifndef NAN -static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; -#define NAN (*(const float *) __nan) -#endif - -#define YGUndefined NAN - -#include "CSSEnums.h" -#include "CSSMacros.h" - -CSS_EXTERN_C_BEGIN - -typedef struct CSSSize { - float width; - float height; -} CSSSize; - -typedef struct CSSNode *CSSNodeRef; -typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, - float width, - YGMeasureMode widthMode, - float height, - YGMeasureMode heightMode); -typedef void (*CSSPrintFunc)(CSSNodeRef node); -typedef int (*CSSLogger)(YGLogLevel level, const char *format, va_list args); - -typedef void *(*CSSMalloc)(size_t size); -typedef void *(*CSSCalloc)(size_t count, size_t size); -typedef void *(*CSSRealloc)(void *ptr, size_t size); -typedef void (*CSSFree)(void *ptr); - -// CSSNode -WIN_EXPORT CSSNodeRef CSSNodeNew(void); -WIN_EXPORT void CSSNodeInit(const CSSNodeRef node); -WIN_EXPORT void CSSNodeFree(const CSSNodeRef node); -WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node); -WIN_EXPORT void CSSNodeReset(const CSSNodeRef node); -WIN_EXPORT int32_t CSSNodeGetInstanceCount(void); - -WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, - const CSSNodeRef child, - const uint32_t index); -WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child); -WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index); -WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node); - -WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGDirection parentDirection); - -// Mark a node as dirty. Only valid for nodes with a custom measure function -// set. -// CSSLayout knows when to mark all other nodes as dirty but because nodes with -// measure functions -// depends on information not known to CSSLayout they must perform this dirty -// marking manually. -WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node); -WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); - -WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options); - -WIN_EXPORT bool CSSValueIsUndefined(const float value); - -WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, - const float width, - const YGMeasureMode heightMode, - const float height, - const YGMeasureMode lastWidthMode, - const float lastWidth, - const YGMeasureMode lastHeightMode, - const float lastHeight, - const float lastComputedWidth, - const float lastComputedHeight, - const float marginRow, - const float marginColumn); - -WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode); - -#define CSS_NODE_PROPERTY(type, name, paramName) \ - WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \ - WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node); - -#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \ - WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \ - WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node); - -#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ - WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \ - const YGEdge edge, \ - const type paramName); \ - WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const YGEdge edge); - -#define CSS_NODE_LAYOUT_PROPERTY(type, name) \ - WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node); - -CSS_NODE_PROPERTY(void *, Context, context); -CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); -CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc); -CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout); - -CSS_NODE_STYLE_PROPERTY(YGDirection, Direction, direction); -CSS_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection); -CSS_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent); -CSS_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent); -CSS_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems); -CSS_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf); -CSS_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType); -CSS_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap); -CSS_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow); - -WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex); -CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow); -CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink); -CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis); - -CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position); -CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin); -CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding); -CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border); - -CSS_NODE_STYLE_PROPERTY(float, Width, width); -CSS_NODE_STYLE_PROPERTY(float, Height, height); -CSS_NODE_STYLE_PROPERTY(float, MinWidth, minWidth); -CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight); -CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth); -CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight); - -// Yoga specific properties, not compatible with flexbox specification -// Aspect ratio control the size of the undefined dimension of a node. -// - On a node with a set width/height aspect ratio control the size of the unset dimension -// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if -// unset -// - On a node with a measure function aspect ratio works as though the measure function measures -// the flex basis -// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if -// unset -// - Aspect ratio takes min/max dimensions into account -CSS_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio); - -CSS_NODE_LAYOUT_PROPERTY(float, Left); -CSS_NODE_LAYOUT_PROPERTY(float, Top); -CSS_NODE_LAYOUT_PROPERTY(float, Right); -CSS_NODE_LAYOUT_PROPERTY(float, Bottom); -CSS_NODE_LAYOUT_PROPERTY(float, Width); -CSS_NODE_LAYOUT_PROPERTY(float, Height); -CSS_NODE_LAYOUT_PROPERTY(YGDirection, Direction); - -WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); -WIN_EXPORT void CSSLog(YGLogLevel level, const char *message, ...); - -WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled); -WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature); - -WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc, - CSSCalloc cssCalloc, - CSSRealloc cssRealloc, - CSSFree cssFree); - -CSS_EXTERN_C_END diff --git a/CSSLayout/CSSNodeList.c b/CSSLayout/CSSNodeList.c deleted file mode 100644 index 886f78cb..00000000 --- a/CSSLayout/CSSNodeList.c +++ /dev/null @@ -1,104 +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. - */ - -#include "CSSNodeList.h" - -extern CSSMalloc gCSSMalloc; -extern CSSRealloc gCSSRealloc; -extern CSSFree gCSSFree; - -struct CSSNodeList { - uint32_t capacity; - uint32_t count; - CSSNodeRef *items; -}; - -CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) { - const CSSNodeListRef list = gCSSMalloc(sizeof(struct CSSNodeList)); - CSS_ASSERT(list != NULL, "Could not allocate memory for list"); - - list->capacity = initialCapacity; - list->count = 0; - list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity); - CSS_ASSERT(list->items != NULL, "Could not allocate memory for items"); - - return list; -} - -void CSSNodeListFree(const CSSNodeListRef list) { - if (list) { - gCSSFree(list->items); - gCSSFree(list); - } -} - -uint32_t CSSNodeListCount(const CSSNodeListRef list) { - if (list) { - return list->count; - } - return 0; -} - -void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node) { - if (!*listp) { - *listp = CSSNodeListNew(4); - } - CSSNodeListInsert(listp, node, (*listp)->count); -} - -void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index) { - if (!*listp) { - *listp = CSSNodeListNew(4); - } - CSSNodeListRef list = *listp; - - if (list->count == list->capacity) { - list->capacity *= 2; - list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity); - CSS_ASSERT(list->items != NULL, "Could not extend allocation for items"); - } - - for (uint32_t i = list->count; i > index; i--) { - list->items[i] = list->items[i - 1]; - } - - list->count++; - list->items[index] = node; -} - -CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index) { - const CSSNodeRef removed = list->items[index]; - list->items[index] = NULL; - - for (uint32_t i = index; i < list->count - 1; i++) { - list->items[i] = list->items[i + 1]; - list->items[i + 1] = NULL; - } - - list->count--; - return removed; -} - -CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) { - for (uint32_t i = 0; i < list->count; i++) { - if (list->items[i] == node) { - return CSSNodeListRemove(list, i); - } - } - - return NULL; -} - -CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) { - if (CSSNodeListCount(list) > 0) { - return list->items[index]; - } - - return NULL; -} diff --git a/CSSLayout/CSSNodeList.h b/CSSLayout/CSSNodeList.h deleted file mode 100644 index 155fcf6e..00000000 --- a/CSSLayout/CSSNodeList.h +++ /dev/null @@ -1,33 +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. - */ - -#pragma once - -#include -#include -#include -#include - -#include "CSSLayout.h" -#include "CSSMacros.h" - -CSS_EXTERN_C_BEGIN - -typedef struct CSSNodeList *CSSNodeListRef; - -CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity); -void CSSNodeListFree(const CSSNodeListRef list); -uint32_t CSSNodeListCount(const CSSNodeListRef list); -void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node); -void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index); -CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index); -CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node); -CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index); - -CSS_EXTERN_C_END diff --git a/CSSLayout/CSSEnums.h b/CSSLayout/YGEnums.h similarity index 100% rename from CSSLayout/CSSEnums.h rename to CSSLayout/YGEnums.h diff --git a/CSSLayout/CSSMacros.h b/CSSLayout/YGMacros.h similarity index 60% rename from CSSLayout/CSSMacros.h rename to CSSLayout/YGMacros.h index f54a5b87..def8371a 100644 --- a/CSSLayout/CSSMacros.h +++ b/CSSLayout/YGMacros.h @@ -10,11 +10,11 @@ #pragma once #ifdef __cplusplus -#define CSS_EXTERN_C_BEGIN extern "C" { -#define CSS_EXTERN_C_END } +#define YG_EXTERN_C_BEGIN extern "C" { +#define YG_EXTERN_C_END } #else -#define CSS_EXTERN_C_BEGIN -#define CSS_EXTERN_C_END +#define YG_EXTERN_C_BEGIN +#define YG_EXTERN_C_END #endif #ifdef _WINDLL @@ -28,15 +28,15 @@ #endif #if FB_ASSERTIONS_ENABLED -#define CSS_ABORT() abort() +#define YG_ABORT() abort() #else -#define CSS_ABORT() +#define YG_ABORT() #endif -#ifndef CSS_ASSERT -#define CSS_ASSERT(X, message) \ - if (!(X)) { \ - CSSLog(YGLogLevelError, "%s", message); \ - CSS_ABORT(); \ +#ifndef YG_ASSERT +#define YG_ASSERT(X, message) \ + if (!(X)) { \ + YGLog(YGLogLevelError, "%s", message); \ + YG_ABORT(); \ } #endif diff --git a/CSSLayout/YGNodeList.c b/CSSLayout/YGNodeList.c new file mode 100644 index 00000000..d82753e2 --- /dev/null +++ b/CSSLayout/YGNodeList.c @@ -0,0 +1,104 @@ +/** + * 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. + */ + +#include "YGNodeList.h" + +extern YGMalloc gYGMalloc; +extern YGRealloc gYGRealloc; +extern YGFree gYGFree; + +struct YGNodeList { + uint32_t capacity; + uint32_t count; + YGNodeRef *items; +}; + +YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) { + const YGNodeListRef list = gYGMalloc(sizeof(struct YGNodeList)); + YG_ASSERT(list != NULL, "Could not allocate memory for list"); + + list->capacity = initialCapacity; + list->count = 0; + list->items = gYGMalloc(sizeof(YGNodeRef) * list->capacity); + YG_ASSERT(list->items != NULL, "Could not allocate memory for items"); + + return list; +} + +void YGNodeListFree(const YGNodeListRef list) { + if (list) { + gYGFree(list->items); + gYGFree(list); + } +} + +uint32_t YGNodeListCount(const YGNodeListRef list) { + if (list) { + return list->count; + } + return 0; +} + +void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node) { + if (!*listp) { + *listp = YGNodeListNew(4); + } + YGNodeListInsert(listp, node, (*listp)->count); +} + +void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index) { + if (!*listp) { + *listp = YGNodeListNew(4); + } + YGNodeListRef list = *listp; + + if (list->count == list->capacity) { + list->capacity *= 2; + list->items = gYGRealloc(list->items, sizeof(YGNodeRef) * list->capacity); + YG_ASSERT(list->items != NULL, "Could not extend allocation for items"); + } + + for (uint32_t i = list->count; i > index; i--) { + list->items[i] = list->items[i - 1]; + } + + list->count++; + list->items[index] = node; +} + +YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index) { + const YGNodeRef removed = list->items[index]; + list->items[index] = NULL; + + for (uint32_t i = index; i < list->count - 1; i++) { + list->items[i] = list->items[i + 1]; + list->items[i + 1] = NULL; + } + + list->count--; + return removed; +} + +YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) { + for (uint32_t i = 0; i < list->count; i++) { + if (list->items[i] == node) { + return YGNodeListRemove(list, i); + } + } + + return NULL; +} + +YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) { + if (YGNodeListCount(list) > 0) { + return list->items[index]; + } + + return NULL; +} diff --git a/CSSLayout/YGNodeList.h b/CSSLayout/YGNodeList.h new file mode 100644 index 00000000..41e272ab --- /dev/null +++ b/CSSLayout/YGNodeList.h @@ -0,0 +1,33 @@ +/** + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include "YGMacros.h" +#include "Yoga.h" + +YG_EXTERN_C_BEGIN + +typedef struct YGNodeList *YGNodeListRef; + +YGNodeListRef YGNodeListNew(const uint32_t initialCapacity); +void YGNodeListFree(const YGNodeListRef list); +uint32_t YGNodeListCount(const YGNodeListRef list); +void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node); +void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index); +YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index); +YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node); +YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index); + +YG_EXTERN_C_END diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/Yoga.c similarity index 50% rename from CSSLayout/CSSLayout.c rename to CSSLayout/Yoga.c index c41194a1..70afece2 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/Yoga.c @@ -9,8 +9,8 @@ #include -#include "CSSLayout.h" -#include "CSSNodeList.h" +#include "YGNodeList.h" +#include "Yoga.h" #ifdef _MSC_VER #include @@ -30,7 +30,7 @@ __forceinline const float fmaxf(const float a, const float b) { #endif #endif -typedef struct CSSCachedMeasurement { +typedef struct YGCachedMeasurement { float availableWidth; float availableHeight; YGMeasureMode widthMeasureMode; @@ -38,13 +38,13 @@ typedef struct CSSCachedMeasurement { float computedWidth; float computedHeight; -} CSSCachedMeasurement; +} YGCachedMeasurement; // This value was chosen based on empiracle data. Even the most complicated // layouts should not require more than 16 entries to fit within the cache. -enum { CSS_MAX_CACHED_RESULT_COUNT = 16 }; +enum { YG_MAX_CACHED_RESULT_COUNT = 16 }; -typedef struct CSSLayout { +typedef struct YGLayout { float position[4]; float dimensions[2]; YGDirection direction; @@ -58,13 +58,13 @@ typedef struct CSSLayout { YGDirection lastParentDirection; uint32_t nextCachedMeasurementsIndex; - CSSCachedMeasurement cachedMeasurements[CSS_MAX_CACHED_RESULT_COUNT]; + YGCachedMeasurement cachedMeasurements[YG_MAX_CACHED_RESULT_COUNT]; float measuredDimensions[2]; - CSSCachedMeasurement cachedLayout; -} CSSLayout; + YGCachedMeasurement cachedLayout; +} YGLayout; -typedef struct CSSStyle { +typedef struct YGStyle { YGDirection direction; YGFlexDirection flexDirection; YGJustify justifyContent; @@ -88,34 +88,34 @@ typedef struct CSSStyle { // Yoga specific properties, not compatible with flexbox specification float aspectRatio; -} CSSStyle; +} YGStyle; -typedef struct CSSNode { - CSSStyle style; - CSSLayout layout; +typedef struct YGNode { + YGStyle style; + YGLayout layout; uint32_t lineIndex; bool hasNewLayout; - CSSNodeRef parent; - CSSNodeListRef children; + YGNodeRef parent; + YGNodeListRef children; bool isDirty; - struct CSSNode *nextChild; + struct YGNode *nextChild; - CSSMeasureFunc measure; - CSSPrintFunc print; + YGMeasureFunc measure; + YGPrintFunc print; void *context; -} CSSNode; +} YGNode; -static void _CSSNodeMarkDirty(const CSSNodeRef node); +static void YGNodeMarkDirtyInternal(const YGNodeRef node); -CSSMalloc gCSSMalloc = &malloc; -CSSCalloc gCSSCalloc = &calloc; -CSSRealloc gCSSRealloc = &realloc; -CSSFree gCSSFree = &free; +YGMalloc gYGMalloc = &malloc; +YGCalloc gYGCalloc = &calloc; +YGRealloc gYGRealloc = &realloc; +YGFree gYGFree = &free; #ifdef ANDROID #include -static int _csslayoutAndroidLog(YGLogLevel level, const char *format, va_list args) { +static int YGAndroidLog(YGLogLevel level, const char *format, va_list args) { int androidLevel = YGLogLevelDebug; switch (level) { case YGLogLevelError: @@ -136,12 +136,12 @@ static int _csslayoutAndroidLog(YGLogLevel level, const char *format, va_list ar case YGLogLevelCount: break; } - const int result = __android_log_vprint(androidLevel, "css-layout", format, args); + const int result = __android_log_vprint(androidLevel, "YG-layout", format, args); return result; } -static CSSLogger gLogger = &_csslayoutAndroidLog; +static YGLogger gLogger = &YGAndroidLog; #else -static int _csslayoutDefaultLog(YGLogLevel level, const char *format, va_list args) { +static int YGDefaultLog(YGLogLevel level, const char *format, va_list args) { switch (level) { case YGLogLevelError: return vfprintf(stderr, format, args); @@ -153,28 +153,28 @@ static int _csslayoutDefaultLog(YGLogLevel level, const char *format, va_list ar return vprintf(format, args); } } -static CSSLogger gLogger = &_csslayoutDefaultLog; +static YGLogger gLogger = &YGDefaultLog; #endif -static inline float computedEdgeValue(const float edges[YGEdgeCount], - const YGEdge edge, - const float defaultValue) { - CSS_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); +static inline float YGComputedEdgeValue(const float edges[YGEdgeCount], + const YGEdge edge, + const float defaultValue) { + YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (!CSSValueIsUndefined(edges[edge])) { + if (!YGValueIsUndefined(edges[edge])) { return edges[edge]; } - if ((edge == YGEdgeTop || edge == YGEdgeBottom) && !CSSValueIsUndefined(edges[YGEdgeVertical])) { + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && !YGValueIsUndefined(edges[YGEdgeVertical])) { return edges[YGEdgeVertical]; } if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && - !CSSValueIsUndefined(edges[YGEdgeHorizontal])) { + !YGValueIsUndefined(edges[YGEdgeHorizontal])) { return edges[YGEdgeHorizontal]; } - if (!CSSValueIsUndefined(edges[YGEdgeAll])) { + if (!YGValueIsUndefined(edges[YGEdgeAll])) { return edges[YGEdgeAll]; } @@ -187,55 +187,55 @@ static inline float computedEdgeValue(const float edges[YGEdgeCount], int32_t gNodeInstanceCount = 0; -CSSNodeRef CSSNodeNew(void) { - const CSSNodeRef node = gCSSCalloc(1, sizeof(CSSNode)); - CSS_ASSERT(node, "Could not allocate memory for node"); +YGNodeRef YGNodeNew(void) { + const YGNodeRef node = gYGCalloc(1, sizeof(YGNode)); + YG_ASSERT(node, "Could not allocate memory for node"); gNodeInstanceCount++; - CSSNodeInit(node); + YGNodeInit(node); return node; } -void CSSNodeFree(const CSSNodeRef node) { +void YGNodeFree(const YGNodeRef node) { if (node->parent) { - CSSNodeListDelete(node->parent->children, node); + YGNodeListDelete(node->parent->children, node); node->parent = NULL; } - const uint32_t childCount = CSSNodeChildCount(node); + const uint32_t childCount = YGNodeChildCount(node); for (uint32_t i = 0; i < childCount; i++) { - const CSSNodeRef child = CSSNodeGetChild(node, i); + const YGNodeRef child = YGNodeGetChild(node, i); child->parent = NULL; } - CSSNodeListFree(node->children); - gCSSFree(node); + YGNodeListFree(node->children); + gYGFree(node); gNodeInstanceCount--; } -void CSSNodeFreeRecursive(const CSSNodeRef root) { - while (CSSNodeChildCount(root) > 0) { - const CSSNodeRef child = CSSNodeGetChild(root, 0); - CSSNodeRemoveChild(root, child); - CSSNodeFreeRecursive(child); +void YGNodeFreeRecursive(const YGNodeRef root) { + while (YGNodeChildCount(root) > 0) { + const YGNodeRef child = YGNodeGetChild(root, 0); + YGNodeRemoveChild(root, child); + YGNodeFreeRecursive(child); } - CSSNodeFree(root); + YGNodeFree(root); } -void CSSNodeReset(const CSSNodeRef node) { - CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot reset a node which still has children attached"); - CSS_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent"); +void YGNodeReset(const YGNodeRef node) { + YG_ASSERT(YGNodeChildCount(node) == 0, "Cannot reset a node which still has children attached"); + YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent"); - CSSNodeListFree(node->children); - memset(node, 0, sizeof(CSSNode)); - CSSNodeInit(node); + YGNodeListFree(node->children); + memset(node, 0, sizeof(YGNode)); + YGNodeInit(node); } -int32_t CSSNodeGetInstanceCount(void) { +int32_t YGNodeGetInstanceCount(void) { return gNodeInstanceCount; } -void CSSNodeInit(const CSSNodeRef node) { +void YGNodeInit(const YGNodeRef node) { node->parent = NULL; node->children = NULL; node->hasNewLayout = true; @@ -289,386 +289,396 @@ void CSSNodeInit(const CSSNodeRef node) { node->layout.cachedLayout.computedHeight = -1; } -static void _CSSNodeMarkDirty(const CSSNodeRef node) { +static void YGNodeMarkDirtyInternal(const YGNodeRef node) { if (!node->isDirty) { node->isDirty = true; node->layout.computedFlexBasis = YGUndefined; if (node->parent) { - _CSSNodeMarkDirty(node->parent); + YGNodeMarkDirtyInternal(node->parent); } } } -void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { +void YGNodeSetMeasureFunc(const YGNodeRef node, YGMeasureFunc measureFunc) { if (measureFunc == NULL) { node->measure = NULL; } else { - CSS_ASSERT(CSSNodeChildCount(node) == 0, - "Cannot set measure function: Nodes with measure functions cannot have children."); + YG_ASSERT(YGNodeChildCount(node) == 0, + "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } } -CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) { +YGMeasureFunc YGNodeGetMeasureFunc(const YGNodeRef node) { return node->measure; } -void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index) { - CSS_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first."); - CSS_ASSERT(node->measure == NULL, - "Cannot add child: Nodes with measure functions cannot have children."); - CSSNodeListInsert(&node->children, child, index); +void YGNodeInsertChild(const YGNodeRef node, const YGNodeRef child, const uint32_t index) { + YG_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first."); + YG_ASSERT(node->measure == NULL, + "Cannot add child: Nodes with measure functions cannot have children."); + YGNodeListInsert(&node->children, child, index); child->parent = node; - _CSSNodeMarkDirty(node); + YGNodeMarkDirtyInternal(node); } -void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child) { - if (CSSNodeListDelete(node->children, child) != NULL) { +void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child) { + if (YGNodeListDelete(node->children, child) != NULL) { child->parent = NULL; - _CSSNodeMarkDirty(node); + YGNodeMarkDirtyInternal(node); } } -CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index) { - return CSSNodeListGet(node->children, index); +YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) { + return YGNodeListGet(node->children, index); } -inline uint32_t CSSNodeChildCount(const CSSNodeRef node) { - return CSSNodeListCount(node->children); +inline uint32_t YGNodeChildCount(const YGNodeRef node) { + return YGNodeListCount(node->children); } -void CSSNodeMarkDirty(const CSSNodeRef node) { - CSS_ASSERT(node->measure != NULL, - "Only leaf nodes with custom measure functions" - "should manually mark themselves as dirty"); - _CSSNodeMarkDirty(node); +void YGNodeMarkDirty(const YGNodeRef node) { + YG_ASSERT(node->measure != NULL, + "Only leaf nodes with custom measure functions" + "should manually mark themselves as dirty"); + YGNodeMarkDirtyInternal(node); } -bool CSSNodeIsDirty(const CSSNodeRef node) { +bool YGNodeIsDirty(const YGNodeRef node) { return node->isDirty; } -void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode) { - if (memcmp(&dstNode->style, &srcNode->style, sizeof(CSSStyle)) != 0) { - memcpy(&dstNode->style, &srcNode->style, sizeof(CSSStyle)); - _CSSNodeMarkDirty(dstNode); +void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) { + if (memcmp(&dstNode->style, &srcNode->style, sizeof(YGStyle)) != 0) { + memcpy(&dstNode->style, &srcNode->style, sizeof(YGStyle)); + YGNodeMarkDirtyInternal(dstNode); } } -inline float CSSNodeStyleGetFlexGrow(const CSSNodeRef node) { - if (!CSSValueIsUndefined(node->style.flexGrow)) { +inline float YGNodeStyleGetFlexGrow(const YGNodeRef node) { + if (!YGValueIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; } - if (!CSSValueIsUndefined(node->style.flex) && node->style.flex > 0) { + if (!YGValueIsUndefined(node->style.flex) && node->style.flex > 0) { return node->style.flex; } return 0; } -inline float CSSNodeStyleGetFlexShrink(const CSSNodeRef node) { - if (!CSSValueIsUndefined(node->style.flexShrink)) { +inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) { + if (!YGValueIsUndefined(node->style.flexShrink)) { return node->style.flexShrink; } - if (!CSSValueIsUndefined(node->style.flex) && node->style.flex < 0) { + if (!YGValueIsUndefined(node->style.flex) && node->style.flex < 0) { return -node->style.flex; } return 0; } -inline float CSSNodeStyleGetFlexBasis(const CSSNodeRef node) { - if (!CSSValueIsUndefined(node->style.flexBasis)) { +inline float YGNodeStyleGetFlexBasis(const YGNodeRef node) { + if (!YGValueIsUndefined(node->style.flexBasis)) { return node->style.flexBasis; } - if (!CSSValueIsUndefined(node->style.flex)) { + if (!YGValueIsUndefined(node->style.flex)) { return node->style.flex > 0 ? 0 : YGUndefined; } return YGUndefined; } -void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { +void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { if (node->style.flex != flex) { node->style.flex = flex; - _CSSNodeMarkDirty(node); + YGNodeMarkDirtyInternal(node); } } -#define CSS_NODE_PROPERTY_IMPL(type, name, paramName, instanceName) \ - void CSSNodeSet##name(const CSSNodeRef node, type paramName) { \ - node->instanceName = paramName; \ - } \ - \ - type CSSNodeGet##name(const CSSNodeRef node) { \ - return node->instanceName; \ +#define YG_NODE_PROPERTY_IMPL(type, name, paramName, instanceName) \ + void YGNodeSet##name(const YGNodeRef node, type paramName) { \ + node->instanceName = paramName; \ + } \ + \ + type YGNodeGet##name(const YGNodeRef node) { \ + return node->instanceName; \ } -#define CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \ - void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName) { \ - if (node->style.instanceName != paramName) { \ - node->style.instanceName = paramName; \ - _CSSNodeMarkDirty(node); \ - } \ +#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \ + void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ + if (node->style.instanceName != paramName) { \ + node->style.instanceName = paramName; \ + YGNodeMarkDirtyInternal(node); \ + } \ } -#define CSS_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \ - CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \ - \ - type CSSNodeStyleGet##name(const CSSNodeRef node) { \ - return node->style.instanceName; \ +#define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \ + YG_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \ + \ + type YGNodeStyleGet##name(const YGNodeRef node) { \ + return node->style.instanceName; \ } -#define CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName, defaultValue) \ - void CSSNodeStyleSet##name(const CSSNodeRef node, const YGEdge edge, const type paramName) { \ - if (node->style.instanceName[edge] != paramName) { \ - node->style.instanceName[edge] = paramName; \ - _CSSNodeMarkDirty(node); \ - } \ - } \ - \ - type CSSNodeStyleGet##name(const CSSNodeRef node, const YGEdge edge) { \ - return computedEdgeValue(node->style.instanceName, edge, defaultValue); \ +#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 CSS_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ - type CSSNodeLayoutGet##name(const CSSNodeRef node) { \ - return node->layout.instanceName; \ +#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ + type YGNodeLayoutGet##name(const YGNodeRef node) { \ + return node->layout.instanceName; \ } -CSS_NODE_PROPERTY_IMPL(void *, Context, context, context); -CSS_NODE_PROPERTY_IMPL(CSSPrintFunc, PrintFunc, printFunc, print); -CSS_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); +YG_NODE_PROPERTY_IMPL(void *, Context, context, context); +YG_NODE_PROPERTY_IMPL(YGPrintFunc, PrintFunc, printFunc, print); +YG_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); -CSS_NODE_STYLE_PROPERTY_IMPL(YGDirection, Direction, direction, direction); -CSS_NODE_STYLE_PROPERTY_IMPL(YGFlexDirection, FlexDirection, flexDirection, flexDirection); -CSS_NODE_STYLE_PROPERTY_IMPL(YGJustify, JustifyContent, justifyContent, justifyContent); -CSS_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignContent, alignContent, alignContent); -CSS_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignItems, alignItems, alignItems); -CSS_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignSelf, alignSelf, alignSelf); -CSS_NODE_STYLE_PROPERTY_IMPL(YGPositionType, PositionType, positionType, positionType); -CSS_NODE_STYLE_PROPERTY_IMPL(YGWrap, FlexWrap, flexWrap, flexWrap); -CSS_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow); +YG_NODE_STYLE_PROPERTY_IMPL(YGDirection, Direction, direction, direction); +YG_NODE_STYLE_PROPERTY_IMPL(YGFlexDirection, FlexDirection, flexDirection, flexDirection); +YG_NODE_STYLE_PROPERTY_IMPL(YGJustify, JustifyContent, justifyContent, justifyContent); +YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignContent, alignContent, alignContent); +YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignItems, alignItems, alignItems); +YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignSelf, alignSelf, alignSelf); +YG_NODE_STYLE_PROPERTY_IMPL(YGPositionType, PositionType, positionType, positionType); +YG_NODE_STYLE_PROPERTY_IMPL(YGWrap, FlexWrap, flexWrap, flexWrap); +YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow); -CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); -CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink); -CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexBasis, flexBasis, flexBasis); +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); -CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Position, position, position, YGUndefined); -CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Margin, margin, margin, 0); -CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Padding, padding, padding, 0); -CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border, 0); +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); -CSS_NODE_STYLE_PROPERTY_IMPL(float, Width, width, dimensions[YGDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, Height, height, dimensions[YGDimensionHeight]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MinWidth, minWidth, minDimensions[YGDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MinHeight, minHeight, minDimensions[YGDimensionHeight]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[YGDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[YGDimensionHeight]); +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]); // Yoga specific properties, not compatible with flexbox specification -CSS_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio); +YG_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft]); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop]); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]); +YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]); +YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction); uint32_t gCurrentGenerationCount = 0; -bool layoutNodeInternal(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGDirection parentDirection, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode, - const bool performLayout, - const char *reason); +bool YGLayoutNodeInternal(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, + const bool performLayout, + const char *reason); -inline bool CSSValueIsUndefined(const float value) { +inline bool YGValueIsUndefined(const float value) { return isnan(value); } -static inline bool eq(const float a, const float b) { - if (CSSValueIsUndefined(a)) { - return CSSValueIsUndefined(b); +static inline bool YGFloatsEqual(const float a, const float b) { + if (YGValueIsUndefined(a)) { + return YGValueIsUndefined(b); } return fabs(a - b) < 0.0001; } -static void indent(const uint32_t n) { +static void YGIndent(const uint32_t n) { for (uint32_t i = 0; i < n; i++) { - CSSLog(YGLogLevelDebug, " "); + YGLog(YGLogLevelDebug, " "); } } -static void printNumberIfNotZero(const char *str, const float number) { - if (!eq(number, 0)) { - CSSLog(YGLogLevelDebug, "%s: %g, ", str, number); +static void YGPrintNumberIfNotZero(const char *str, const float number) { + if (!YGFloatsEqual(number, 0)) { + YGLog(YGLogLevelDebug, "%s: %g, ", str, number); } } -static void printNumberIfNotUndefined(const char *str, const float number) { - if (!CSSValueIsUndefined(number)) { - CSSLog(YGLogLevelDebug, "%s: %g, ", str, number); +static void YGPrintNumberIfNotUndefined(const char *str, const float number) { + if (!YGValueIsUndefined(number)) { + YGLog(YGLogLevelDebug, "%s: %g, ", str, number); } } -static bool eqFour(const float four[4]) { - return eq(four[0], four[1]) && eq(four[0], four[2]) && eq(four[0], four[3]); +static bool YGFourFloatsEqual(const float four[4]) { + return YGFloatsEqual(four[0], four[1]) && YGFloatsEqual(four[0], four[2]) && + YGFloatsEqual(four[0], four[3]); } -static void _CSSNodePrint(const CSSNodeRef node, - const YGPrintOptions options, - const uint32_t level) { - indent(level); - CSSLog(YGLogLevelDebug, "{"); +static void YGNodePrintInternal(const YGNodeRef node, + const YGPrintOptions options, + const uint32_t level) { + YGIndent(level); + YGLog(YGLogLevelDebug, "{"); if (node->print) { node->print(node); } if (options & YGPrintOptionsLayout) { - CSSLog(YGLogLevelDebug, "layout: {"); - CSSLog(YGLogLevelDebug, "width: %g, ", node->layout.dimensions[YGDimensionWidth]); - CSSLog(YGLogLevelDebug, "height: %g, ", node->layout.dimensions[YGDimensionHeight]); - CSSLog(YGLogLevelDebug, "top: %g, ", node->layout.position[YGEdgeTop]); - CSSLog(YGLogLevelDebug, "left: %g", node->layout.position[YGEdgeLeft]); - CSSLog(YGLogLevelDebug, "}, "); + YGLog(YGLogLevelDebug, "layout: {"); + YGLog(YGLogLevelDebug, "width: %g, ", node->layout.dimensions[YGDimensionWidth]); + YGLog(YGLogLevelDebug, "height: %g, ", node->layout.dimensions[YGDimensionHeight]); + YGLog(YGLogLevelDebug, "top: %g, ", node->layout.position[YGEdgeTop]); + YGLog(YGLogLevelDebug, "left: %g", node->layout.position[YGEdgeLeft]); + YGLog(YGLogLevelDebug, "}, "); } if (options & YGPrintOptionsStyle) { if (node->style.flexDirection == YGFlexDirectionColumn) { - CSSLog(YGLogLevelDebug, "flexDirection: 'column', "); + YGLog(YGLogLevelDebug, "flexDirection: 'column', "); } else if (node->style.flexDirection == YGFlexDirectionColumnReverse) { - CSSLog(YGLogLevelDebug, "flexDirection: 'column-reverse', "); + YGLog(YGLogLevelDebug, "flexDirection: 'column-reverse', "); } else if (node->style.flexDirection == YGFlexDirectionRow) { - CSSLog(YGLogLevelDebug, "flexDirection: 'row', "); + YGLog(YGLogLevelDebug, "flexDirection: 'row', "); } else if (node->style.flexDirection == YGFlexDirectionRowReverse) { - CSSLog(YGLogLevelDebug, "flexDirection: 'row-reverse', "); + YGLog(YGLogLevelDebug, "flexDirection: 'row-reverse', "); } if (node->style.justifyContent == YGJustifyCenter) { - CSSLog(YGLogLevelDebug, "justifyContent: 'center', "); + YGLog(YGLogLevelDebug, "justifyContent: 'center', "); } else if (node->style.justifyContent == YGJustifyFlexEnd) { - CSSLog(YGLogLevelDebug, "justifyContent: 'flex-end', "); + YGLog(YGLogLevelDebug, "justifyContent: 'flex-end', "); } else if (node->style.justifyContent == YGJustifySpaceAround) { - CSSLog(YGLogLevelDebug, "justifyContent: 'space-around', "); + YGLog(YGLogLevelDebug, "justifyContent: 'space-around', "); } else if (node->style.justifyContent == YGJustifySpaceBetween) { - CSSLog(YGLogLevelDebug, "justifyContent: 'space-between', "); + YGLog(YGLogLevelDebug, "justifyContent: 'space-between', "); } if (node->style.alignItems == YGAlignCenter) { - CSSLog(YGLogLevelDebug, "alignItems: 'center', "); + YGLog(YGLogLevelDebug, "alignItems: 'center', "); } else if (node->style.alignItems == YGAlignFlexEnd) { - CSSLog(YGLogLevelDebug, "alignItems: 'flex-end', "); + YGLog(YGLogLevelDebug, "alignItems: 'flex-end', "); } else if (node->style.alignItems == YGAlignStretch) { - CSSLog(YGLogLevelDebug, "alignItems: 'stretch', "); + YGLog(YGLogLevelDebug, "alignItems: 'stretch', "); } if (node->style.alignContent == YGAlignCenter) { - CSSLog(YGLogLevelDebug, "alignContent: 'center', "); + YGLog(YGLogLevelDebug, "alignContent: 'center', "); } else if (node->style.alignContent == YGAlignFlexEnd) { - CSSLog(YGLogLevelDebug, "alignContent: 'flex-end', "); + YGLog(YGLogLevelDebug, "alignContent: 'flex-end', "); } else if (node->style.alignContent == YGAlignStretch) { - CSSLog(YGLogLevelDebug, "alignContent: 'stretch', "); + YGLog(YGLogLevelDebug, "alignContent: 'stretch', "); } if (node->style.alignSelf == YGAlignFlexStart) { - CSSLog(YGLogLevelDebug, "alignSelf: 'flex-start', "); + YGLog(YGLogLevelDebug, "alignSelf: 'flex-start', "); } else if (node->style.alignSelf == YGAlignCenter) { - CSSLog(YGLogLevelDebug, "alignSelf: 'center', "); + YGLog(YGLogLevelDebug, "alignSelf: 'center', "); } else if (node->style.alignSelf == YGAlignFlexEnd) { - CSSLog(YGLogLevelDebug, "alignSelf: 'flex-end', "); + YGLog(YGLogLevelDebug, "alignSelf: 'flex-end', "); } else if (node->style.alignSelf == YGAlignStretch) { - CSSLog(YGLogLevelDebug, "alignSelf: 'stretch', "); + YGLog(YGLogLevelDebug, "alignSelf: 'stretch', "); } - printNumberIfNotUndefined("flexGrow", CSSNodeStyleGetFlexGrow(node)); - printNumberIfNotUndefined("flexShrink", CSSNodeStyleGetFlexShrink(node)); - printNumberIfNotUndefined("flexBasis", CSSNodeStyleGetFlexBasis(node)); + YGPrintNumberIfNotUndefined("flexGrow", YGNodeStyleGetFlexGrow(node)); + YGPrintNumberIfNotUndefined("flexShrink", YGNodeStyleGetFlexShrink(node)); + YGPrintNumberIfNotUndefined("flexBasis", YGNodeStyleGetFlexBasis(node)); if (node->style.overflow == YGOverflowHidden) { - CSSLog(YGLogLevelDebug, "overflow: 'hidden', "); + YGLog(YGLogLevelDebug, "overflow: 'hidden', "); } else if (node->style.overflow == YGOverflowVisible) { - CSSLog(YGLogLevelDebug, "overflow: 'visible', "); + YGLog(YGLogLevelDebug, "overflow: 'visible', "); } else if (node->style.overflow == YGOverflowScroll) { - CSSLog(YGLogLevelDebug, "overflow: 'scroll', "); + YGLog(YGLogLevelDebug, "overflow: 'scroll', "); } - if (eqFour(node->style.margin)) { - printNumberIfNotZero("margin", computedEdgeValue(node->style.margin, YGEdgeLeft, 0)); + if (YGFourFloatsEqual(node->style.margin)) { + YGPrintNumberIfNotZero("margin", YGComputedEdgeValue(node->style.margin, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("marginLeft", computedEdgeValue(node->style.margin, YGEdgeLeft, 0)); - printNumberIfNotZero("marginRight", computedEdgeValue(node->style.margin, YGEdgeRight, 0)); - printNumberIfNotZero("marginTop", computedEdgeValue(node->style.margin, YGEdgeTop, 0)); - printNumberIfNotZero("marginBottom", computedEdgeValue(node->style.margin, YGEdgeBottom, 0)); - printNumberIfNotZero("marginStart", computedEdgeValue(node->style.margin, YGEdgeStart, 0)); - printNumberIfNotZero("marginEnd", computedEdgeValue(node->style.margin, YGEdgeEnd, 0)); + 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)); } - if (eqFour(node->style.padding)) { - printNumberIfNotZero("padding", computedEdgeValue(node->style.padding, YGEdgeLeft, 0)); + if (YGFourFloatsEqual(node->style.padding)) { + YGPrintNumberIfNotZero("padding", YGComputedEdgeValue(node->style.padding, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("paddingLeft", computedEdgeValue(node->style.padding, YGEdgeLeft, 0)); - printNumberIfNotZero("paddingRight", computedEdgeValue(node->style.padding, YGEdgeRight, 0)); - printNumberIfNotZero("paddingTop", computedEdgeValue(node->style.padding, YGEdgeTop, 0)); - printNumberIfNotZero("paddingBottom", - computedEdgeValue(node->style.padding, YGEdgeBottom, 0)); - printNumberIfNotZero("paddingStart", computedEdgeValue(node->style.padding, YGEdgeStart, 0)); - printNumberIfNotZero("paddingEnd", computedEdgeValue(node->style.padding, YGEdgeEnd, 0)); + 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)); } - if (eqFour(node->style.border)) { - printNumberIfNotZero("borderWidth", computedEdgeValue(node->style.border, YGEdgeLeft, 0)); + if (YGFourFloatsEqual(node->style.border)) { + YGPrintNumberIfNotZero("borderWidth", YGComputedEdgeValue(node->style.border, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("borderLeftWidth", computedEdgeValue(node->style.border, YGEdgeLeft, 0)); - printNumberIfNotZero("borderRightWidth", - computedEdgeValue(node->style.border, YGEdgeRight, 0)); - printNumberIfNotZero("borderTopWidth", computedEdgeValue(node->style.border, YGEdgeTop, 0)); - printNumberIfNotZero("borderBottomWidth", - computedEdgeValue(node->style.border, YGEdgeBottom, 0)); - printNumberIfNotZero("borderStartWidth", - computedEdgeValue(node->style.border, YGEdgeStart, 0)); - printNumberIfNotZero("borderEndWidth", computedEdgeValue(node->style.border, YGEdgeEnd, 0)); + 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)); } - printNumberIfNotUndefined("width", node->style.dimensions[YGDimensionWidth]); - printNumberIfNotUndefined("height", node->style.dimensions[YGDimensionHeight]); - printNumberIfNotUndefined("maxWidth", node->style.maxDimensions[YGDimensionWidth]); - printNumberIfNotUndefined("maxHeight", node->style.maxDimensions[YGDimensionHeight]); - printNumberIfNotUndefined("minWidth", node->style.minDimensions[YGDimensionWidth]); - printNumberIfNotUndefined("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) { - CSSLog(YGLogLevelDebug, "position: 'absolute', "); + YGLog(YGLogLevelDebug, "position: 'absolute', "); } - printNumberIfNotUndefined("left", - computedEdgeValue(node->style.position, YGEdgeLeft, YGUndefined)); - printNumberIfNotUndefined("right", - computedEdgeValue(node->style.position, YGEdgeRight, YGUndefined)); - printNumberIfNotUndefined("top", - computedEdgeValue(node->style.position, YGEdgeTop, YGUndefined)); - printNumberIfNotUndefined("bottom", - computedEdgeValue(node->style.position, YGEdgeBottom, YGUndefined)); + 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)); } - const uint32_t childCount = CSSNodeListCount(node->children); + const uint32_t childCount = YGNodeListCount(node->children); if (options & YGPrintOptionsChildren && childCount > 0) { - CSSLog(YGLogLevelDebug, "children: [\n"); + YGLog(YGLogLevelDebug, "children: [\n"); for (uint32_t i = 0; i < childCount; i++) { - _CSSNodePrint(CSSNodeGetChild(node, i), options, level + 1); + YGNodePrintInternal(YGNodeGetChild(node, i), options, level + 1); } - indent(level); - CSSLog(YGLogLevelDebug, "]},\n"); + YGIndent(level); + YGLog(YGLogLevelDebug, "]},\n"); } else { - CSSLog(YGLogLevelDebug, "},\n"); + YGLog(YGLogLevelDebug, "},\n"); } } -void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options) { - _CSSNodePrint(node, options, 0); +void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) { + YGNodePrintInternal(node, options, 0); } static const YGEdge leading[4] = { @@ -696,88 +706,91 @@ static const YGDimension dim[4] = { [YGFlexDirectionRowReverse] = YGDimensionWidth, }; -static inline bool isRowDirection(const YGFlexDirection flexDirection) { +static inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) { return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse; } -static inline bool isColumnDirection(const YGFlexDirection flexDirection) { +static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) { return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse; } -static inline float getLeadingMargin(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[YGEdgeStart])) { +static inline float YGNodeLeadingMargin(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeStart])) { return node->style.margin[YGEdgeStart]; } - return computedEdgeValue(node->style.margin, leading[axis], 0); + return YGComputedEdgeValue(node->style.margin, leading[axis], 0); } -static float getTrailingMargin(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[YGEdgeEnd])) { +static float YGNodeTrailingMargin(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.margin[YGEdgeEnd])) { return node->style.margin[YGEdgeEnd]; } - return computedEdgeValue(node->style.margin, trailing[axis], 0); + return YGComputedEdgeValue(node->style.margin, trailing[axis], 0); } -static float getLeadingPadding(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[YGEdgeStart]) && +static float YGNodeLeadingPadding(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeStart]) && node->style.padding[YGEdgeStart] >= 0) { return node->style.padding[YGEdgeStart]; } - return fmaxf(computedEdgeValue(node->style.padding, leading[axis], 0), 0); + return fmaxf(YGComputedEdgeValue(node->style.padding, leading[axis], 0), 0); } -static float getTrailingPadding(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[YGEdgeEnd]) && +static float YGNodeTrailingPadding(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.padding[YGEdgeEnd]) && node->style.padding[YGEdgeEnd] >= 0) { return node->style.padding[YGEdgeEnd]; } - return fmaxf(computedEdgeValue(node->style.padding, trailing[axis], 0), 0); + return fmaxf(YGComputedEdgeValue(node->style.padding, trailing[axis], 0), 0); } -static float getLeadingBorder(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[YGEdgeStart]) && +static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeStart]) && node->style.border[YGEdgeStart] >= 0) { return node->style.border[YGEdgeStart]; } - return fmaxf(computedEdgeValue(node->style.border, leading[axis], 0), 0); + return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], 0), 0); } -static float getTrailingBorder(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[YGEdgeEnd]) && +static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis) && !YGValueIsUndefined(node->style.border[YGEdgeEnd]) && node->style.border[YGEdgeEnd] >= 0) { return node->style.border[YGEdgeEnd]; } - return fmaxf(computedEdgeValue(node->style.border, trailing[axis], 0), 0); + return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], 0), 0); } -static inline float getLeadingPaddingAndBorder(const CSSNodeRef node, const YGFlexDirection axis) { - return getLeadingPadding(node, axis) + getLeadingBorder(node, axis); +static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node, + const YGFlexDirection axis) { + return YGNodeLeadingPadding(node, axis) + YGNodeLeadingBorder(node, axis); } -static inline float getTrailingPaddingAndBorder(const CSSNodeRef node, const YGFlexDirection axis) { - return getTrailingPadding(node, axis) + getTrailingBorder(node, axis); +static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node, + const YGFlexDirection axis) { + return YGNodeTrailingPadding(node, axis) + YGNodeTrailingBorder(node, axis); } -static inline float getMarginAxis(const CSSNodeRef node, const YGFlexDirection axis) { - return getLeadingMargin(node, axis) + getTrailingMargin(node, axis); +static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis) { + return YGNodeLeadingMargin(node, axis) + YGNodeTrailingMargin(node, axis); } -static inline float getPaddingAndBorderAxis(const CSSNodeRef node, const YGFlexDirection axis) { - return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis); +static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, + const YGFlexDirection axis) { + return YGNodeLeadingPaddingAndBorder(node, axis) + YGNodeTrailingPaddingAndBorder(node, axis); } -static inline YGAlign getAlignItem(const CSSNodeRef node, const CSSNodeRef child) { +static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { return child->style.alignSelf == YGAlignAuto ? node->style.alignItems : child->style.alignSelf; } -static inline YGDirection resolveDirection(const CSSNodeRef node, - const YGDirection parentDirection) { +static inline YGDirection YGNodeResolveDirection(const YGNodeRef node, + const YGDirection parentDirection) { if (node->style.direction == YGDirectionInherit) { return parentDirection > YGDirectionInherit ? parentDirection : YGDirectionLTR; } else { @@ -785,8 +798,8 @@ static inline YGDirection resolveDirection(const CSSNodeRef node, } } -static inline YGFlexDirection resolveAxis(const YGFlexDirection flexDirection, - const YGDirection direction) { +static inline YGFlexDirection YGFlexDirectionResolve(const YGFlexDirection flexDirection, + const YGDirection direction) { if (direction == YGDirectionRTL) { if (flexDirection == YGFlexDirectionRow) { return YGFlexDirectionRowReverse; @@ -798,111 +811,117 @@ static inline YGFlexDirection resolveAxis(const YGFlexDirection flexDirection, return flexDirection; } -static YGFlexDirection getCrossFlexDirection(const YGFlexDirection flexDirection, - const YGDirection direction) { - return isColumnDirection(flexDirection) ? resolveAxis(YGFlexDirectionRow, direction) - : YGFlexDirectionColumn; +static YGFlexDirection YGFlexDirectionCross(const YGFlexDirection flexDirection, + const YGDirection direction) { + return YGFlexDirectionIsColumn(flexDirection) + ? YGFlexDirectionResolve(YGFlexDirectionRow, direction) + : YGFlexDirectionColumn; } -static inline bool isFlex(const CSSNodeRef node) { +static inline bool YGNodeIsFlex(const YGNodeRef node) { return (node->style.positionType == YGPositionTypeRelative && (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); } -static inline float getDimWithMargin(const CSSNodeRef node, const YGFlexDirection axis) { - return node->layout.measuredDimensions[dim[axis]] + getLeadingMargin(node, axis) + - getTrailingMargin(node, axis); +static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis) { + return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis) + + YGNodeTrailingMargin(node, axis); } -static inline bool isStyleDimDefined(const CSSNodeRef node, const YGFlexDirection axis) { +static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const float value = node->style.dimensions[dim[axis]]; - return !CSSValueIsUndefined(value) && value >= 0.0; + return !YGValueIsUndefined(value) && value >= 0.0; } -static inline bool isLayoutDimDefined(const CSSNodeRef node, const YGFlexDirection axis) { +static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) { const float value = node->layout.measuredDimensions[dim[axis]]; - return !CSSValueIsUndefined(value) && value >= 0.0; + return !YGValueIsUndefined(value) && value >= 0.0; } -static inline bool isLeadingPosDefined(const CSSNodeRef node, const YGFlexDirection axis) { - return (isRowDirection(axis) && - !CSSValueIsUndefined( - computedEdgeValue(node->style.position, YGEdgeStart, YGUndefined))) || - !CSSValueIsUndefined(computedEdgeValue(node->style.position, leading[axis], YGUndefined)); +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)); } -static inline bool isTrailingPosDefined(const CSSNodeRef node, const YGFlexDirection axis) { - return (isRowDirection(axis) && - !CSSValueIsUndefined(computedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined))) || - !CSSValueIsUndefined(computedEdgeValue(node->style.position, trailing[axis], YGUndefined)); +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)); } -static float getLeadingPosition(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis)) { - const float leadingPosition = computedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); - if (!CSSValueIsUndefined(leadingPosition)) { +static float YGNodeLeadingPosition(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis)) { + const float leadingPosition = + YGComputedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); + if (!YGValueIsUndefined(leadingPosition)) { return leadingPosition; } } - const float leadingPosition = computedEdgeValue(node->style.position, leading[axis], YGUndefined); + const float leadingPosition = + YGComputedEdgeValue(node->style.position, leading[axis], YGUndefined); - return CSSValueIsUndefined(leadingPosition) ? 0 : leadingPosition; + return YGValueIsUndefined(leadingPosition) ? 0 : leadingPosition; } -static float getTrailingPosition(const CSSNodeRef node, const YGFlexDirection axis) { - if (isRowDirection(axis)) { - const float trailingPosition = computedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); - if (!CSSValueIsUndefined(trailingPosition)) { +static float YGNodeTrailingPosition(const YGNodeRef node, const YGFlexDirection axis) { + if (YGFlexDirectionIsRow(axis)) { + const float trailingPosition = + YGComputedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); + if (!YGValueIsUndefined(trailingPosition)) { return trailingPosition; } } const float trailingPosition = - computedEdgeValue(node->style.position, trailing[axis], YGUndefined); + YGComputedEdgeValue(node->style.position, trailing[axis], YGUndefined); - return CSSValueIsUndefined(trailingPosition) ? 0 : trailingPosition; + return YGValueIsUndefined(trailingPosition) ? 0 : trailingPosition; } -static float boundAxisWithinMinAndMax(const CSSNodeRef node, - const YGFlexDirection axis, - const float value) { +static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node, + const YGFlexDirection axis, + const float value) { float min = YGUndefined; float max = YGUndefined; - if (isColumnDirection(axis)) { + if (YGFlexDirectionIsColumn(axis)) { min = node->style.minDimensions[YGDimensionHeight]; max = node->style.maxDimensions[YGDimensionHeight]; - } else if (isRowDirection(axis)) { + } else if (YGFlexDirectionIsRow(axis)) { min = node->style.minDimensions[YGDimensionWidth]; max = node->style.maxDimensions[YGDimensionWidth]; } float boundValue = value; - if (!CSSValueIsUndefined(max) && max >= 0.0 && boundValue > max) { + if (!YGValueIsUndefined(max) && max >= 0.0 && boundValue > max) { boundValue = max; } - if (!CSSValueIsUndefined(min) && min >= 0.0 && boundValue < min) { + if (!YGValueIsUndefined(min) && min >= 0.0 && boundValue < min) { boundValue = min; } return boundValue; } -// Like boundAxisWithinMinAndMax but also ensures that the value doesn't go +// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't go // below the // padding and border amount. -static inline float boundAxis(const CSSNodeRef node, - const YGFlexDirection axis, - const float value) { - return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis)); +static inline float YGNodeBoundAxis(const YGNodeRef node, + const YGFlexDirection axis, + const float value) { + return fmaxf(YGNodeBoundAxisWithinMinAndMax(node, axis, value), + YGNodePaddingAndBorderForAxis(node, axis)); } -static void setTrailingPosition(const CSSNodeRef node, - const CSSNodeRef child, - const YGFlexDirection axis) { +static void YGNodeSetChildTrailingPosition(const YGNodeRef node, + const YGNodeRef child, + const YGFlexDirection axis) { const float size = child->layout.measuredDimensions[dim[axis]]; child->layout.position[trailing[axis]] = node->layout.measuredDimensions[dim[axis]] - size - child->layout.position[pos[axis]]; @@ -910,19 +929,19 @@ static void setTrailingPosition(const CSSNodeRef node, // If both left and right are defined, then use left. Otherwise return // +left or -right depending on which is defined. -static float getRelativePosition(const CSSNodeRef node, const YGFlexDirection axis) { - return isLeadingPosDefined(node, axis) ? getLeadingPosition(node, axis) - : -getTrailingPosition(node, axis); +static float YGNodeRelativePosition(const YGNodeRef node, const YGFlexDirection axis) { + return YGNodeIsLeadingPosDefined(node, axis) ? YGNodeLeadingPosition(node, axis) + : -YGNodeTrailingPosition(node, axis); } -static void constrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, float *size) { +static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, float *size) { switch (*mode) { case YGMeasureModeExactly: case YGMeasureModeAtMost: - *size = (CSSValueIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; + *size = (YGValueIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; break; case YGMeasureModeUndefined: - if (!CSSValueIsUndefined(maxSize)) { + if (!YGValueIsUndefined(maxSize)) { *mode = YGMeasureModeAtMost; *size = maxSize; } @@ -932,56 +951,58 @@ static void constrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, fl } } -static void setPosition(const CSSNodeRef node, const YGDirection direction) { - const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const YGFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); - const float relativePositionMain = getRelativePosition(node, mainAxis); - const float relativePositionCross = getRelativePosition(node, crossAxis); +static void YGNodeSetPosition(const YGNodeRef node, const YGDirection direction) { + 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); node->layout.position[leading[mainAxis]] = - getLeadingMargin(node, mainAxis) + relativePositionMain; + YGNodeLeadingMargin(node, mainAxis) + relativePositionMain; node->layout.position[trailing[mainAxis]] = - getTrailingMargin(node, mainAxis) + relativePositionMain; + YGNodeTrailingMargin(node, mainAxis) + relativePositionMain; node->layout.position[leading[crossAxis]] = - getLeadingMargin(node, crossAxis) + relativePositionCross; + YGNodeLeadingMargin(node, crossAxis) + relativePositionCross; node->layout.position[trailing[crossAxis]] = - getTrailingMargin(node, crossAxis) + relativePositionCross; + YGNodeTrailingMargin(node, crossAxis) + relativePositionCross; } -static void computeChildFlexBasis(const CSSNodeRef node, - const CSSNodeRef child, - const float width, - const YGMeasureMode widthMode, - const float height, - const YGMeasureMode heightMode, - const YGDirection direction) { - const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const bool isMainAxisRow = isRowDirection(mainAxis); +static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, + const YGNodeRef child, + const float width, + const YGMeasureMode widthMode, + const float height, + const YGMeasureMode heightMode, + const YGDirection direction) { + const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); + const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); float childWidth; float childHeight; YGMeasureMode childWidthMeasureMode; YGMeasureMode childHeightMeasureMode; - const bool isRowStyleDimDefined = isStyleDimDefined(child, YGFlexDirectionRow); - const bool isColumnStyleDimDefined = isStyleDimDefined(child, YGFlexDirectionColumn); + const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow); + const bool isColumnStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn); - if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && - !CSSValueIsUndefined(isMainAxisRow ? width : height)) { - if (CSSValueIsUndefined(child->layout.computedFlexBasis) || - (CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && + if (!YGValueIsUndefined(YGNodeStyleGetFlexBasis(child)) && + !YGValueIsUndefined(isMainAxisRow ? width : height)) { + if (YGValueIsUndefined(child->layout.computedFlexBasis) || + (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = - fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); + fmaxf(YGNodeStyleGetFlexBasis(child), YGNodePaddingAndBorderForAxis(child, mainAxis)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. - child->layout.computedFlexBasis = fmaxf(child->style.dimensions[YGDimensionWidth], - getPaddingAndBorderAxis(child, YGFlexDirectionRow)); + child->layout.computedFlexBasis = + fmaxf(child->style.dimensions[YGDimensionWidth], + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. - child->layout.computedFlexBasis = fmaxf(child->style.dimensions[YGDimensionHeight], - getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); + child->layout.computedFlexBasis = + fmaxf(child->style.dimensions[YGDimensionHeight], + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped // flex basis). @@ -991,13 +1012,13 @@ static void computeChildFlexBasis(const CSSNodeRef node, childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { - childWidth = - child->style.dimensions[YGDimensionWidth] + getMarginAxis(child, YGFlexDirectionRow); + childWidth = child->style.dimensions[YGDimensionWidth] + + YGNodeMarginForAxis(child, YGFlexDirectionRow); childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = - child->style.dimensions[YGDimensionHeight] + getMarginAxis(child, YGFlexDirectionColumn); + childHeight = child->style.dimensions[YGDimensionHeight] + + YGNodeMarginForAxis(child, YGFlexDirectionColumn); childHeightMeasureMode = YGMeasureModeExactly; } @@ -1005,7 +1026,7 @@ static void computeChildFlexBasis(const CSSNodeRef node, // but all major browsers appear to implement the following logic. if ((!isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (CSSValueIsUndefined(childWidth) && !CSSValueIsUndefined(width)) { + if (YGValueIsUndefined(childWidth) && !YGValueIsUndefined(width)) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } @@ -1013,7 +1034,7 @@ static void computeChildFlexBasis(const CSSNodeRef node, if ((isMainAxisRow && node->style.overflow == YGOverflowScroll) || node->style.overflow != YGOverflowScroll) { - if (CSSValueIsUndefined(childHeight) && !CSSValueIsUndefined(height)) { + if (YGValueIsUndefined(childHeight) && !YGValueIsUndefined(height)) { childHeight = height; childHeightMeasureMode = YGMeasureModeAtMost; } @@ -1022,185 +1043,188 @@ static void computeChildFlexBasis(const CSSNodeRef 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 && !CSSValueIsUndefined(width) && !isRowStyleDimDefined && - widthMode == YGMeasureModeExactly && getAlignItem(node, child) == YGAlignStretch) { + if (!isMainAxisRow && !YGValueIsUndefined(width) && !isRowStyleDimDefined && + widthMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childWidth = width; childWidthMeasureMode = YGMeasureModeExactly; } - if (isMainAxisRow && !CSSValueIsUndefined(height) && !isColumnStyleDimDefined && - heightMode == YGMeasureModeExactly && getAlignItem(node, child) == YGAlignStretch) { + if (isMainAxisRow && !YGValueIsUndefined(height) && !isColumnStyleDimDefined && + heightMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) { childHeight = height; childHeightMeasureMode = YGMeasureModeExactly; } - if (!CSSValueIsUndefined(child->style.aspectRatio)) { + if (!YGValueIsUndefined(child->style.aspectRatio)) { if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childWidth * child->style.aspectRatio, - getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); return; } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { - child->layout.computedFlexBasis = fmaxf(childHeight * child->style.aspectRatio, - getPaddingAndBorderAxis(child, YGFlexDirectionRow)); + child->layout.computedFlexBasis = + fmaxf(childHeight * child->style.aspectRatio, + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); return; } } - constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], - &childWidthMeasureMode, - &childWidth); - constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], - &childHeightMeasureMode, - &childHeight); + YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], + &childWidthMeasureMode, + &childWidth); + YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], + &childHeightMeasureMode, + &childHeight); // Measure the child - layoutNodeInternal(child, - childWidth, - childHeight, - direction, - childWidthMeasureMode, - childHeightMeasureMode, - false, - "measure"); + YGLayoutNodeInternal(child, + childWidth, + childHeight, + direction, + childWidthMeasureMode, + childHeightMeasureMode, + false, + "measure"); child->layout.computedFlexBasis = fmaxf(isMainAxisRow ? child->layout.measuredDimensions[YGDimensionWidth] : child->layout.measuredDimensions[YGDimensionHeight], - getPaddingAndBorderAxis(child, mainAxis)); + YGNodePaddingAndBorderForAxis(child, mainAxis)); } child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; } -static void absoluteLayoutChild(const CSSNodeRef node, - const CSSNodeRef child, - const float width, - const YGMeasureMode widthMode, - const YGDirection direction) { - const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const YGFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); - const bool isMainAxisRow = isRowDirection(mainAxis); +static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, + const YGNodeRef child, + const float width, + const YGMeasureMode widthMode, + const YGDirection direction) { + const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); + const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); + const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); float childWidth = YGUndefined; float childHeight = YGUndefined; YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined; YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; - if (isStyleDimDefined(child, YGFlexDirectionRow)) { + if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) { childWidth = - child->style.dimensions[YGDimensionWidth] + getMarginAxis(child, YGFlexDirectionRow); + child->style.dimensions[YGDimensionWidth] + YGNodeMarginForAxis(child, YGFlexDirectionRow); } else { // If the child doesn't have a specified width, compute the width based // on the left/right // offsets if they're defined. - if (isLeadingPosDefined(child, YGFlexDirectionRow) && - isTrailingPosDefined(child, YGFlexDirectionRow)) { + if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionRow) && + YGNodeIsTrailingPosDefined(child, YGFlexDirectionRow)) { childWidth = node->layout.measuredDimensions[YGDimensionWidth] - - (getLeadingBorder(node, YGFlexDirectionRow) + - getTrailingBorder(node, YGFlexDirectionRow)) - - (getLeadingPosition(child, YGFlexDirectionRow) + - getTrailingPosition(child, YGFlexDirectionRow)); - childWidth = boundAxis(child, YGFlexDirectionRow, childWidth); + (YGNodeLeadingBorder(node, YGFlexDirectionRow) + + YGNodeTrailingBorder(node, YGFlexDirectionRow)) - + (YGNodeLeadingPosition(child, YGFlexDirectionRow) + + YGNodeTrailingPosition(child, YGFlexDirectionRow)); + childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth); } } - if (isStyleDimDefined(child, YGFlexDirectionColumn)) { - childHeight = - child->style.dimensions[YGDimensionHeight] + getMarginAxis(child, YGFlexDirectionColumn); + if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) { + childHeight = child->style.dimensions[YGDimensionHeight] + + YGNodeMarginForAxis(child, YGFlexDirectionColumn); } else { // If the child doesn't have a specified height, compute the height // based on the top/bottom // offsets if they're defined. - if (isLeadingPosDefined(child, YGFlexDirectionColumn) && - isTrailingPosDefined(child, YGFlexDirectionColumn)) { + if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionColumn) && + YGNodeIsTrailingPosDefined(child, YGFlexDirectionColumn)) { childHeight = node->layout.measuredDimensions[YGDimensionHeight] - - (getLeadingBorder(node, YGFlexDirectionColumn) + - getTrailingBorder(node, YGFlexDirectionColumn)) - - (getLeadingPosition(child, YGFlexDirectionColumn) + - getTrailingPosition(child, YGFlexDirectionColumn)); - childHeight = boundAxis(child, YGFlexDirectionColumn, childHeight); + (YGNodeLeadingBorder(node, YGFlexDirectionColumn) + + YGNodeTrailingBorder(node, YGFlexDirectionColumn)) - + (YGNodeLeadingPosition(child, YGFlexDirectionColumn) + + YGNodeTrailingPosition(child, YGFlexDirectionColumn)); + childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight); } } // 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 (CSSValueIsUndefined(childWidth) ^ CSSValueIsUndefined(childHeight)) { - if (!CSSValueIsUndefined(child->style.aspectRatio)) { - if (CSSValueIsUndefined(childWidth)) { + if (YGValueIsUndefined(childWidth) ^ YGValueIsUndefined(childHeight)) { + if (!YGValueIsUndefined(child->style.aspectRatio)) { + if (YGValueIsUndefined(childWidth)) { childWidth = fmaxf(childHeight * child->style.aspectRatio, - getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); - } else if (CSSValueIsUndefined(childHeight)) { + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); + } else if (YGValueIsUndefined(childHeight)) { childHeight = fmaxf(childWidth * child->style.aspectRatio, - getPaddingAndBorderAxis(child, YGFlexDirectionRow)); + YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); } } } // If we're still missing one or the other dimension, measure the content. - if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) { + if (YGValueIsUndefined(childWidth) || YGValueIsUndefined(childHeight)) { childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - CSSValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefined(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 && CSSValueIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) { + if (!isMainAxisRow && YGValueIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) { childWidth = width; childWidthMeasureMode = YGMeasureModeAtMost; } - layoutNodeInternal(child, + YGLayoutNodeInternal(child, + childWidth, + childHeight, + direction, + childWidthMeasureMode, + childHeightMeasureMode, + false, + "abs-measure"); + childWidth = child->layout.measuredDimensions[YGDimensionWidth] + + YGNodeMarginForAxis(child, YGFlexDirectionRow); + childHeight = child->layout.measuredDimensions[YGDimensionHeight] + + YGNodeMarginForAxis(child, YGFlexDirectionColumn); + } + + YGLayoutNodeInternal(child, childWidth, childHeight, direction, - childWidthMeasureMode, - childHeightMeasureMode, - false, - "abs-measure"); - childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - getMarginAxis(child, YGFlexDirectionRow); - childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - getMarginAxis(child, YGFlexDirectionColumn); - } + YGMeasureModeExactly, + YGMeasureModeExactly, + true, + "abs-layout"); - layoutNodeInternal(child, - childWidth, - childHeight, - direction, - YGMeasureModeExactly, - YGMeasureModeExactly, - true, - "abs-layout"); - - if (isTrailingPosDefined(child, mainAxis) && !isLeadingPosDefined(child, mainAxis)) { + if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) { child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - child->layout.measuredDimensions[dim[mainAxis]] - - getTrailingBorder(node, mainAxis) - - getTrailingPosition(child, mainAxis); + YGNodeTrailingBorder(node, mainAxis) - + YGNodeTrailingPosition(child, mainAxis); } - if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) { + if (YGNodeIsTrailingPosDefined(child, crossAxis) && + !YGNodeIsLeadingPosDefined(child, crossAxis)) { child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - - getTrailingBorder(node, crossAxis) - - getTrailingPosition(child, crossAxis); + YGNodeTrailingBorder(node, crossAxis) - + YGNodeTrailingPosition(child, crossAxis); } } -static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode) { - CSS_ASSERT(node->measure, "Expected node to have custom measure function"); +static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode) { + YG_ASSERT(node->measure, "Expected node to have custom measure function"); - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, YGFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); + const float paddingAndBorderAxisColumn = + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; @@ -1208,88 +1232,91 @@ static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) { // Don't bother sizing the text if both dimensions are already defined. node->layout.measuredDimensions[YGDimensionWidth] = - boundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); node->layout.measuredDimensions[YGDimensionHeight] = - boundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); } else if (innerWidth <= 0 || innerHeight <= 0) { // Don't bother sizing the text if there's no horizontal or vertical // space. - node->layout.measuredDimensions[YGDimensionWidth] = boundAxis(node, YGFlexDirectionRow, 0); - node->layout.measuredDimensions[YGDimensionHeight] = boundAxis(node, YGFlexDirectionColumn, 0); + node->layout.measuredDimensions[YGDimensionWidth] = + YGNodeBoundAxis(node, YGFlexDirectionRow, 0); + node->layout.measuredDimensions[YGDimensionHeight] = + YGNodeBoundAxis(node, YGFlexDirectionColumn, 0); } else { // Measure the text under the current constraints. - const CSSSize measuredSize = + const YGSize measuredSize = node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); node->layout.measuredDimensions[YGDimensionWidth] = - boundAxis(node, - YGFlexDirectionRow, - (widthMeasureMode == YGMeasureModeUndefined || - widthMeasureMode == YGMeasureModeAtMost) - ? measuredSize.width + paddingAndBorderAxisRow - : availableWidth - marginAxisRow); + YGNodeBoundAxis(node, + YGFlexDirectionRow, + (widthMeasureMode == YGMeasureModeUndefined || + widthMeasureMode == YGMeasureModeAtMost) + ? measuredSize.width + paddingAndBorderAxisRow + : availableWidth - marginAxisRow); node->layout.measuredDimensions[YGDimensionHeight] = - boundAxis(node, - YGFlexDirectionColumn, - (heightMeasureMode == YGMeasureModeUndefined || - heightMeasureMode == YGMeasureModeAtMost) - ? measuredSize.height + paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, + YGFlexDirectionColumn, + (heightMeasureMode == YGMeasureModeUndefined || + heightMeasureMode == YGMeasureModeAtMost) + ? measuredSize.height + paddingAndBorderAxisColumn + : availableHeight - marginAxisColumn); } } // For nodes with no children, use the available values if they were provided, // or the minimum size as indicated by the padding and border sizes. -static void setMeasuredDimensionsForEmptyContainer(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode) { - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, YGFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); +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 float paddingAndBorderAxisColumn = + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); node->layout.measuredDimensions[YGDimensionWidth] = - boundAxis(node, - YGFlexDirectionRow, - (widthMeasureMode == YGMeasureModeUndefined || - widthMeasureMode == YGMeasureModeAtMost) - ? paddingAndBorderAxisRow - : availableWidth - marginAxisRow); + YGNodeBoundAxis(node, + YGFlexDirectionRow, + (widthMeasureMode == YGMeasureModeUndefined || + widthMeasureMode == YGMeasureModeAtMost) + ? paddingAndBorderAxisRow + : availableWidth - marginAxisRow); node->layout.measuredDimensions[YGDimensionHeight] = - boundAxis(node, - YGFlexDirectionColumn, - (heightMeasureMode == YGMeasureModeUndefined || - heightMeasureMode == YGMeasureModeAtMost) - ? paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, + YGFlexDirectionColumn, + (heightMeasureMode == YGMeasureModeUndefined || + heightMeasureMode == YGMeasureModeAtMost) + ? paddingAndBorderAxisColumn + : availableHeight - marginAxisColumn); } -static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode) { +static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode) { if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0) || (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly)) { - const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); node->layout.measuredDimensions[YGDimensionWidth] = - boundAxis(node, - YGFlexDirectionRow, - CSSValueIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) - ? 0 - : availableWidth - marginAxisRow); + YGNodeBoundAxis(node, + YGFlexDirectionRow, + YGValueIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) + ? 0 + : availableWidth - marginAxisRow); node->layout.measuredDimensions[YGDimensionHeight] = - boundAxis(node, - YGFlexDirectionColumn, - CSSValueIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) - ? 0 - : availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, + YGFlexDirectionColumn, + YGValueIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) + ? 0 + : availableHeight - marginAxisColumn); return true; } @@ -1300,7 +1327,7 @@ static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, // // This is the main routine that implements a subset of the flexbox layout // algorithm -// described in the W3C CSS documentation: https://www.w3.org/TR/css3-flexbox/. +// described in the W3C YG documentation: https://www.w3.org/TR/YG3-flexbox/. // // Limitations of this algorithm, compared to the full standard: // * Display property is always assumed to be 'flex' except for Text nodes, @@ -1399,45 +1426,44 @@ static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, // support default // minimum main sizes (see above for details). Each of our measure modes maps // to a layout mode -// from the spec (https://www.w3.org/TR/css3-sizing/#terms): +// from the spec (https://www.w3.org/TR/YG3-sizing/#terms): // - YGMeasureModeUndefined: max content // - YGMeasureModeExactly: fill available // - YGMeasureModeAtMost: fit content // -// When calling layoutNodeImpl and layoutNodeInternal, if the caller passes +// When calling YGNodelayoutImpl and YGLayoutNodeInternal, if the caller passes // an available size of // undefined then it must also pass a measure mode of YGMeasureModeUndefined // in that dimension. // -static void layoutNodeImpl(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGDirection parentDirection, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode, - const bool performLayout) { - CSS_ASSERT(CSSValueIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined - : true, - "availableWidth is indefinite so widthMeasureMode must be " - "YGMeasureModeUndefined"); - CSS_ASSERT(CSSValueIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined - : true, - "availableHeight is indefinite so heightMeasureMode must be " - "YGMeasureModeUndefined"); +static void YGNodelayoutImpl(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, + const bool performLayout) { + YG_ASSERT(YGValueIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, + "availableWidth is indefinite so widthMeasureMode must be " + "YGMeasureModeUndefined"); + YG_ASSERT(YGValueIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined + : true, + "availableHeight is indefinite so heightMeasureMode must be " + "YGMeasureModeUndefined"); // Set the resolved resolution in the node's layout. - const YGDirection direction = resolveDirection(node, parentDirection); + const YGDirection direction = YGNodeResolveDirection(node, parentDirection); node->layout.direction = direction; if (node->measure) { - setMeasuredDimensionsForNodeWithMeasureFunc( + YGNodeWithMeasureFuncSetMeasuredDimensions( node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode); return; } - const uint32_t childCount = CSSNodeListCount(node->children); + const uint32_t childCount = YGNodeListCount(node->children); if (childCount == 0) { - setMeasuredDimensionsForEmptyContainer( + YGNodeEmptyContainerSetMeasuredDimensions( node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode); return; } @@ -1445,34 +1471,35 @@ static void layoutNodeImpl(const CSSNodeRef node, // If we're not being asked to perform a full layout we can skip the algorithm if we already know // the size if (!performLayout && - setMeasuredDimensionsIfEmptyOrFixedSize( + YGNodeFixedSizeSetMeasuredDimensions( node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode)) { return; } // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM - const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const YGFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); - const bool isMainAxisRow = isRowDirection(mainAxis); + const YGFlexDirection mainAxis = YGFlexDirectionResolve(node->style.flexDirection, direction); + const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction); + const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis); const YGJustify justifyContent = node->style.justifyContent; const bool isNodeFlexWrap = node->style.flexWrap == YGWrapWrap; - CSSNodeRef firstAbsoluteChild = NULL; - CSSNodeRef currentAbsoluteChild = NULL; + YGNodeRef firstAbsoluteChild = NULL; + YGNodeRef currentAbsoluteChild = NULL; - const float leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); - const float trailingPaddingAndBorderMain = getTrailingPaddingAndBorder(node, mainAxis); - const float leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); - const float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); - const float paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis); + 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 YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, YGFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, YGFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); + const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); + const float paddingAndBorderAxisColumn = + YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; @@ -1484,18 +1511,18 @@ static void layoutNodeImpl(const CSSNodeRef node, // 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 // match the remaining space - CSSNodeRef singleFlexChild = NULL; + YGNodeRef singleFlexChild = NULL; if ((isMainAxisRow && widthMeasureMode == YGMeasureModeExactly) || (!isMainAxisRow && heightMeasureMode == YGMeasureModeExactly)) { for (uint32_t i = 0; i < childCount; i++) { - const CSSNodeRef child = CSSNodeGetChild(node, i); + const YGNodeRef child = YGNodeGetChild(node, i); if (singleFlexChild) { - if (isFlex(child)) { + if (YGNodeIsFlex(child)) { // There is already a flexible child, abort. singleFlexChild = NULL; break; } - } else if (CSSNodeStyleGetFlexGrow(child) > 0 && CSSNodeStyleGetFlexShrink(child) > 0) { + } else if (YGNodeStyleGetFlexGrow(child) > 0 && YGNodeStyleGetFlexShrink(child) > 0) { singleFlexChild = child; } } @@ -1503,12 +1530,12 @@ static void layoutNodeImpl(const CSSNodeRef node, // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM for (uint32_t i = 0; i < childCount; i++) { - const CSSNodeRef child = CSSNodeListGet(node->children, i); + const YGNodeRef child = YGNodeListGet(node->children, i); if (performLayout) { // Set the initial position (relative to the parent). - const YGDirection childDirection = resolveDirection(child, direction); - setPosition(child, childDirection); + const YGDirection childDirection = YGNodeResolveDirection(child, direction); + YGNodeSetPosition(child, childDirection); } // Absolute-positioned children don't participate in flex layout. Add them @@ -1529,13 +1556,13 @@ static void layoutNodeImpl(const CSSNodeRef node, child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; child->layout.computedFlexBasis = 0; } else { - computeChildFlexBasis(node, - child, - availableInnerWidth, - widthMeasureMode, - availableInnerHeight, - heightMeasureMode, - direction); + YGNodeComputeFlexBasisForChild(node, + child, + availableInnerWidth, + widthMeasureMode, + availableInnerHeight, + heightMeasureMode, + direction); } } } @@ -1572,17 +1599,17 @@ static void layoutNodeImpl(const CSSNodeRef node, float totalFlexShrinkScaledFactors = 0; // Maintain a linked list of the child nodes that can shrink and/or grow. - CSSNodeRef firstRelativeChild = NULL; - CSSNodeRef currentRelativeChild = NULL; + YGNodeRef firstRelativeChild = NULL; + YGNodeRef currentRelativeChild = NULL; // Add items to the current line until it's full or we run out of items. for (uint32_t i = startOfLineIndex; i < childCount; i++, endOfLineIndex++) { - const CSSNodeRef child = CSSNodeListGet(node->children, i); + const YGNodeRef child = YGNodeListGet(node->children, i); child->lineIndex = lineCount; if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = - child->layout.computedFlexBasis + getMarginAxis(child, mainAxis); + child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis); // If this is a multi-line flow and this item pushes us over the // available size, we've @@ -1596,14 +1623,14 @@ static void layoutNodeImpl(const CSSNodeRef node, sizeConsumedOnCurrentLine += outerFlexBasis; itemsOnLine++; - if (isFlex(child)) { - totalFlexGrowFactors += CSSNodeStyleGetFlexGrow(child); + if (YGNodeIsFlex(child)) { + totalFlexGrowFactors += YGNodeStyleGetFlexGrow(child); // Unlike the grow factor, the shrink factor is scaled relative to the // child // dimension. totalFlexShrinkScaledFactors += - -CSSNodeStyleGetFlexShrink(child) * child->layout.computedFlexBasis; + -YGNodeStyleGetFlexShrink(child) * child->layout.computedFlexBasis; } // Store a private linked list of children that need to be layed out. @@ -1633,7 +1660,7 @@ static void layoutNodeImpl(const CSSNodeRef 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 (!CSSValueIsUndefined(availableInnerMainDim)) { + if (!YGValueIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; } else if (sizeConsumedOnCurrentLine < 0) { // availableInnerMainDim is indefinite which means the node is being sized @@ -1670,7 +1697,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // // This two pass approach for resolving min/max constraints deviates from // the spec. The - // spec (https://www.w3.org/TR/css-flexbox-1/#resolve-flexible-lengths) + // spec (https://www.w3.org/TR/YG-flexbox-1/#resolve-flexible-lengths) // describes a process // that needs to be repeated a variable number of times. The algorithm // implemented here @@ -1686,15 +1713,14 @@ static void layoutNodeImpl(const CSSNodeRef node, childFlexBasis = currentRelativeChild->layout.computedFlexBasis; if (remainingFreeSpace < 0) { - flexShrinkScaledFactor = - -CSSNodeStyleGetFlexShrink(currentRelativeChild) * childFlexBasis; + flexShrinkScaledFactor = -YGNodeStyleGetFlexShrink(currentRelativeChild) * childFlexBasis; // Is this child able to shrink? if (flexShrinkScaledFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1707,13 +1733,13 @@ static void layoutNodeImpl(const CSSNodeRef node, } } } else if (remainingFreeSpace > 0) { - flexGrowFactor = CSSNodeStyleGetFlexGrow(currentRelativeChild); + flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); // Is this child able to grow? if (flexGrowFactor != 0) { baseMainSize = childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize); + boundMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, baseMainSize); if (baseMainSize != boundMainSize) { // By excluding this item's size and flex factor from remaining, // this item's @@ -1742,8 +1768,7 @@ static void layoutNodeImpl(const CSSNodeRef node, float updatedMainSize = childFlexBasis; if (remainingFreeSpace < 0) { - flexShrinkScaledFactor = - -CSSNodeStyleGetFlexShrink(currentRelativeChild) * childFlexBasis; + flexShrinkScaledFactor = -YGNodeStyleGetFlexShrink(currentRelativeChild) * childFlexBasis; // Is this child able to shrink? if (flexShrinkScaledFactor != 0) { float childSize; @@ -1756,18 +1781,18 @@ static void layoutNodeImpl(const CSSNodeRef node, (remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor; } - updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize); + updatedMainSize = YGNodeBoundAxis(currentRelativeChild, mainAxis, childSize); } } else if (remainingFreeSpace > 0) { - flexGrowFactor = CSSNodeStyleGetFlexGrow(currentRelativeChild); + flexGrowFactor = YGNodeStyleGetFlexGrow(currentRelativeChild); // Is this child able to grow? if (flexGrowFactor != 0) { updatedMainSize = - boundAxis(currentRelativeChild, - mainAxis, - childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor); + YGNodeBoundAxis(currentRelativeChild, + mainAxis, + childFlexBasis + + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor); } } @@ -1779,80 +1804,82 @@ static void layoutNodeImpl(const CSSNodeRef node, YGMeasureMode childHeightMeasureMode; if (isMainAxisRow) { - childWidth = updatedMainSize + getMarginAxis(currentRelativeChild, YGFlexDirectionRow); + childWidth = + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow); childWidthMeasureMode = YGMeasureModeExactly; - if (!CSSValueIsUndefined(availableInnerCrossDim) && - !isStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn) && + if (!YGValueIsUndefined(availableInnerCrossDim) && + !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn) && heightMeasureMode == YGMeasureModeExactly && - getAlignItem(node, currentRelativeChild) == YGAlignStretch) { + YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { childHeight = availableInnerCrossDim; childHeightMeasureMode = YGMeasureModeExactly; - } else if (!isStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn)) { + } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn)) { childHeight = availableInnerCrossDim; childHeightMeasureMode = - CSSValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { childHeight = currentRelativeChild->style.dimensions[YGDimensionHeight] + - getMarginAxis(currentRelativeChild, YGFlexDirectionColumn); + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn); childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + getMarginAxis(currentRelativeChild, YGFlexDirectionColumn); + updatedMainSize + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn); childHeightMeasureMode = YGMeasureModeExactly; - if (!CSSValueIsUndefined(availableInnerCrossDim) && - !isStyleDimDefined(currentRelativeChild, YGFlexDirectionRow) && + if (!YGValueIsUndefined(availableInnerCrossDim) && + !YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow) && widthMeasureMode == YGMeasureModeExactly && - getAlignItem(node, currentRelativeChild) == YGAlignStretch) { + YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) { childWidth = availableInnerCrossDim; childWidthMeasureMode = YGMeasureModeExactly; - } else if (!isStyleDimDefined(currentRelativeChild, YGFlexDirectionRow)) { + } else if (!YGNodeIsStyleDimDefined(currentRelativeChild, YGFlexDirectionRow)) { childWidth = availableInnerCrossDim; childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; + YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { childWidth = currentRelativeChild->style.dimensions[YGDimensionWidth] + - getMarginAxis(currentRelativeChild, YGFlexDirectionRow); + YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow); childWidthMeasureMode = YGMeasureModeExactly; } } - if (!CSSValueIsUndefined(currentRelativeChild->style.aspectRatio)) { + if (!YGValueIsUndefined(currentRelativeChild->style.aspectRatio)) { if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - getPaddingAndBorderAxis(currentRelativeChild, YGFlexDirectionColumn)); + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { - childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, - getPaddingAndBorderAxis(currentRelativeChild, YGFlexDirectionRow)); + childWidth = + fmaxf(childHeight * currentRelativeChild->style.aspectRatio, + YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow)); childWidthMeasureMode = YGMeasureModeExactly; } } - constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionWidth], - &childWidthMeasureMode, - &childWidth); - constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionHeight], - &childHeightMeasureMode, - &childHeight); + YGConstrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionWidth], + &childWidthMeasureMode, + &childWidth); + YGConstrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionHeight], + &childHeightMeasureMode, + &childHeight); const bool requiresStretchLayout = - !isStyleDimDefined(currentRelativeChild, crossAxis) && - getAlignItem(node, currentRelativeChild) == YGAlignStretch; + !YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis) && + YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch; // Recursively call the layout algorithm for this child with the updated // main size. - layoutNodeInternal(currentRelativeChild, - childWidth, - childHeight, - direction, - childWidthMeasureMode, - childHeightMeasureMode, - performLayout && !requiresStretchLayout, - "flex"); + YGLayoutNodeInternal(currentRelativeChild, + childWidth, + childHeight, + direction, + childWidthMeasureMode, + childHeightMeasureMode, + performLayout && !requiresStretchLayout, + "flex"); currentRelativeChild = currentRelativeChild->nextChild; } @@ -1873,7 +1900,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // constraint by the min size defined for the main axis. if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { - if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && + if (!YGValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && node->style.minDimensions[dim[mainAxis]] >= 0) { remainingFreeSpace = fmaxf(0, node->style.minDimensions[dim[mainAxis]] - @@ -1911,17 +1938,17 @@ static void layoutNodeImpl(const CSSNodeRef node, float crossDim = 0; for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { - const CSSNodeRef child = CSSNodeListGet(node->children, i); + const YGNodeRef child = YGNodeListGet(node->children, i); if (child->style.positionType == YGPositionTypeAbsolute && - isLeadingPosDefined(child, mainAxis)) { + YGNodeIsLeadingPosDefined(child, mainAxis)) { if (performLayout) { // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said // (and margin/border). - child->layout.position[pos[mainAxis]] = getLeadingPosition(child, mainAxis) + - getLeadingBorder(node, mainAxis) + - getLeadingMargin(child, mainAxis); + child->layout.position[pos[mainAxis]] = YGNodeLeadingPosition(child, mainAxis) + + YGNodeLeadingBorder(node, mainAxis) + + YGNodeLeadingMargin(child, mainAxis); } } else { // Now that we placed the element, we need to update the variables. @@ -1935,23 +1962,23 @@ static void layoutNodeImpl(const CSSNodeRef node, if (canSkipFlex) { // 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 getDimWithMargin. - mainDim += - betweenMainDim + getMarginAxis(child, mainAxis) + child->layout.computedFlexBasis; + // they weren't computed. This means we can't call YGNodeDimWithMargin. + mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis) + + child->layout.computedFlexBasis; crossDim = availableInnerCrossDim; } else { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); + mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis); // The cross dimension is the max of the elements dimension since // there // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, getDimWithMargin(child, crossAxis)); + crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis)); } } else if (performLayout) { child->layout.position[pos[mainAxis]] += - getLeadingBorder(node, mainAxis) + leadingMainDim; + YGNodeLeadingBorder(node, mainAxis) + leadingMainDim; } } } @@ -1962,7 +1989,7 @@ static void layoutNodeImpl(const CSSNodeRef node, if (measureModeCrossDim == YGMeasureModeUndefined || measureModeCrossDim == YGMeasureModeAtMost) { // Compute the cross axis from the max cross dimension of the children. - containerCrossAxis = boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - + containerCrossAxis = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - paddingAndBorderAxisCross; if (measureModeCrossDim == YGMeasureModeAtMost) { @@ -1976,27 +2003,27 @@ static void layoutNodeImpl(const CSSNodeRef node, } // Clamp to the min/max size specified on the container. - crossDim = boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - + crossDim = YGNodeBoundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - paddingAndBorderAxisCross; // STEP 7: CROSS-AXIS ALIGNMENT // We can skip child alignment if we're just measuring the container. if (performLayout) { for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { - const CSSNodeRef child = CSSNodeListGet(node->children, i); + const YGNodeRef child = YGNodeListGet(node->children, i); if (child->style.positionType == YGPositionTypeAbsolute) { // If the child is absolutely positioned and has a // top/left/bottom/right // set, override all the previously computed positions to set it // correctly. - if (isLeadingPosDefined(child, crossAxis)) { - child->layout.position[pos[crossAxis]] = getLeadingPosition(child, crossAxis) + - getLeadingBorder(node, crossAxis) + - getLeadingMargin(child, crossAxis); + if (YGNodeIsLeadingPosDefined(child, crossAxis)) { + child->layout.position[pos[crossAxis]] = YGNodeLeadingPosition(child, crossAxis) + + YGNodeLeadingBorder(node, crossAxis) + + YGNodeLeadingMargin(child, crossAxis); } else { child->layout.position[pos[crossAxis]] = - getLeadingBorder(node, crossAxis) + getLeadingMargin(child, crossAxis); + YGNodeLeadingBorder(node, crossAxis) + YGNodeLeadingMargin(child, crossAxis); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -2004,7 +2031,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // For a relative children, we're either using alignItems (parent) or // alignSelf (child) in order to determine the position in the cross // axis - const YGAlign alignItem = getAlignItem(node, child); + const YGAlign alignItem = YGNodeAlignItem(node, child); // If the child uses align stretch, we need to lay it out one more // time, this time @@ -2012,8 +2039,8 @@ static void layoutNodeImpl(const CSSNodeRef node, // current line. if (alignItem == YGAlignStretch) { const bool isCrossSizeDefinite = - (isMainAxisRow && isStyleDimDefined(child, YGFlexDirectionColumn)) || - (!isMainAxisRow && isStyleDimDefined(child, YGFlexDirectionRow)); + (isMainAxisRow && YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) || + (!isMainAxisRow && YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)); float childWidth; float childHeight; @@ -2023,39 +2050,40 @@ static void layoutNodeImpl(const CSSNodeRef node, if (isMainAxisRow) { childHeight = crossDim; childWidth = child->layout.measuredDimensions[YGDimensionWidth] + - getMarginAxis(child, YGFlexDirectionRow); + YGNodeMarginForAxis(child, YGFlexDirectionRow); } else { childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + - getMarginAxis(child, YGFlexDirectionColumn); + YGNodeMarginForAxis(child, YGFlexDirectionColumn); } - constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], - &childWidthMeasureMode, - &childWidth); - constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], - &childHeightMeasureMode, - &childHeight); + YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], + &childWidthMeasureMode, + &childWidth); + YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], + &childHeightMeasureMode, + &childHeight); // If the child defines a definite size for its cross axis, there's // no need to stretch. if (!isCrossSizeDefinite) { childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - CSSValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; + YGValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; - layoutNodeInternal(child, - childWidth, - childHeight, - direction, - childWidthMeasureMode, - childHeightMeasureMode, - true, - "stretch"); + YGLayoutNodeInternal(child, + childWidth, + childHeight, + direction, + childWidthMeasureMode, + childHeightMeasureMode, + true, + "stretch"); } } else if (alignItem != YGAlignFlexStart) { - const float remainingCrossDim = containerCrossAxis - getDimWithMargin(child, crossAxis); + const float remainingCrossDim = + containerCrossAxis - YGNodeDimWithMargin(child, crossAxis); if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; @@ -2075,7 +2103,7 @@ static void layoutNodeImpl(const CSSNodeRef node, } // STEP 8: MULTI-LINE CONTENT ALIGNMENT - if (lineCount > 1 && performLayout && !CSSValueIsUndefined(availableInnerCrossDim)) { + if (lineCount > 1 && performLayout && !YGValueIsUndefined(availableInnerCrossDim)) { const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim; float crossDimLead = 0; @@ -2107,17 +2135,17 @@ static void layoutNodeImpl(const CSSNodeRef node, // compute the line's height and find the endIndex float lineHeight = 0; for (ii = startIndex; ii < childCount; ii++) { - const CSSNodeRef child = CSSNodeListGet(node->children, ii); + const YGNodeRef child = YGNodeListGet(node->children, ii); if (child->style.positionType == YGPositionTypeRelative) { if (child->lineIndex != i) { break; } - if (isLayoutDimDefined(child, crossAxis)) { + if (YGNodeIsLayoutDimDefined(child, crossAxis)) { lineHeight = fmaxf(lineHeight, child->layout.measuredDimensions[dim[crossAxis]] + - getMarginAxis(child, crossAxis)); + YGNodeMarginForAxis(child, crossAxis)); } } } @@ -2126,18 +2154,18 @@ static void layoutNodeImpl(const CSSNodeRef node, if (performLayout) { for (ii = startIndex; ii < endIndex; ii++) { - const CSSNodeRef child = CSSNodeListGet(node->children, ii); + const YGNodeRef child = YGNodeListGet(node->children, ii); if (child->style.positionType == YGPositionTypeRelative) { - switch (getAlignItem(node, child)) { + switch (YGNodeAlignItem(node, child)) { case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = - currentLead + getLeadingMargin(child, crossAxis); + currentLead + YGNodeLeadingMargin(child, crossAxis); break; } case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = - currentLead + lineHeight - getTrailingMargin(child, crossAxis) - + currentLead + lineHeight - YGNodeTrailingMargin(child, crossAxis) - child->layout.measuredDimensions[dim[crossAxis]]; break; } @@ -2149,7 +2177,7 @@ static void layoutNodeImpl(const CSSNodeRef node, } case YGAlignStretch: { child->layout.position[pos[crossAxis]] = - currentLead + getLeadingMargin(child, crossAxis); + currentLead + YGNodeLeadingMargin(child, crossAxis); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; @@ -2168,20 +2196,21 @@ static void layoutNodeImpl(const CSSNodeRef node, // STEP 9: COMPUTING FINAL DIMENSIONS node->layout.measuredDimensions[YGDimensionWidth] = - boundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + YGNodeBoundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); node->layout.measuredDimensions[YGDimensionHeight] = - boundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); + YGNodeBoundAxis(node, YGFlexDirectionColumn, availableHeight - marginAxisColumn); // If the user didn't specify a width or height for the node, set the // dimensions based on the children. if (measureModeMainDim == YGMeasureModeUndefined) { // 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]] = boundAxis(node, mainAxis, maxLineMainDim); + node->layout.measuredDimensions[dim[mainAxis]] = + YGNodeBoundAxis(node, mainAxis, maxLineMainDim); } else if (measureModeMainDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, - boundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), + YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), paddingAndBorderAxisMain); } @@ -2189,13 +2218,13 @@ static void layoutNodeImpl(const CSSNodeRef 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]] = - boundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross); + YGNodeBoundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross); } else if (measureModeCrossDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, - boundAxisWithinMinAndMax(node, - crossAxis, - totalLineCrossDim + paddingAndBorderAxisCross)), + YGNodeBoundAxisWithinMinAndMax(node, + crossAxis, + totalLineCrossDim + paddingAndBorderAxisCross)), paddingAndBorderAxisCross); } @@ -2203,7 +2232,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN for (currentAbsoluteChild = firstAbsoluteChild; currentAbsoluteChild != NULL; currentAbsoluteChild = currentAbsoluteChild->nextChild) { - absoluteLayoutChild( + YGNodeAbsoluteLayoutChild( node, currentAbsoluteChild, availableInnerWidth, widthMeasureMode, direction); } @@ -2216,14 +2245,14 @@ static void layoutNodeImpl(const CSSNodeRef node, // Set trailing position if necessary. if (needsMainTrailingPos || needsCrossTrailingPos) { for (uint32_t i = 0; i < childCount; i++) { - const CSSNodeRef child = CSSNodeListGet(node->children, i); + const YGNodeRef child = YGNodeListGet(node->children, i); if (needsMainTrailingPos) { - setTrailingPosition(node, child, mainAxis); + YGNodeSetChildTrailingPosition(node, child, mainAxis); } if (needsCrossTrailingPos) { - setTrailingPosition(node, child, crossAxis); + YGNodeSetChildTrailingPosition(node, child, crossAxis); } } } @@ -2237,7 +2266,7 @@ bool gPrintSkips = false; static const char *spacer = " "; -static const char *getSpacer(const unsigned long level) { +static const char *YGSpacer(const unsigned long level) { const size_t spacerLen = strlen(spacer); if (level > spacerLen) { return &spacer[0]; @@ -2246,7 +2275,7 @@ static const char *getSpacer(const unsigned long level) { } } -static const char *getModeName(const YGMeasureMode mode, const bool performLayout) { +static const char *YGMeasureModeName(const YGMeasureMode mode, const bool performLayout) { const char *kMeasureModeNames[YGMeasureModeCount] = {"UNDEFINED", "EXACTLY", "AT_MOST"}; const char *kLayoutModeNames[YGMeasureModeCount] = {"LAY_UNDEFINED", "LAY_EXACTLY", @@ -2260,89 +2289,90 @@ static const char *getModeName(const YGMeasureMode mode, const bool performLayou return performLayout ? kLayoutModeNames[mode] : kMeasureModeNames[mode]; } -static inline bool newSizeIsExactAndMatchesOldMeasuredSize(YGMeasureMode sizeMode, - float size, - float lastComputedSize) { - return sizeMode == YGMeasureModeExactly && eq(size, lastComputedSize); +static inline bool YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(YGMeasureMode sizeMode, + float size, + float lastComputedSize) { + return sizeMode == YGMeasureModeExactly && YGFloatsEqual(size, lastComputedSize); } -static inline bool oldSizeIsUnspecifiedAndStillFits(YGMeasureMode sizeMode, - float size, - YGMeasureMode lastSizeMode, - float lastComputedSize) { +static inline bool YGMeasureModeOldSizeIsUnspecifiedAndStillFits(YGMeasureMode sizeMode, + float size, + YGMeasureMode lastSizeMode, + float lastComputedSize) { return sizeMode == YGMeasureModeAtMost && lastSizeMode == YGMeasureModeUndefined && size >= lastComputedSize; } -static inline bool newMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode, - float size, - YGMeasureMode lastSizeMode, - float lastSize, - float lastComputedSize) { +static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode, + float size, + YGMeasureMode lastSizeMode, + float lastSize, + float lastComputedSize) { return lastSizeMode == YGMeasureModeAtMost && sizeMode == YGMeasureModeAtMost && lastSize > size && lastComputedSize <= size; } -bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, - const float width, - const YGMeasureMode heightMode, - const float height, - const YGMeasureMode lastWidthMode, - const float lastWidth, - const YGMeasureMode lastHeightMode, - const float lastHeight, - const float lastComputedWidth, - const float lastComputedHeight, - const float marginRow, - const float marginColumn) { +bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, + const float width, + const YGMeasureMode heightMode, + const float height, + const YGMeasureMode lastWidthMode, + const float lastWidth, + const YGMeasureMode lastHeightMode, + const float lastHeight, + const float lastComputedWidth, + const float lastComputedHeight, + const float marginRow, + const float marginColumn) { if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } - const bool hasSameWidthSpec = lastWidthMode == widthMode && eq(lastWidth, width); - const bool hasSameHeightSpec = lastHeightMode == heightMode && eq(lastHeight, height); + const bool hasSameWidthSpec = lastWidthMode == widthMode && YGFloatsEqual(lastWidth, width); + const bool hasSameHeightSpec = lastHeightMode == heightMode && YGFloatsEqual(lastHeight, height); const bool widthIsCompatible = - hasSameWidthSpec || - newSizeIsExactAndMatchesOldMeasuredSize(widthMode, width - marginRow, lastComputedWidth) || - oldSizeIsUnspecifiedAndStillFits(widthMode, - width - marginRow, - lastWidthMode, - lastComputedWidth) || - newMeasureSizeIsStricterAndStillValid( + hasSameWidthSpec || YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(widthMode, + width - marginRow, + lastComputedWidth) || + YGMeasureModeOldSizeIsUnspecifiedAndStillFits(widthMode, + width - marginRow, + lastWidthMode, + lastComputedWidth) || + YGMeasureModeNewMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); const bool heightIsCompatible = - hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, - height - marginColumn, - lastComputedHeight) || - oldSizeIsUnspecifiedAndStillFits(heightMode, - height - marginColumn, - lastHeightMode, - lastComputedHeight) || - newMeasureSizeIsStricterAndStillValid( + hasSameHeightSpec || YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(heightMode, + height - marginColumn, + lastComputedHeight) || + YGMeasureModeOldSizeIsUnspecifiedAndStillFits(heightMode, + height - marginColumn, + lastHeightMode, + lastComputedHeight) || + YGMeasureModeNewMeasureSizeIsStricterAndStillValid( heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight); return widthIsCompatible && heightIsCompatible; } // -// This is a wrapper around the layoutNodeImpl function. It determines +// This is a wrapper around the YGNodelayoutImpl function. It determines // whether the layout request is redundant and can be skipped. // // Parameters: -// Input parameters are the same as layoutNodeImpl (see above) +// Input parameters are the same as YGNodelayoutImpl (see above) // Return parameter is true if layout was performed, false if skipped // -bool layoutNodeInternal(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGDirection parentDirection, - const YGMeasureMode widthMeasureMode, - const YGMeasureMode heightMeasureMode, - const bool performLayout, - const char *reason) { - CSSLayout *layout = &node->layout; +bool YGLayoutNodeInternal(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, + const bool performLayout, + const char *reason) { + YGLayout *layout = &node->layout; gDepth++; @@ -2359,7 +2389,7 @@ bool layoutNodeInternal(const CSSNodeRef node, layout->cachedLayout.computedHeight = -1; } - CSSCachedMeasurement *cachedResults = NULL; + YGCachedMeasurement *cachedResults = NULL; // Determine whether the results are already cached. We maintain a separate // cache for layouts and measurements. A layout operation modifies the @@ -2374,54 +2404,54 @@ bool layoutNodeInternal(const CSSNodeRef node, // expensive to measure, so it's worth avoiding redundant measurements if at // all possible. if (node->measure) { - const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); // First, try to use the layout cache. - if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, - availableWidth, - heightMeasureMode, - availableHeight, - layout->cachedLayout.widthMeasureMode, - layout->cachedLayout.availableWidth, - layout->cachedLayout.heightMeasureMode, - layout->cachedLayout.availableHeight, - layout->cachedLayout.computedWidth, - layout->cachedLayout.computedHeight, - marginAxisRow, - marginAxisColumn)) { + if (YGNodeCanUseCachedMeasurement(widthMeasureMode, + availableWidth, + heightMeasureMode, + availableHeight, + layout->cachedLayout.widthMeasureMode, + layout->cachedLayout.availableWidth, + layout->cachedLayout.heightMeasureMode, + layout->cachedLayout.availableHeight, + layout->cachedLayout.computedWidth, + layout->cachedLayout.computedHeight, + marginAxisRow, + marginAxisColumn)) { cachedResults = &layout->cachedLayout; } else { // Try to use the measurement cache. for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) { - if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, - availableWidth, - heightMeasureMode, - availableHeight, - layout->cachedMeasurements[i].widthMeasureMode, - layout->cachedMeasurements[i].availableWidth, - layout->cachedMeasurements[i].heightMeasureMode, - layout->cachedMeasurements[i].availableHeight, - layout->cachedMeasurements[i].computedWidth, - layout->cachedMeasurements[i].computedHeight, - marginAxisRow, - marginAxisColumn)) { + if (YGNodeCanUseCachedMeasurement(widthMeasureMode, + availableWidth, + heightMeasureMode, + availableHeight, + layout->cachedMeasurements[i].widthMeasureMode, + layout->cachedMeasurements[i].availableWidth, + layout->cachedMeasurements[i].heightMeasureMode, + layout->cachedMeasurements[i].availableHeight, + layout->cachedMeasurements[i].computedWidth, + layout->cachedMeasurements[i].computedHeight, + marginAxisRow, + marginAxisColumn)) { cachedResults = &layout->cachedMeasurements[i]; break; } } } } else if (performLayout) { - if (eq(layout->cachedLayout.availableWidth, availableWidth) && - eq(layout->cachedLayout.availableHeight, availableHeight) && + if (YGFloatsEqual(layout->cachedLayout.availableWidth, availableWidth) && + YGFloatsEqual(layout->cachedLayout.availableHeight, availableHeight) && layout->cachedLayout.widthMeasureMode == widthMeasureMode && layout->cachedLayout.heightMeasureMode == heightMeasureMode) { cachedResults = &layout->cachedLayout; } } else { for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) { - if (eq(layout->cachedMeasurements[i].availableWidth, availableWidth) && - eq(layout->cachedMeasurements[i].availableHeight, availableHeight) && + if (YGFloatsEqual(layout->cachedMeasurements[i].availableWidth, availableWidth) && + YGFloatsEqual(layout->cachedMeasurements[i].availableHeight, availableHeight) && layout->cachedMeasurements[i].widthMeasureMode == widthMeasureMode && layout->cachedMeasurements[i].heightMeasureMode == heightMeasureMode) { cachedResults = &layout->cachedMeasurements[i]; @@ -2435,13 +2465,13 @@ bool layoutNodeInternal(const CSSNodeRef node, layout->measuredDimensions[YGDimensionHeight] = cachedResults->computedHeight; if (gPrintChanges && gPrintSkips) { - printf("%s%d.{[skipped] ", getSpacer(gDepth), gDepth); + printf("%s%d.{[skipped] ", YGSpacer(gDepth), gDepth); if (node->print) { node->print(node); } printf("wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n", - getModeName(widthMeasureMode, performLayout), - getModeName(heightMeasureMode, performLayout), + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), availableWidth, availableHeight, cachedResults->computedWidth, @@ -2450,34 +2480,34 @@ bool layoutNodeInternal(const CSSNodeRef node, } } else { if (gPrintChanges) { - printf("%s%d.{%s", getSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); + printf("%s%d.{%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); if (node->print) { node->print(node); } printf("wm: %s, hm: %s, aw: %f ah: %f %s\n", - getModeName(widthMeasureMode, performLayout), - getModeName(heightMeasureMode, performLayout), + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), availableWidth, availableHeight, reason); } - layoutNodeImpl(node, - availableWidth, - availableHeight, - parentDirection, - widthMeasureMode, - heightMeasureMode, - performLayout); + YGNodelayoutImpl(node, + availableWidth, + availableHeight, + parentDirection, + widthMeasureMode, + heightMeasureMode, + performLayout); if (gPrintChanges) { - printf("%s%d.}%s", getSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); + printf("%s%d.}%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); if (node->print) { node->print(node); } printf("wm: %s, hm: %s, d: (%f, %f) %s\n", - getModeName(widthMeasureMode, performLayout), - getModeName(heightMeasureMode, performLayout), + YGMeasureModeName(widthMeasureMode, performLayout), + YGMeasureModeName(heightMeasureMode, performLayout), layout->measuredDimensions[YGDimensionWidth], layout->measuredDimensions[YGDimensionHeight], reason); @@ -2486,14 +2516,14 @@ bool layoutNodeInternal(const CSSNodeRef node, layout->lastParentDirection = parentDirection; if (cachedResults == NULL) { - if (layout->nextCachedMeasurementsIndex == CSS_MAX_CACHED_RESULT_COUNT) { + if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) { if (gPrintChanges) { printf("Out of cache entries!\n"); } layout->nextCachedMeasurementsIndex = 0; } - CSSCachedMeasurement *newCacheEntry; + YGCachedMeasurement *newCacheEntry; if (performLayout) { // Use the single layout cache entry. newCacheEntry = &layout->cachedLayout; @@ -2524,7 +2554,7 @@ bool layoutNodeInternal(const CSSNodeRef node, return (needToVisitNode || cachedResults == NULL); } -static void roundToPixelGrid(const CSSNodeRef node) { +static void roundToPixelGrid(const YGNodeRef node) { const float fractialLeft = node->layout.position[YGEdgeLeft] - floorf(node->layout.position[YGEdgeLeft]); const float fractialTop = @@ -2537,16 +2567,16 @@ static void roundToPixelGrid(const CSSNodeRef node) { node->layout.position[YGEdgeLeft] = roundf(node->layout.position[YGEdgeLeft]); node->layout.position[YGEdgeTop] = roundf(node->layout.position[YGEdgeTop]); - const uint32_t childCount = CSSNodeListCount(node->children); + const uint32_t childCount = YGNodeListCount(node->children); for (uint32_t i = 0; i < childCount; i++) { - roundToPixelGrid(CSSNodeGetChild(node, i)); + roundToPixelGrid(YGNodeGetChild(node, i)); } } -void CSSNodeCalculateLayout(const CSSNodeRef node, - const float availableWidth, - const float availableHeight, - const YGDirection parentDirection) { +void YGNodeCalculateLayout(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGDirection parentDirection) { // Increment the generation count. This will force the recursive routine to // visit // all dirty nodes at least once. Subsequent visits will be skipped if the @@ -2559,54 +2589,54 @@ void CSSNodeCalculateLayout(const CSSNodeRef node, YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; YGMeasureMode heightMeasureMode = YGMeasureModeUndefined; - if (!CSSValueIsUndefined(width)) { + if (!YGValueIsUndefined(width)) { widthMeasureMode = YGMeasureModeExactly; - } else if (isStyleDimDefined(node, YGFlexDirectionRow)) { - width = - node->style.dimensions[dim[YGFlexDirectionRow]] + getMarginAxis(node, YGFlexDirectionRow); + } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow)) { + width = node->style.dimensions[dim[YGFlexDirectionRow]] + + YGNodeMarginForAxis(node, YGFlexDirectionRow); widthMeasureMode = YGMeasureModeExactly; } else if (node->style.maxDimensions[YGDimensionWidth] >= 0.0) { width = node->style.maxDimensions[YGDimensionWidth]; widthMeasureMode = YGMeasureModeAtMost; } - if (!CSSValueIsUndefined(height)) { + if (!YGValueIsUndefined(height)) { heightMeasureMode = YGMeasureModeExactly; - } else if (isStyleDimDefined(node, YGFlexDirectionColumn)) { + } else if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn)) { height = node->style.dimensions[dim[YGFlexDirectionColumn]] + - getMarginAxis(node, YGFlexDirectionColumn); + YGNodeMarginForAxis(node, YGFlexDirectionColumn); heightMeasureMode = YGMeasureModeExactly; } else if (node->style.maxDimensions[YGDimensionHeight] >= 0.0) { height = node->style.maxDimensions[YGDimensionHeight]; heightMeasureMode = YGMeasureModeAtMost; } - if (layoutNodeInternal(node, - width, - height, - parentDirection, - widthMeasureMode, - heightMeasureMode, - true, - "initia" - "l")) { - setPosition(node, node->layout.direction); + if (YGLayoutNodeInternal(node, + width, + height, + parentDirection, + widthMeasureMode, + heightMeasureMode, + true, + "initia" + "l")) { + YGNodeSetPosition(node, node->layout.direction); - if (CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { + if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { roundToPixelGrid(node); } if (gPrintTree) { - CSSNodePrint(node, YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle); + YGNodePrint(node, YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle); } } } -void CSSLayoutSetLogger(CSSLogger logger) { +void YGSetLogger(YGLogger logger) { gLogger = logger; } -void CSSLog(YGLogLevel level, const char *format, ...) { +void YGLog(YGLogLevel level, const char *format, ...) { va_list args; va_start(args, format); gLogger(level, format, args); @@ -2615,32 +2645,29 @@ void CSSLog(YGLogLevel level, const char *format, ...) { static bool experimentalFeatures[YGExperimentalFeatureCount + 1]; -void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled) { +void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled) { experimentalFeatures[feature] = enabled; } -inline bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature) { +inline bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature) { return experimentalFeatures[feature]; } -void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc, - CSSCalloc cssCalloc, - CSSRealloc cssRealloc, - CSSFree cssFree) { - CSS_ASSERT(gNodeInstanceCount == 0, "Cannot set memory functions: all node must be freed first"); - CSS_ASSERT((cssMalloc == NULL && cssCalloc == NULL && cssRealloc == NULL && cssFree == NULL) || - (cssMalloc != NULL && cssCalloc != NULL && cssRealloc != NULL && cssFree != NULL), - "Cannot set memory functions: functions must be all NULL or Non-NULL"); +void YGSetMemoryFuncs(YGMalloc YGMalloc, YGCalloc YGCalloc, YGRealloc YGRealloc, YGFree YGFree) { + YG_ASSERT(gNodeInstanceCount == 0, "Cannot set memory functions: all node must be freed first"); + YG_ASSERT((YGMalloc == NULL && YGCalloc == NULL && YGRealloc == NULL && YGFree == NULL) || + (YGMalloc != NULL && YGCalloc != NULL && YGRealloc != NULL && YGFree != NULL), + "Cannot set memory functions: functions must be all NULL or Non-NULL"); - if (cssMalloc == NULL || cssCalloc == NULL || cssRealloc == NULL || cssFree == NULL) { - gCSSMalloc = &malloc; - gCSSCalloc = &calloc; - gCSSRealloc = &realloc; - gCSSFree = &free; + if (YGMalloc == NULL || YGCalloc == NULL || YGRealloc == NULL || YGFree == NULL) { + gYGMalloc = &malloc; + gYGCalloc = &calloc; + gYGRealloc = &realloc; + gYGFree = &free; } else { - gCSSMalloc = cssMalloc; - gCSSCalloc = cssCalloc; - gCSSRealloc = cssRealloc; - gCSSFree = cssFree; + gYGMalloc = YGMalloc; + gYGCalloc = YGCalloc; + gYGRealloc = YGRealloc; + gYGFree = YGFree; } } diff --git a/CSSLayout/Yoga.h b/CSSLayout/Yoga.h new file mode 100644 index 00000000..926a3b94 --- /dev/null +++ b/CSSLayout/Yoga.h @@ -0,0 +1,181 @@ +/** + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#ifndef __cplusplus +#include +#endif + +// Not defined in MSVC++ +#ifndef NAN +static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; +#define NAN (*(const float *) __nan) +#endif + +#define YGUndefined NAN + +#include "YGEnums.h" +#include "YGMacros.h" + +YG_EXTERN_C_BEGIN + +typedef struct YGSize { + float width; + float height; +} YGSize; + +typedef struct YGNode *YGNodeRef; +typedef YGSize (*YGMeasureFunc)(YGNodeRef node, + float width, + YGMeasureMode widthMode, + float height, + YGMeasureMode heightMode); +typedef void (*YGPrintFunc)(YGNodeRef node); +typedef int (*YGLogger)(YGLogLevel level, const char *format, va_list args); + +typedef void *(*YGMalloc)(size_t size); +typedef void *(*YGCalloc)(size_t count, size_t size); +typedef void *(*YGRealloc)(void *ptr, size_t size); +typedef void (*YGFree)(void *ptr); + +// YGNode +WIN_EXPORT YGNodeRef YGNodeNew(void); +WIN_EXPORT void YGNodeInit(const YGNodeRef node); +WIN_EXPORT void YGNodeFree(const YGNodeRef node); +WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node); +WIN_EXPORT void YGNodeReset(const YGNodeRef node); +WIN_EXPORT int32_t YGNodeGetInstanceCount(void); + +WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node, + const YGNodeRef child, + const uint32_t index); +WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child); +WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index); +WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node); + +WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, + const float availableWidth, + const float availableHeight, + const YGDirection parentDirection); + +// Mark a node as dirty. Only valid for nodes with a custom measure function +// set. +// YG knows when to mark all other nodes as dirty but because nodes with +// measure functions +// depends on information not known to YG they must perform this dirty +// marking manually. +WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node); +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 YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, + const float width, + const YGMeasureMode heightMode, + const float height, + const YGMeasureMode lastWidthMode, + const float lastWidth, + const YGMeasureMode lastHeightMode, + const float lastHeight, + const float lastComputedWidth, + const float lastComputedHeight, + const float marginRow, + const float marginColumn); + +WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode); + +#define YG_NODE_PROPERTY(type, name, paramName) \ + WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \ + WIN_EXPORT type YGNodeGet##name(const YGNodeRef node); + +#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \ + 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, \ + const YGEdge edge, \ + const type paramName); \ + 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); + +YG_NODE_PROPERTY(void *, Context, context); +YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc); +YG_NODE_PROPERTY(YGPrintFunc, PrintFunc, printFunc); +YG_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout); + +YG_NODE_STYLE_PROPERTY(YGDirection, Direction, direction); +YG_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection); +YG_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent); +YG_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent); +YG_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems); +YG_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf); +YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType); +YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap); +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_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_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); + +// Yoga specific properties, not compatible with flexbox specification +// Aspect ratio control the size of the undefined dimension of a node. +// - On a node with a set width/height aspect ratio control the size of the unset dimension +// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if +// unset +// - On a node with a measure function aspect ratio works as though the measure function measures +// the flex basis +// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if +// unset +// - Aspect ratio takes min/max dimensions into account +YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio); + +YG_NODE_LAYOUT_PROPERTY(float, Left); +YG_NODE_LAYOUT_PROPERTY(float, Top); +YG_NODE_LAYOUT_PROPERTY(float, Right); +YG_NODE_LAYOUT_PROPERTY(float, Bottom); +YG_NODE_LAYOUT_PROPERTY(float, Width); +YG_NODE_LAYOUT_PROPERTY(float, Height); +YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction); + +WIN_EXPORT void YGSetLogger(YGLogger logger); +WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...); + +WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled); +WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature); + +WIN_EXPORT void +YGSetMemoryFuncs(YGMalloc cssMalloc, YGCalloc cssCalloc, YGRealloc cssRealloc, YGFree cssFree); + +YG_EXTERN_C_END diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 2b31d9ce..21b7f4ba 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -20,19 +20,19 @@ - (void)testNodesAreDeallocedWithSingleView { - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + XCTAssertEqual(0, YGNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; [view yg_setFlexBasis:1]; - XCTAssertEqual(1, CSSNodeGetInstanceCount()); + XCTAssertEqual(1, YGNodeGetInstanceCount()); view = nil; - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + XCTAssertEqual(0, YGNodeGetInstanceCount()); } - (void)testNodesAreDeallocedCascade { - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + XCTAssertEqual(0, YGNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; [view yg_setFlexBasis:1]; @@ -42,10 +42,10 @@ [subview yg_setFlexBasis:1]; [view addSubview:subview]; } - XCTAssertEqual(11, CSSNodeGetInstanceCount()); + XCTAssertEqual(11, YGNodeGetInstanceCount()); view = nil; - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + XCTAssertEqual(0, YGNodeGetInstanceCount()); } #endif diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h index b23b2027..94480da6 100644 --- a/YogaKit/UIView+Yoga.h +++ b/YogaKit/UIView+Yoga.h @@ -8,9 +8,9 @@ */ #import -#import +#import -@interface UIView (CSSLayout) +@interface UIView (Yoga) /** The property that decides if we should include this view when calculating layout. Defaults to YES. diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index 32299d9e..da22e1b8 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -11,21 +11,21 @@ #import -@interface CSSNodeBridge : NSObject -@property (nonatomic, assign, readonly) CSSNodeRef cnode; +@interface YGNodeBridge : NSObject +@property (nonatomic, assign, readonly) YGNodeRef cnode; @end -@implementation CSSNodeBridge +@implementation YGNodeBridge + (void)initialize { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); + YogaSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); } - (instancetype)init { if ([super init]) { - _cnode = CSSNodeNew(); + _cnode = YGNodeNew(); } return self; @@ -33,11 +33,11 @@ - (void)dealloc { - CSSNodeFree(_cnode); + YGNodeFree(_cnode); } @end -@implementation UIView (CSSLayout) +@implementation UIView (Yoga) - (BOOL)yg_usesYoga { @@ -53,7 +53,7 @@ - (NSUInteger)yg_numberOfChildren { - return CSSNodeChildCount([self cssNode]); + return YGNodeChildCount([self ygNode]); } #pragma mark - Setters @@ -78,120 +78,120 @@ - (void)yg_setDirection:(YGDirection)direction { - CSSNodeStyleSetDirection([self cssNode], direction); + YGNodeStyleSetDirection([self ygNode], direction); } - (void)yg_setFlexDirection:(YGFlexDirection)flexDirection { - CSSNodeStyleSetFlexDirection([self cssNode], flexDirection); + YGNodeStyleSetFlexDirection([self ygNode], flexDirection); } - (void)yg_setJustifyContent:(YGJustify)justifyContent { - CSSNodeStyleSetJustifyContent([self cssNode], justifyContent); + YGNodeStyleSetJustifyContent([self ygNode], justifyContent); } - (void)yg_setAlignContent:(YGAlign)alignContent { - CSSNodeStyleSetAlignContent([self cssNode], alignContent); + YGNodeStyleSetAlignContent([self ygNode], alignContent); } - (void)yg_setAlignItems:(YGAlign)alignItems { - CSSNodeStyleSetAlignItems([self cssNode], alignItems); + YGNodeStyleSetAlignItems([self ygNode], alignItems); } - (void)yg_setAlignSelf:(YGAlign)alignSelf { - CSSNodeStyleSetAlignSelf([self cssNode], alignSelf); + YGNodeStyleSetAlignSelf([self ygNode], alignSelf); } - (void)yg_setPositionType:(YGPositionType)positionType { - CSSNodeStyleSetPositionType([self cssNode], positionType); + YGNodeStyleSetPositionType([self ygNode], positionType); } - (void)yg_setFlexWrap:(YGWrap)flexWrap { - CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); + YGNodeStyleSetFlexWrap([self ygNode], flexWrap); } - (void)yg_setFlexGrow:(CGFloat)flexGrow { - CSSNodeStyleSetFlexGrow([self cssNode], flexGrow); + YGNodeStyleSetFlexGrow([self ygNode], flexGrow); } - (void)yg_setFlexShrink:(CGFloat)flexShrink { - CSSNodeStyleSetFlexShrink([self cssNode], flexShrink); + YGNodeStyleSetFlexShrink([self ygNode], flexShrink); } - (void)yg_setFlexBasis:(CGFloat)flexBasis { - CSSNodeStyleSetFlexBasis([self cssNode], flexBasis); + YGNodeStyleSetFlexBasis([self ygNode], flexBasis); } - (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge { - CSSNodeStyleSetPosition([self cssNode], edge, position); + YGNodeStyleSetPosition([self ygNode], edge, position); } - (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge { - CSSNodeStyleSetMargin([self cssNode], edge, margin); + YGNodeStyleSetMargin([self ygNode], edge, margin); } - (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge { - CSSNodeStyleSetPadding([self cssNode], edge, padding); + YGNodeStyleSetPadding([self ygNode], edge, padding); } - (void)yg_setWidth:(CGFloat)width { - CSSNodeStyleSetWidth([self cssNode], width); + YGNodeStyleSetWidth([self ygNode], width); } - (void)yg_setHeight:(CGFloat)height { - CSSNodeStyleSetHeight([self cssNode], height); + YGNodeStyleSetHeight([self ygNode], height); } - (void)yg_setMinWidth:(CGFloat)minWidth { - CSSNodeStyleSetMinWidth([self cssNode], minWidth); + YGNodeStyleSetMinWidth([self ygNode], minWidth); } - (void)yg_setMinHeight:(CGFloat)minHeight { - CSSNodeStyleSetMinHeight([self cssNode], minHeight); + YGNodeStyleSetMinHeight([self ygNode], minHeight); } - (void)yg_setMaxWidth:(CGFloat)maxWidth { - CSSNodeStyleSetMaxWidth([self cssNode], maxWidth); + YGNodeStyleSetMaxWidth([self ygNode], maxWidth); } - (void)yg_setMaxHeight:(CGFloat)maxHeight { - CSSNodeStyleSetMaxHeight([self cssNode], maxHeight); + YGNodeStyleSetMaxHeight([self ygNode], maxHeight); } - (void)yg_setAspectRatio:(CGFloat)aspectRatio { - CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio); + YGNodeStyleSetAspectRatio([self ygNode], aspectRatio); } #pragma mark - Layout and Sizing - (YGDirection)yg_resolvedDirection { - return CSSNodeLayoutGetDirection([self cssNode]); + return YGNodeLayoutGetDirection([self ygNode]); } - (void)yg_applyLayout { [self calculateLayoutWithSize:self.bounds.size]; - CSSApplyLayoutToViewHierarchy(self); + YGApplyLayoutToViewHierarchy(self); } - (CGSize)yg_intrinsicSize @@ -205,13 +205,13 @@ #pragma mark - Private -- (CSSNodeRef)cssNode +- (YGNodeRef)ygNode { - CSSNodeBridge *node = objc_getAssociatedObject(self, @selector(cssNode)); + YGNodeBridge *node = objc_getAssociatedObject(self, @selector(ygNode)); if (!node) { - node = [CSSNodeBridge new]; - CSSNodeSetContext(node.cnode, (__bridge void *) self); - objc_setAssociatedObject(self, @selector(cssNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + node = [YGNodeBridge new]; + YGNodeSetContext(node.cnode, (__bridge void *) self); + objc_setAssociatedObject(self, @selector(ygNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } return node.cnode; @@ -219,26 +219,26 @@ - (CGSize)calculateLayoutWithSize:(CGSize)size { - NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); - NSAssert([self yg_usesYoga], @"CSS Layout is not enabled for this view."); + NSAssert([NSThread isMainThread], @"YG Layout calculation must be done on main."); + NSAssert([self yg_usesYoga], @"YG Layout is not enabled for this view."); - CSSAttachNodesFromViewHierachy(self); + YGAttachNodesFromViewHierachy(self); - const CSSNodeRef node = [self cssNode]; - CSSNodeCalculateLayout( + const YGNodeRef node = [self ygNode]; + YGNodeCalculateLayout( node, size.width, size.height, - CSSNodeStyleGetDirection(node)); + YGNodeStyleGetDirection(node)); return (CGSize) { - .width = CSSNodeLayoutGetWidth(node), - .height = CSSNodeLayoutGetHeight(node), + .width = YGNodeLayoutGetWidth(node), + .height = YGNodeLayoutGetHeight(node), }; } -static CSSSize CSSMeasureView( - CSSNodeRef node, +static YGSize YGMeasureView( + YGNodeRef node, float width, YGMeasureMode widthMode, float height, @@ -247,19 +247,19 @@ static CSSSize CSSMeasureView( const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width; const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height; - UIView *view = (__bridge UIView*) CSSNodeGetContext(node); + UIView *view = (__bridge UIView*) YGNodeGetContext(node); const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { .width = constrainedWidth, .height = constrainedHeight, }]; - return (CSSSize) { - .width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), - .height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), + return (YGSize) { + .width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), + .height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), }; } -static CGFloat CSSSanitizeMeasurement( +static CGFloat YGSanitizeMeasurement( CGFloat constrainedSize, CGFloat measuredSize, YGMeasureMode measureMode) @@ -276,15 +276,15 @@ static CGFloat CSSSanitizeMeasurement( return result; } -static void CSSAttachNodesFromViewHierachy(UIView *view) { - CSSNodeRef node = [view cssNode]; +static void YGAttachNodesFromViewHierachy(UIView *view) { + YGNodeRef node = [view ygNode]; // Only leaf nodes should have a measure function if (![view yg_usesYoga] || view.subviews.count == 0) { - CSSNodeSetMeasureFunc(node, CSSMeasureView); - CSSRemoveAllChildren(node); + YGNodeSetMeasureFunc(node, YGMeasureView); + YGRemoveAllChildren(node); } else { - CSSNodeSetMeasureFunc(node, NULL); + YGNodeSetMeasureFunc(node, NULL); // Create a list of all the subviews that we are going to use for layout. NSMutableArray *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count]; @@ -295,11 +295,11 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { } BOOL shouldReconstructChildList = NO; - if (CSSNodeChildCount(node) != subviewsToInclude.count) { + if (YGNodeChildCount(node) != subviewsToInclude.count) { shouldReconstructChildList = YES; } else { for (int i = 0; i < subviewsToInclude.count; i++) { - if (CSSNodeGetChild(node, i) != [subviewsToInclude[i] cssNode]) { + if (YGNodeGetChild(node, i) != [subviewsToInclude[i] ygNode]) { shouldReconstructChildList = YES; break; } @@ -307,29 +307,29 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { } if (shouldReconstructChildList) { - CSSRemoveAllChildren(node); + YGRemoveAllChildren(node); for (int i = 0 ; i < subviewsToInclude.count; i++) { UIView *const subview = subviewsToInclude[i]; - CSSNodeInsertChild(node, [subview cssNode], i); - CSSAttachNodesFromViewHierachy(subview); + YGNodeInsertChild(node, [subview ygNode], i); + YGAttachNodesFromViewHierachy(subview); } } } } -static void CSSRemoveAllChildren(const CSSNodeRef node) +static void YGRemoveAllChildren(const YGNodeRef node) { if (node == NULL) { return; } - while (CSSNodeChildCount(node) > 0) { - CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); + while (YGNodeChildCount(node) > 0) { + YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeChildCount(node) - 1)); } } -static CGFloat CSSRoundPixelValue(CGFloat value) +static CGFloat YGRoundPixelValue(CGFloat value) { static CGFloat scale; static dispatch_once_t onceToken; @@ -340,38 +340,38 @@ static CGFloat CSSRoundPixelValue(CGFloat value) return round(value * scale) / scale; } -static void CSSApplyLayoutToViewHierarchy(UIView *view) { +static void YGApplyLayoutToViewHierarchy(UIView *view) { NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); if (![view yg_includeInLayout]) { return; } - CSSNodeRef node = [view cssNode]; + YGNodeRef node = [view ygNode]; const CGPoint topLeft = { - CSSNodeLayoutGetLeft(node), - CSSNodeLayoutGetTop(node), + YGNodeLayoutGetLeft(node), + YGNodeLayoutGetTop(node), }; const CGPoint bottomRight = { - topLeft.x + CSSNodeLayoutGetWidth(node), - topLeft.y + CSSNodeLayoutGetHeight(node), + topLeft.x + YGNodeLayoutGetWidth(node), + topLeft.y + YGNodeLayoutGetHeight(node), }; view.frame = (CGRect) { .origin = { - .x = CSSRoundPixelValue(topLeft.x), - .y = CSSRoundPixelValue(topLeft.y), + .x = YGRoundPixelValue(topLeft.x), + .y = YGRoundPixelValue(topLeft.y), }, .size = { - .width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x), - .height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y), + .width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x), + .height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y), }, }; const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0; if (!isLeaf) { for (NSUInteger i = 0; i < view.subviews.count; i++) { - CSSApplyLayoutToViewHierarchy(view.subviews[i]); + YGApplyLayoutToViewHierarchy(view.subviews[i]); } } } diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index 22d639d8..c326616f 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -9,14 +9,14 @@ #include "YGBenchmark.h" -#include +#include -static CSSSize _measure(CSSNodeRef node, +static YGSize _measure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - return (CSSSize){ + return (YGSize){ .width = widthMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : width, }; @@ -25,94 +25,94 @@ static CSSSize _measure(CSSNodeRef node, YGBENCHMARKS({ YGBENCHMARK("Stack with flex", { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); for (uint32_t i = 0; i < 10; i++) { - const CSSNodeRef child = CSSNodeNew(); - CSSNodeSetMeasureFunc(child, _measure); - CSSNodeStyleSetFlex(child, 1); - CSSNodeInsertChild(root, child, 0); + const YGNodeRef child = YGNodeNew(); + YGNodeSetMeasureFunc(child, _measure); + YGNodeStyleSetFlex(child, 1); + YGNodeInsertChild(root, child, 0); } - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeFreeRecursive(root); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); }); YGBENCHMARK("Align stretch in undefined axis", { - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); for (uint32_t i = 0; i < 10; i++) { - const CSSNodeRef child = CSSNodeNew(); - CSSNodeStyleSetHeight(child, 20); - CSSNodeSetMeasureFunc(child, _measure); - CSSNodeInsertChild(root, child, 0); + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetHeight(child, 20); + YGNodeSetMeasureFunc(child, _measure); + YGNodeInsertChild(root, child, 0); } - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeFreeRecursive(root); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); }); YGBENCHMARK("Nested flex", { - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); for (uint32_t i = 0; i < 10; i++) { - const CSSNodeRef child = CSSNodeNew(); - CSSNodeStyleSetFlex(child, 1); - CSSNodeInsertChild(root, child, 0); + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetFlex(child, 1); + YGNodeInsertChild(root, child, 0); for (uint32_t ii = 0; ii < 10; ii++) { - const CSSNodeRef grandChild = CSSNodeNew(); - CSSNodeSetMeasureFunc(grandChild, _measure); - CSSNodeStyleSetFlex(grandChild, 1); - CSSNodeInsertChild(child, grandChild, 0); + const YGNodeRef grandChild = YGNodeNew(); + YGNodeSetMeasureFunc(grandChild, _measure); + YGNodeStyleSetFlex(grandChild, 1); + YGNodeInsertChild(child, grandChild, 0); } } - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeFreeRecursive(root); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); }); YGBENCHMARK("Huge nested layout", { - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); for (uint32_t i = 0; i < 10; i++) { - const CSSNodeRef child = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(child, 1); - CSSNodeStyleSetWidth(child, 10); - CSSNodeStyleSetHeight(child, 10); - CSSNodeInsertChild(root, child, 0); + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetFlexGrow(child, 1); + YGNodeStyleSetWidth(child, 10); + YGNodeStyleSetHeight(child, 10); + YGNodeInsertChild(root, child, 0); for (uint32_t ii = 0; ii < 10; ii++) { - const CSSNodeRef grandChild = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); - CSSNodeStyleSetFlexGrow(grandChild, 1); - CSSNodeStyleSetWidth(grandChild, 10); - CSSNodeStyleSetHeight(grandChild, 10); - CSSNodeInsertChild(child, grandChild, 0); + const YGNodeRef grandChild = YGNodeNew(); + YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); + YGNodeStyleSetFlexGrow(grandChild, 1); + YGNodeStyleSetWidth(grandChild, 10); + YGNodeStyleSetHeight(grandChild, 10); + YGNodeInsertChild(child, grandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { - const CSSNodeRef grandGrandChild = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(grandGrandChild, 1); - CSSNodeStyleSetWidth(grandGrandChild, 10); - CSSNodeStyleSetHeight(grandGrandChild, 10); - CSSNodeInsertChild(grandChild, grandGrandChild, 0); + const YGNodeRef grandGrandChild = YGNodeNew(); + YGNodeStyleSetFlexGrow(grandGrandChild, 1); + YGNodeStyleSetWidth(grandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandChild, 10); + YGNodeInsertChild(grandChild, grandGrandChild, 0); for (uint32_t iii = 0; iii < 10; iii++) { - const CSSNodeRef grandGrandGrandChild = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); - CSSNodeStyleSetFlexGrow(grandGrandGrandChild, 1); - CSSNodeStyleSetWidth(grandGrandGrandChild, 10); - CSSNodeStyleSetHeight(grandGrandGrandChild, 10); - CSSNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0); + const YGNodeRef grandGrandGrandChild = YGNodeNew(); + YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); + YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); + YGNodeStyleSetWidth(grandGrandGrandChild, 10); + YGNodeStyleSetHeight(grandGrandGrandChild, 10); + YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0); } } } } - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeFreeRecursive(root); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); }); }); diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index b5120822..587c0314 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -25,261 +25,261 @@ namespace Facebook.Yoga [MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func); [DllImport(DllName)] - public static extern IntPtr CSSNodeNew(); + public static extern IntPtr YGNodeNew(); [DllImport(DllName)] - public static extern void CSSNodeInit(IntPtr cssNode); + public static extern void YGNodeInit(IntPtr cssNode); [DllImport(DllName)] - public static extern void CSSNodeFree(IntPtr cssNode); + public static extern void YGNodeFree(IntPtr cssNode); [DllImport(DllName)] - public static extern void CSSNodeReset(IntPtr cssNode); + public static extern void YGNodeReset(IntPtr cssNode); [DllImport(DllName)] - public static extern int CSSNodeGetInstanceCount(); + public static extern int YGNodeGetInstanceCount(); [DllImport(DllName)] - public static extern void CSSLayoutSetExperimentalFeatureEnabled( + public static extern void YGSetExperimentalFeatureEnabled( YogaExperimentalFeature feature, bool enabled); [DllImport(DllName)] - public static extern bool CSSLayoutIsExperimentalFeatureEnabled( + public static extern bool YGIsExperimentalFeatureEnabled( YogaExperimentalFeature feature); [DllImport(DllName)] - public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index); + public static extern void YGNodeInsertChild(IntPtr node, IntPtr child, uint index); [DllImport(DllName)] - public static extern void CSSNodeRemoveChild(IntPtr node, IntPtr child); + public static extern void YGNodeRemoveChild(IntPtr node, IntPtr child); [DllImport(DllName)] - public static extern IntPtr CSSNodeGetChild(IntPtr node, uint index); + public static extern IntPtr YGNodeGetChild(IntPtr node, uint index); [DllImport(DllName)] - public static extern uint CSSNodeChildCount(IntPtr node); + public static extern uint YGNodeChildCount(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeCalculateLayout(IntPtr node, + public static extern void YGNodeCalculateLayout(IntPtr node, float availableWidth, float availableHeight, YogaDirection parentDirection); [DllImport(DllName)] - public static extern void CSSNodeMarkDirty(IntPtr node); + public static extern void YGNodeMarkDirty(IntPtr node); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool CSSNodeIsDirty(IntPtr node); + public static extern bool YGNodeIsDirty(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodePrint(IntPtr node, YogaPrintOptions options); + public static extern void YGNodePrint(IntPtr node, YogaPrintOptions options); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool CSSValueIsUndefined(float value); + public static extern bool YGValueIsUndefined(float value); [DllImport(DllName)] - public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode); + public static extern void YGNodeCopyStyle(IntPtr dstNode, IntPtr srcNode); - #region CSS_NODE_PROPERTY + #region YG_NODE_PROPERTY [DllImport(DllName)] - public static extern void CSSNodeSetContext(IntPtr node, IntPtr context); + public static extern void YGNodeSetContext(IntPtr node, IntPtr context); [DllImport(DllName)] - public static extern IntPtr CSSNodeGetContext(IntPtr node); + public static extern IntPtr YGNodeGetContext(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeSetMeasureFunc( + public static extern void YGNodeSetMeasureFunc( IntPtr node, [MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.FunctionPtr)] - public static extern YogaMeasureFunc CSSNodeGetMeasureFunc(IntPtr node); + public static extern YogaMeasureFunc YGNodeGetMeasureFunc(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); + public static extern void YGNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool CSSNodeGetHasNewLayout(IntPtr node); + public static extern bool YGNodeGetHasNewLayout(IntPtr node); #endregion - #region CSS_NODE_STYLE_PROPERTY + #region YG_NODE_STYLE_PROPERTY [DllImport(DllName)] - public static extern void CSSNodeStyleSetDirection(IntPtr node, YogaDirection direction); + public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction); [DllImport(DllName)] - public static extern YogaDirection CSSNodeStyleGetDirection(IntPtr node); + public static extern YogaDirection YGNodeStyleGetDirection(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection); + public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection); [DllImport(DllName)] - public static extern YogaFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node); + public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent); + public static extern void YGNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent); [DllImport(DllName)] - public static extern YogaJustify CSSNodeStyleGetJustifyContent(IntPtr node); + public static extern YogaJustify YGNodeStyleGetJustifyContent(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent); + public static extern void YGNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent); [DllImport(DllName)] - public static extern YogaAlign CSSNodeStyleGetAlignContent(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignContent(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems); + public static extern void YGNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems); [DllImport(DllName)] - public static extern YogaAlign CSSNodeStyleGetAlignItems(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignItems(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf); + public static extern void YGNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf); [DllImport(DllName)] - public static extern YogaAlign CSSNodeStyleGetAlignSelf(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignSelf(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType); + public static extern void YGNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType); [DllImport(DllName)] - public static extern YogaPositionType CSSNodeStyleGetPositionType(IntPtr node); + public static extern YogaPositionType YGNodeStyleGetPositionType(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap); + public static extern void YGNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap); [DllImport(DllName)] - public static extern YogaWrap CSSNodeStyleGetFlexWrap(IntPtr node); + public static extern YogaWrap YGNodeStyleGetFlexWrap(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap); + public static extern void YGNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap); [DllImport(DllName)] - public static extern YogaOverflow CSSNodeStyleGetOverflow(IntPtr node); + public static extern YogaOverflow YGNodeStyleGetOverflow(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex); + public static extern void YGNodeStyleSetFlex(IntPtr node, float flex); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexGrow(IntPtr node, float flexGrow); + public static extern void YGNodeStyleSetFlexGrow(IntPtr node, float flexGrow); [DllImport(DllName)] - public static extern float CSSNodeStyleGetFlexGrow(IntPtr node); + public static extern float YGNodeStyleGetFlexGrow(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexShrink(IntPtr node, float flexShrink); + public static extern void YGNodeStyleSetFlexShrink(IntPtr node, float flexShrink); [DllImport(DllName)] - public static extern float CSSNodeStyleGetFlexShrink(IntPtr node); + public static extern float YGNodeStyleGetFlexShrink(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexBasis(IntPtr node, float flexBasis); + public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis); [DllImport(DllName)] - public static extern float CSSNodeStyleGetFlexBasis(IntPtr node); + public static extern float YGNodeStyleGetFlexBasis(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetWidth(IntPtr node, float width); + public static extern void YGNodeStyleSetWidth(IntPtr node, float width); [DllImport(DllName)] - public static extern float CSSNodeStyleGetWidth(IntPtr node); + public static extern float YGNodeStyleGetWidth(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetHeight(IntPtr node, float height); + public static extern void YGNodeStyleSetHeight(IntPtr node, float height); [DllImport(DllName)] - public static extern float CSSNodeStyleGetHeight(IntPtr node); + public static extern float YGNodeStyleGetHeight(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMinWidth(IntPtr node, float minWidth); + public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMinWidth(IntPtr node); + public static extern float YGNodeStyleGetMinWidth(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMinHeight(IntPtr node, float minHeight); + public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMinHeight(IntPtr node); + public static extern float YGNodeStyleGetMinHeight(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMaxWidth(IntPtr node, float maxWidth); + public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMaxWidth(IntPtr node); + public static extern float YGNodeStyleGetMaxWidth(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMaxHeight(IntPtr node, float maxHeight); + public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMaxHeight(IntPtr node); + public static extern float YGNodeStyleGetMaxHeight(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio); + public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio); [DllImport(DllName)] - public static extern float CSSNodeStyleGetAspectRatio(IntPtr node); + public static extern float YGNodeStyleGetAspectRatio(IntPtr node); #endregion - #region CSS_NODE_STYLE_EDGE_PROPERTY + #region YG_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName)] - public static extern void CSSNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position); + public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position); [DllImport(DllName)] - public static extern float CSSNodeStyleGetPosition(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin); + public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMargin(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding); + public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding); [DllImport(DllName)] - public static extern float CSSNodeStyleGetPadding(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border); + public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border); [DllImport(DllName)] - public static extern float CSSNodeStyleGetBorder(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetBorder(IntPtr node, YogaEdge edge); #endregion - #region CSS_NODE_LAYOUT_PROPERTY + #region YG_NODE_LAYOUT_PROPERTY [DllImport(DllName)] - public static extern float CSSNodeLayoutGetLeft(IntPtr node); + public static extern float YGNodeLayoutGetLeft(IntPtr node); [DllImport(DllName)] - public static extern float CSSNodeLayoutGetTop(IntPtr node); + public static extern float YGNodeLayoutGetTop(IntPtr node); [DllImport(DllName)] - public static extern float CSSNodeLayoutGetRight(IntPtr node); + public static extern float YGNodeLayoutGetRight(IntPtr node); [DllImport(DllName)] - public static extern float CSSNodeLayoutGetBottom(IntPtr node); + public static extern float YGNodeLayoutGetBottom(IntPtr node); [DllImport(DllName)] - public static extern float CSSNodeLayoutGetWidth(IntPtr node); + public static extern float YGNodeLayoutGetWidth(IntPtr node); [DllImport(DllName)] - public static extern float CSSNodeLayoutGetHeight(IntPtr node); + public static extern float YGNodeLayoutGetHeight(IntPtr node); [DllImport(DllName)] - public static extern YogaDirection CSSNodeLayoutGetDirection(IntPtr node); + public static extern YogaDirection YGNodeLayoutGetDirection(IntPtr node); #endregion } diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 8d1b5a6b..9211b28e 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -17,19 +17,19 @@ namespace Facebook.Yoga { public partial class YogaNode : IEnumerable { - private IntPtr _cssNode; + private IntPtr _ygNode; private WeakReference _parent; private List _children; private MeasureFunction _measureFunction; - private YogaMeasureFunc _cssMeasureFunc; + private YogaMeasureFunc _ygMeasureFunc; private object _data; public YogaNode() { YogaLogger.Initialize(); - _cssNode = Native.CSSNodeNew(); - if (_cssNode == IntPtr.Zero) + _ygNode = Native.YGNodeNew(); + if (_ygNode == IntPtr.Zero) { throw new InvalidOperationException("Failed to allocate native memory"); } @@ -37,7 +37,7 @@ namespace Facebook.Yoga ~YogaNode() { - Native.CSSNodeFree(_cssNode); + Native.YGNodeFree(_ygNode); } public void Reset() @@ -45,33 +45,33 @@ namespace Facebook.Yoga _measureFunction = null; _data = null; - Native.CSSNodeReset(_cssNode); + Native.YGNodeReset(_ygNode); } public bool IsDirty { get { - return Native.CSSNodeIsDirty(_cssNode); + return Native.YGNodeIsDirty(_ygNode); } } public virtual void MarkDirty() { - Native.CSSNodeMarkDirty(_cssNode); + Native.YGNodeMarkDirty(_ygNode); } public bool HasNewLayout { get { - return Native.CSSNodeGetHasNewLayout(_cssNode); + return Native.YGNodeGetHasNewLayout(_ygNode); } } public void MarkHasNewLayout() { - Native.CSSNodeSetHasNewLayout(_cssNode, true); + Native.YGNodeSetHasNewLayout(_ygNode, true); } public YogaNode Parent @@ -92,19 +92,19 @@ namespace Facebook.Yoga public void CopyStyle(YogaNode srcNode) { - Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode); + Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode); } public YogaDirection StyleDirection { get { - return Native.CSSNodeStyleGetDirection(_cssNode); + return Native.YGNodeStyleGetDirection(_ygNode); } set { - Native.CSSNodeStyleSetDirection(_cssNode, value); + Native.YGNodeStyleSetDirection(_ygNode, value); } } @@ -112,12 +112,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetFlexDirection(_cssNode); + return Native.YGNodeStyleGetFlexDirection(_ygNode); } set { - Native.CSSNodeStyleSetFlexDirection(_cssNode, value); + Native.YGNodeStyleSetFlexDirection(_ygNode, value); } } @@ -125,12 +125,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetJustifyContent(_cssNode); + return Native.YGNodeStyleGetJustifyContent(_ygNode); } set { - Native.CSSNodeStyleSetJustifyContent(_cssNode, value); + Native.YGNodeStyleSetJustifyContent(_ygNode, value); } } @@ -138,12 +138,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetAlignItems(_cssNode); + return Native.YGNodeStyleGetAlignItems(_ygNode); } set { - Native.CSSNodeStyleSetAlignItems(_cssNode, value); + Native.YGNodeStyleSetAlignItems(_ygNode, value); } } @@ -151,12 +151,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetAlignSelf(_cssNode); + return Native.YGNodeStyleGetAlignSelf(_ygNode); } set { - Native.CSSNodeStyleSetAlignSelf(_cssNode, value); + Native.YGNodeStyleSetAlignSelf(_ygNode, value); } } @@ -164,12 +164,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetAlignContent(_cssNode); + return Native.YGNodeStyleGetAlignContent(_ygNode); } set { - Native.CSSNodeStyleSetAlignContent(_cssNode, value); + Native.YGNodeStyleSetAlignContent(_ygNode, value); } } @@ -177,12 +177,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetPositionType(_cssNode); + return Native.YGNodeStyleGetPositionType(_ygNode); } set { - Native.CSSNodeStyleSetPositionType(_cssNode, value); + Native.YGNodeStyleSetPositionType(_ygNode, value); } } @@ -190,12 +190,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetFlexWrap(_cssNode); + return Native.YGNodeStyleGetFlexWrap(_ygNode); } set { - Native.CSSNodeStyleSetFlexWrap(_cssNode, value); + Native.YGNodeStyleSetFlexWrap(_ygNode, value); } } @@ -203,7 +203,7 @@ namespace Facebook.Yoga { set { - Native.CSSNodeStyleSetFlex(_cssNode, value); + Native.YGNodeStyleSetFlex(_ygNode, value); } } @@ -211,12 +211,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetFlexGrow(_cssNode); + return Native.YGNodeStyleGetFlexGrow(_ygNode); } set { - Native.CSSNodeStyleSetFlexGrow(_cssNode, value); + Native.YGNodeStyleSetFlexGrow(_ygNode, value); } } @@ -224,12 +224,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetFlexShrink(_cssNode); + return Native.YGNodeStyleGetFlexShrink(_ygNode); } set { - Native.CSSNodeStyleSetFlexShrink(_cssNode, value); + Native.YGNodeStyleSetFlexShrink(_ygNode, value); } } @@ -237,65 +237,65 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetFlexBasis(_cssNode); + return Native.YGNodeStyleGetFlexBasis(_ygNode); } set { - Native.CSSNodeStyleSetFlexBasis(_cssNode, value); + Native.YGNodeStyleSetFlexBasis(_ygNode, value); } } public float GetMargin(YogaEdge edge) { - return Native.CSSNodeStyleGetMargin(_cssNode, edge); + return Native.YGNodeStyleGetMargin(_ygNode, edge); } public void SetMargin(YogaEdge edge, float value) { - Native.CSSNodeStyleSetMargin(_cssNode, edge, value); + Native.YGNodeStyleSetMargin(_ygNode, edge, value); } public float GetPadding(YogaEdge edge) { - return Native.CSSNodeStyleGetPadding(_cssNode, edge); + return Native.YGNodeStyleGetPadding(_ygNode, edge); } public void SetPadding(YogaEdge edge, float padding) { - Native.CSSNodeStyleSetPadding(_cssNode, edge, padding); + Native.YGNodeStyleSetPadding(_ygNode, edge, padding); } public float GetBorder(YogaEdge edge) { - return Native.CSSNodeStyleGetBorder(_cssNode, edge); + return Native.YGNodeStyleGetBorder(_ygNode, edge); } public void SetBorder(YogaEdge edge, float border) { - Native.CSSNodeStyleSetBorder(_cssNode, edge, border); + Native.YGNodeStyleSetBorder(_ygNode, edge, border); } public float GetPosition(YogaEdge edge) { - return Native.CSSNodeStyleGetPosition(_cssNode, edge); + return Native.YGNodeStyleGetPosition(_ygNode, edge); } public void SetPosition(YogaEdge edge, float position) { - Native.CSSNodeStyleSetPosition(_cssNode, edge, position); + Native.YGNodeStyleSetPosition(_ygNode, edge, position); } public float Width { get { - return Native.CSSNodeStyleGetWidth(_cssNode); + return Native.YGNodeStyleGetWidth(_ygNode); } set { - Native.CSSNodeStyleSetWidth(_cssNode, value); + Native.YGNodeStyleSetWidth(_ygNode, value); } } @@ -303,12 +303,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetHeight(_cssNode); + return Native.YGNodeStyleGetHeight(_ygNode); } set { - Native.CSSNodeStyleSetHeight(_cssNode, value); + Native.YGNodeStyleSetHeight(_ygNode, value); } } @@ -316,12 +316,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetMaxWidth(_cssNode); + return Native.YGNodeStyleGetMaxWidth(_ygNode); } set { - Native.CSSNodeStyleSetMaxWidth(_cssNode, value); + Native.YGNodeStyleSetMaxWidth(_ygNode, value); } } @@ -329,12 +329,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetMaxHeight(_cssNode); + return Native.YGNodeStyleGetMaxHeight(_ygNode); } set { - Native.CSSNodeStyleSetMaxHeight(_cssNode, value); + Native.YGNodeStyleSetMaxHeight(_ygNode, value); } } @@ -342,12 +342,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetMinWidth(_cssNode); + return Native.YGNodeStyleGetMinWidth(_ygNode); } set { - Native.CSSNodeStyleSetMinWidth(_cssNode, value); + Native.YGNodeStyleSetMinWidth(_ygNode, value); } } @@ -355,12 +355,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetMinHeight(_cssNode); + return Native.YGNodeStyleGetMinHeight(_ygNode); } set { - Native.CSSNodeStyleSetMinHeight(_cssNode, value); + Native.YGNodeStyleSetMinHeight(_ygNode, value); } } @@ -368,12 +368,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetAspectRatio(_cssNode); + return Native.YGNodeStyleGetAspectRatio(_ygNode); } set { - Native.CSSNodeStyleSetAspectRatio(_cssNode, value); + Native.YGNodeStyleSetAspectRatio(_ygNode, value); } } @@ -381,7 +381,7 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeLayoutGetLeft(_cssNode); + return Native.YGNodeLayoutGetLeft(_ygNode); } } @@ -389,7 +389,7 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeLayoutGetTop(_cssNode); + return Native.YGNodeLayoutGetTop(_ygNode); } } @@ -397,7 +397,7 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeLayoutGetWidth(_cssNode); + return Native.YGNodeLayoutGetWidth(_ygNode); } } @@ -405,7 +405,7 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeLayoutGetHeight(_cssNode); + return Native.YGNodeLayoutGetHeight(_ygNode); } } @@ -413,7 +413,7 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeLayoutGetDirection(_cssNode); + return Native.YGNodeLayoutGetDirection(_ygNode); } } @@ -421,12 +421,12 @@ namespace Facebook.Yoga { get { - return Native.CSSNodeStyleGetOverflow(_cssNode); + return Native.YGNodeStyleGetOverflow(_ygNode); } set { - Native.CSSNodeStyleSetOverflow(_cssNode, value); + Native.YGNodeStyleSetOverflow(_ygNode, value); } } @@ -461,7 +461,7 @@ namespace Facebook.Yoga public void MarkLayoutSeen() { - Native.CSSNodeSetHasNewLayout(_cssNode, false); + Native.YGNodeSetHasNewLayout(_ygNode, false); } public bool ValuesEqual(float f1, float f2) @@ -482,7 +482,7 @@ namespace Facebook.Yoga } _children.Insert(index, node); node._parent = new WeakReference(this); - Native.CSSNodeInsertChild(_cssNode, node._cssNode, (uint)index); + Native.YGNodeInsertChild(_ygNode, node._ygNode, (uint)index); } public void RemoveAt(int index) @@ -490,7 +490,7 @@ namespace Facebook.Yoga var child = _children[index]; child._parent = null; _children.RemoveAt(index); - Native.CSSNodeRemoveChild(_cssNode, child._cssNode); + Native.YGNodeRemoveChild(_ygNode, child._ygNode); } public void Clear() @@ -512,17 +512,17 @@ namespace Facebook.Yoga public void SetMeasureFunction(MeasureFunction measureFunction) { _measureFunction = measureFunction; - _cssMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null; - Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc); + _ygMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null; + Native.YGNodeSetMeasureFunc(_ygNode, _ygMeasureFunc); } public void CalculateLayout() { - Native.CSSNodeCalculateLayout( - _cssNode, + Native.YGNodeCalculateLayout( + _ygNode, YogaConstants.Undefined, YogaConstants.Undefined, - Native.CSSNodeStyleGetDirection(_cssNode)); + Native.YGNodeStyleGetDirection(_ygNode)); } private YogaSize MeasureInternal( @@ -547,7 +547,7 @@ namespace Facebook.Yoga StringBuilder sb = new StringBuilder(); YogaLogger.Func orig = YogaLogger.Logger; YogaLogger.Logger = (level, message) => {sb.Append(message);}; - Native.CSSNodePrint(_cssNode, options); + Native.YGNodePrint(_ygNode, options); YogaLogger.Logger = orig; return sb.ToString(); } @@ -566,19 +566,19 @@ namespace Facebook.Yoga public static int GetInstanceCount() { - return Native.CSSNodeGetInstanceCount(); + return Native.YGNodeGetInstanceCount(); } public static void SetExperimentalFeatureEnabled( YogaExperimentalFeature feature, bool enabled) { - Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); + Native.YGSetExperimentalFeatureEnabled(feature, enabled); } public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature) { - return Native.CSSLayoutIsExperimentalFeatureEnabled(feature); + return Native.YGIsExperimentalFeatureEnabled(feature); } } } diff --git a/csharp/Yoga/YGInterop.cpp b/csharp/Yoga/YGInterop.cpp index 04c849cd..fc2043dc 100644 --- a/csharp/Yoga/YGInterop.cpp +++ b/csharp/Yoga/YGInterop.cpp @@ -23,5 +23,5 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) { gManagedFunc = managedFunc; - CSSLayoutSetLogger(&unmanagedLogger); + YGSetLogger(&unmanagedLogger); } diff --git a/csharp/Yoga/YGInterop.h b/csharp/Yoga/YGInterop.h index 546bf46b..b544d3db 100644 --- a/csharp/Yoga/YGInterop.h +++ b/csharp/Yoga/YGInterop.h @@ -9,12 +9,12 @@ #pragma once -#include +#include -CSS_EXTERN_C_BEGIN +YG_EXTERN_C_BEGIN typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message); WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc); -CSS_EXTERN_C_END +YG_EXTERN_C_END diff --git a/csharp/Yoga/Yoga.vcxproj b/csharp/Yoga/Yoga.vcxproj index b6029218..30d2947d 100755 --- a/csharp/Yoga/Yoga.vcxproj +++ b/csharp/Yoga/Yoga.vcxproj @@ -87,7 +87,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) @@ -102,7 +102,7 @@ Level3 Disabled - _DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + _DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) @@ -119,7 +119,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) @@ -138,7 +138,7 @@ MaxSpeed true true - NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) @@ -150,16 +150,16 @@ - - - + + + - - + + false diff --git a/csharp/Yoga/Yoga.vcxproj.filters b/csharp/Yoga/Yoga.vcxproj.filters index 65c4b19c..415d0824 100755 --- a/csharp/Yoga/Yoga.vcxproj.filters +++ b/csharp/Yoga/Yoga.vcxproj.filters @@ -21,13 +21,13 @@ Header Files - + Header Files - + Header Files - + Header Files @@ -41,10 +41,10 @@ Source Files - + Source Files - + Source Files diff --git a/enums.py b/enums.py index 8360da49..00dbdbc7 100644 --- a/enums.py +++ b/enums.py @@ -114,7 +114,7 @@ def to_java_upper(symbol): root = os.path.dirname(__file__) # write out C header -with open(root + '/CSSLayout/CSSEnums.h', 'w') as f: +with open(root + '/CSSLayout/YGEnums.h', 'w') as f: f.write(LICENSE) remaining = len(ENUMS) for name, values in ENUMS.items(): diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 1d98f7df..ea49d995 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -20,38 +20,38 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { emitPrologue:{value:function() { this.push([ - '#include ', + '#include ', '#include ', '', ]); }}, emitTestPrologue:{value:function(name, experiments) { - this.push('TEST(CSSLayoutTest, ' + name + ') {'); + this.push('TEST(YogaTest, ' + name + ') {'); this.pushIndent(); if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);'); + this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);'); } this.push(''); } }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('const CSSNodeRef ' + nodeName + ' = CSSNodeNew();'); + this.push('const YGNodeRef ' + nodeName + ' = YGNodeNew();'); }}, emitTestEpilogue:{value:function(experiments) { this.push([ '', - 'CSSNodeFreeRecursive(root);', + 'YGNodeFreeRecursive(root);', ]); if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);'); + this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);'); } } @@ -109,114 +109,114 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGUndefined:{value:'YGUndefined'}, CSSNodeCalculateLayout:{value:function(node, dir) { - this.push('CSSNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');'); + this.push('YGNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');'); }}, CSSNodeInsertChild:{value:function(parentName, nodeName, index) { - this.push('CSSNodeInsertChild(' + parentName + ', ' + nodeName + ', ' + index + ');'); + this.push('YGNodeInsertChild(' + parentName + ', ' + nodeName + ', ' + index + ');'); }}, CSSNodeLayoutGetLeft:{value:function(nodeName) { - return 'CSSNodeLayoutGetLeft(' + nodeName + ')'; + return 'YGNodeLayoutGetLeft(' + nodeName + ')'; }}, CSSNodeLayoutGetTop:{value:function(nodeName) { - return 'CSSNodeLayoutGetTop(' + nodeName + ')'; + return 'YGNodeLayoutGetTop(' + nodeName + ')'; }}, CSSNodeLayoutGetWidth:{value:function(nodeName) { - return 'CSSNodeLayoutGetWidth(' + nodeName + ')'; + return 'YGNodeLayoutGetWidth(' + nodeName + ')'; }}, CSSNodeLayoutGetHeight:{value:function(nodeName) { - return 'CSSNodeLayoutGetHeight(' + nodeName + ')'; + return 'YGNodeLayoutGetHeight(' + nodeName + ')'; }}, CSSNodeStyleSetAlignContent:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetAlignItems:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetDirection:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetDirection(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetOverflow(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetPositionType:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetPositionType(' + nodeName + ', ' + value + ');'); + this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');'); }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); + this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, }); diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 1fc2af87..90fe4676 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -27,26 +27,26 @@ public class CSSNode implements CSSNodeAPI { /** * Get native instance count. Useful for testing only. */ - static native int jni_CSSNodeGetInstanceCount(); - static native void jni_CSSLog(int level, String message); + static native int jni_YGNodeGetInstanceCount(); + static native void jni_YGLog(int level, String message); - private static native void jni_CSSLayoutSetLogger(Object logger); + private static native void jni_YGSetLogger(Object logger); public static void setLogger(CSSLogger logger) { - jni_CSSLayoutSetLogger(logger); + jni_YGSetLogger(logger); } - private static native void jni_CSSLayoutSetExperimentalFeatureEnabled( + private static native void jni_YGSetExperimentalFeatureEnabled( int feature, boolean enabled); public static void setExperimentalFeatureEnabled( YogaExperimentalFeature feature, boolean enabled) { - jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled); + jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled); } - private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature); + private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature); public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) { - return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue()); + return jni_YGIsExperimentalFeatureEnabled(feature.intValue()); } private CSSNode mParent; @@ -71,25 +71,25 @@ public class CSSNode implements CSSNodeAPI { @DoNotStrip private int mLayoutDirection = 0; - private native long jni_CSSNodeNew(); + private native long jni_YGNodeNew(); public CSSNode() { - mNativePointer = jni_CSSNodeNew(); + mNativePointer = jni_YGNodeNew(); if (mNativePointer == 0) { throw new IllegalStateException("Failed to allocate native memory"); } } - private native void jni_CSSNodeFree(long nativePointer); + private native void jni_YGNodeFree(long nativePointer); @Override protected void finalize() throws Throwable { try { - jni_CSSNodeFree(mNativePointer); + jni_YGNodeFree(mNativePointer); } finally { super.finalize(); } } - private native void jni_CSSNodeReset(long nativePointer); + private native void jni_YGNodeReset(long nativePointer); @Override public void reset() { mHasSetPadding = false; @@ -106,7 +106,7 @@ public class CSSNode implements CSSNodeAPI { mMeasureFunction = null; mData = null; - jni_CSSNodeReset(mNativePointer); + jni_YGNodeReset(mNativePointer); } @Override @@ -119,7 +119,7 @@ public class CSSNode implements CSSNodeAPI { return mChildren.get(i); } - private native void jni_CSSNodeInsertChild(long nativePointer, long childPointer, int index); + private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index); @Override public void addChildAt(CSSNode child, int i) { if (child.mParent != null) { @@ -131,16 +131,16 @@ public class CSSNode implements CSSNodeAPI { } mChildren.add(i, child); child.mParent = this; - jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i); + jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i); } - private native void jni_CSSNodeRemoveChild(long nativePointer, long childPointer); + private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer); @Override public CSSNode removeChildAt(int i) { final CSSNode child = mChildren.remove(i); child.mParent = null; - jni_CSSNodeRemoveChild(mNativePointer, child.mNativePointer); + jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer); return child; } @@ -155,330 +155,330 @@ public class CSSNode implements CSSNodeAPI { return mChildren == null ? -1 : mChildren.indexOf(child); } - private native void jni_CSSNodeCalculateLayout(long nativePointer); + private native void jni_YGNodeCalculateLayout(long nativePointer); @Override public void calculateLayout() { - jni_CSSNodeCalculateLayout(mNativePointer); + jni_YGNodeCalculateLayout(mNativePointer); } - private native boolean jni_CSSNodeHasNewLayout(long nativePointer); + private native boolean jni_YGNodeHasNewLayout(long nativePointer); @Override public boolean hasNewLayout() { - return jni_CSSNodeHasNewLayout(mNativePointer); + return jni_YGNodeHasNewLayout(mNativePointer); } - private native void jni_CSSNodeMarkDirty(long nativePointer); + private native void jni_YGNodeMarkDirty(long nativePointer); @Override public void dirty() { - jni_CSSNodeMarkDirty(mNativePointer); + jni_YGNodeMarkDirty(mNativePointer); } - private native boolean jni_CSSNodeIsDirty(long nativePointer); + private native boolean jni_YGNodeIsDirty(long nativePointer); @Override public boolean isDirty() { - return jni_CSSNodeIsDirty(mNativePointer); + return jni_YGNodeIsDirty(mNativePointer); } - private native void jni_CSSNodeMarkLayoutSeen(long nativePointer); + private native void jni_YGNodeMarkLayoutSeen(long nativePointer); @Override public void markLayoutSeen() { - jni_CSSNodeMarkLayoutSeen(mNativePointer); + jni_YGNodeMarkLayoutSeen(mNativePointer); } - private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer); + private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer); @Override public void copyStyle(CSSNode srcNode) { - jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer); + jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer); } - private native int jni_CSSNodeStyleGetDirection(long nativePointer); + private native int jni_YGNodeStyleGetDirection(long nativePointer); @Override public YogaDirection getStyleDirection() { - return YogaDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)]; + return YogaDirection.values()[jni_YGNodeStyleGetDirection(mNativePointer)]; } - private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction); + private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction); @Override public void setDirection(YogaDirection direction) { - jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue()); + jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue()); } - private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer); + private native int jni_YGNodeStyleGetFlexDirection(long nativePointer); @Override public YogaFlexDirection getFlexDirection() { - return YogaFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)]; + return YogaFlexDirection.values()[jni_YGNodeStyleGetFlexDirection(mNativePointer)]; } - private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection); + private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection); @Override public void setFlexDirection(YogaFlexDirection flexDirection) { - jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue()); + jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue()); } - private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer); + private native int jni_YGNodeStyleGetJustifyContent(long nativePointer); @Override public YogaJustify getJustifyContent() { - return YogaJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)]; + return YogaJustify.values()[jni_YGNodeStyleGetJustifyContent(mNativePointer)]; } - private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent); + private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent); @Override public void setJustifyContent(YogaJustify justifyContent) { - jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue()); + jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue()); } - private native int jni_CSSNodeStyleGetAlignItems(long nativePointer); + private native int jni_YGNodeStyleGetAlignItems(long nativePointer); @Override public YogaAlign getAlignItems() { - return YogaAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)]; + return YogaAlign.values()[jni_YGNodeStyleGetAlignItems(mNativePointer)]; } - private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems); + private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems); @Override public void setAlignItems(YogaAlign alignItems) { - jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue()); + jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue()); } - private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer); + private native int jni_YGNodeStyleGetAlignSelf(long nativePointer); @Override public YogaAlign getAlignSelf() { - return YogaAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)]; + return YogaAlign.values()[jni_YGNodeStyleGetAlignSelf(mNativePointer)]; } - private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf); + private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf); @Override public void setAlignSelf(YogaAlign alignSelf) { - jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue()); + jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue()); } - private native int jni_CSSNodeStyleGetAlignContent(long nativePointer); + private native int jni_YGNodeStyleGetAlignContent(long nativePointer); @Override public YogaAlign getAlignContent() { - return YogaAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)]; + return YogaAlign.values()[jni_YGNodeStyleGetAlignContent(mNativePointer)]; } - private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent); + private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent); @Override public void setAlignContent(YogaAlign alignContent) { - jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue()); + jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue()); } - private native int jni_CSSNodeStyleGetPositionType(long nativePointer); + private native int jni_YGNodeStyleGetPositionType(long nativePointer); @Override public YogaPositionType getPositionType() { - return YogaPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)]; + return YogaPositionType.values()[jni_YGNodeStyleGetPositionType(mNativePointer)]; } - private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType); + private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType); @Override public void setPositionType(YogaPositionType positionType) { - jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue()); + jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue()); } - private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType); + private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType); @Override public void setWrap(YogaWrap flexWrap) { - jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue()); + jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue()); } - private native int jni_CSSNodeStyleGetOverflow(long nativePointer); + private native int jni_YGNodeStyleGetOverflow(long nativePointer); @Override public YogaOverflow getOverflow() { - return YogaOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)]; + return YogaOverflow.values()[jni_YGNodeStyleGetOverflow(mNativePointer)]; } - private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow); + private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow); @Override public void setOverflow(YogaOverflow overflow) { - jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue()); + jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue()); } - private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex); + private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex); @Override public void setFlex(float flex) { - jni_CSSNodeStyleSetFlex(mNativePointer, flex); + jni_YGNodeStyleSetFlex(mNativePointer, flex); } - private native float jni_CSSNodeStyleGetFlexGrow(long nativePointer); + private native float jni_YGNodeStyleGetFlexGrow(long nativePointer); @Override public float getFlexGrow() { - return jni_CSSNodeStyleGetFlexGrow(mNativePointer); + return jni_YGNodeStyleGetFlexGrow(mNativePointer); } - private native void jni_CSSNodeStyleSetFlexGrow(long nativePointer, float flexGrow); + private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow); @Override public void setFlexGrow(float flexGrow) { - jni_CSSNodeStyleSetFlexGrow(mNativePointer, flexGrow); + jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow); } - private native float jni_CSSNodeStyleGetFlexShrink(long nativePointer); + private native float jni_YGNodeStyleGetFlexShrink(long nativePointer); @Override public float getFlexShrink() { - return jni_CSSNodeStyleGetFlexShrink(mNativePointer); + return jni_YGNodeStyleGetFlexShrink(mNativePointer); } - private native void jni_CSSNodeStyleSetFlexShrink(long nativePointer, float flexShrink); + private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink); @Override public void setFlexShrink(float flexShrink) { - jni_CSSNodeStyleSetFlexShrink(mNativePointer, flexShrink); + jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink); } - private native float jni_CSSNodeStyleGetFlexBasis(long nativePointer); + private native float jni_YGNodeStyleGetFlexBasis(long nativePointer); @Override public float getFlexBasis() { - return jni_CSSNodeStyleGetFlexBasis(mNativePointer); + return jni_YGNodeStyleGetFlexBasis(mNativePointer); } - private native void jni_CSSNodeStyleSetFlexBasis(long nativePointer, float flexBasis); + private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis); @Override public void setFlexBasis(float flexBasis) { - jni_CSSNodeStyleSetFlexBasis(mNativePointer, flexBasis); + jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis); } - private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge); + private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge); @Override public float getMargin(YogaEdge edge) { if (!mHasSetMargin) { return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } - return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue()); + return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()); } - private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin); + private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin); @Override public void setMargin(YogaEdge edge, float margin) { mHasSetMargin = true; - jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); + jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); } - private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge); + private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge); @Override public float getPadding(YogaEdge edge) { if (!mHasSetPadding) { return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } - return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue()); + return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()); } - private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding); + private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding); @Override public void setPadding(YogaEdge edge, float padding) { mHasSetPadding = true; - jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); + jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); } - private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge); + private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge); @Override public float getBorder(YogaEdge edge) { if (!mHasSetBorder) { return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } - return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue()); + return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue()); } - private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border); + private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border); @Override public void setBorder(YogaEdge edge, float border) { mHasSetBorder = true; - jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border); + jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border); } - private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge); + private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge); @Override public float getPosition(YogaEdge edge) { if (!mHasSetPosition) { return YogaConstants.UNDEFINED; } - return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue()); + return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()); } - private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position); + private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position); @Override public void setPosition(YogaEdge edge, float position) { mHasSetPosition = true; - jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position); + jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position); } - private native float jni_CSSNodeStyleGetWidth(long nativePointer); + private native float jni_YGNodeStyleGetWidth(long nativePointer); @Override public float getWidth() { - return jni_CSSNodeStyleGetWidth(mNativePointer); + return jni_YGNodeStyleGetWidth(mNativePointer); } - private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width); + private native void jni_YGNodeStyleSetWidth(long nativePointer, float width); @Override public void setWidth(float width) { - jni_CSSNodeStyleSetWidth(mNativePointer, width); + jni_YGNodeStyleSetWidth(mNativePointer, width); } - private native float jni_CSSNodeStyleGetHeight(long nativePointer); + private native float jni_YGNodeStyleGetHeight(long nativePointer); @Override public float getHeight() { - return jni_CSSNodeStyleGetHeight(mNativePointer); + return jni_YGNodeStyleGetHeight(mNativePointer); } - private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height); + private native void jni_YGNodeStyleSetHeight(long nativePointer, float height); @Override public void setHeight(float height) { - jni_CSSNodeStyleSetHeight(mNativePointer, height); + jni_YGNodeStyleSetHeight(mNativePointer, height); } - private native float jni_CSSNodeStyleGetMinWidth(long nativePointer); + private native float jni_YGNodeStyleGetMinWidth(long nativePointer); @Override public float getMinWidth() { - return jni_CSSNodeStyleGetMinWidth(mNativePointer); + return jni_YGNodeStyleGetMinWidth(mNativePointer); } - private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth); + private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth); @Override public void setMinWidth(float minWidth) { - jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth); + jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth); } - private native float jni_CSSNodeStyleGetMinHeight(long nativePointer); + private native float jni_YGNodeStyleGetMinHeight(long nativePointer); @Override public float getMinHeight() { - return jni_CSSNodeStyleGetMinHeight(mNativePointer); + return jni_YGNodeStyleGetMinHeight(mNativePointer); } - private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight); + private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight); @Override public void setMinHeight(float minHeight) { - jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight); + jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight); } - private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer); + private native float jni_YGNodeStyleGetMaxWidth(long nativePointer); @Override public float getMaxWidth() { - return jni_CSSNodeStyleGetMaxWidth(mNativePointer); + return jni_YGNodeStyleGetMaxWidth(mNativePointer); } - private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth); + private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth); @Override public void setMaxWidth(float maxWidth) { - jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth); + jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth); } - private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer); + private native float jni_YGNodeStyleGetMaxHeight(long nativePointer); @Override public float getMaxHeight() { - return jni_CSSNodeStyleGetMaxHeight(mNativePointer); + return jni_YGNodeStyleGetMaxHeight(mNativePointer); } - private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight); + private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight); @Override public void setMaxHeight(float maxheight) { - jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); + jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight); } - private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer); + private native float jni_YGNodeStyleGetAspectRatio(long nativePointer); public float getAspectRatio() { - return jni_CSSNodeStyleGetAspectRatio(mNativePointer); + return jni_YGNodeStyleGetAspectRatio(mNativePointer); } - private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio); + private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio); public void setAspectRatio(float aspectRatio) { - jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio); + jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio); } @Override @@ -506,11 +506,11 @@ public class CSSNode implements CSSNodeAPI { return YogaDirection.values()[mLayoutDirection]; } - private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc); + private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc); @Override public void setMeasureFunction(MeasureFunction measureFunction) { mMeasureFunction = measureFunction; - jni_CSSNodeSetHasMeasureFunc(mNativePointer, measureFunction != null); + jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null); } // Implementation Note: Why this method needs to stay final diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp deleted file mode 100644 index 1a01570d..00000000 --- a/java/jni/CSSJNI.cpp +++ /dev/null @@ -1,340 +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. - */ - -#include -#include -#include - -using namespace facebook::jni; -using namespace std; - -static inline weak_ref *jobjectContext(CSSNodeRef node) { - return reinterpret_cast *>(CSSNodeGetContext(node)); -} - -static void _jniTransferLayoutDirection(CSSNodeRef node, alias_ref javaNode) { - static auto layoutDirectionField = javaNode->getClass()->getField("mLayoutDirection"); - javaNode->setFieldValue(layoutDirectionField, static_cast(CSSNodeLayoutGetDirection(node))); -} - -static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) { - if (auto obj = jobjectContext(root)->lockLocal()) { - static auto widthField = obj->getClass()->getField("mWidth"); - static auto heightField = obj->getClass()->getField("mHeight"); - static auto leftField = obj->getClass()->getField("mLeft"); - static auto topField = obj->getClass()->getField("mTop"); - - obj->setFieldValue(widthField, CSSNodeLayoutGetWidth(root)); - obj->setFieldValue(heightField, CSSNodeLayoutGetHeight(root)); - obj->setFieldValue(leftField, CSSNodeLayoutGetLeft(root)); - obj->setFieldValue(topField, CSSNodeLayoutGetTop(root)); - _jniTransferLayoutDirection(root, obj); - - for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) { - _jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i)); - } - } else { - CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); - } -} - -static void _jniPrint(CSSNodeRef node) { - if (auto obj = jobjectContext(node)->lockLocal()) { - cout << obj->toString() << endl; - } else { - CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); - } -} - -static CSSSize _jniMeasureFunc(CSSNodeRef node, - float width, - YGMeasureMode widthMode, - float height, - YGMeasureMode heightMode) { - if (auto obj = jobjectContext(node)->lockLocal()) { - static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") - ->getMethod("measure"); - - _jniTransferLayoutDirection(node, obj); - const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); - - static_assert(sizeof(measureResult) == 8, - "Expected measureResult to be 8 bytes, or two 32 bit ints"); - - const float measuredWidth = static_cast(0xFFFFFFFF & (measureResult >> 32)); - const float measuredHeight = static_cast(0xFFFFFFFF & measureResult); - - return CSSSize{measuredWidth, measuredHeight}; - } else { - CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); - return CSSSize{ - widthMode == YGMeasureModeUndefined ? 0 : width, - heightMode == YGMeasureModeUndefined ? 0 : height, - }; - } -} - -struct JYogaLogLevel : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;"; -}; - -static global_ref *jLogger; -static int _jniLog(YGLogLevel level, const char *format, va_list args) { - char buffer[256]; - int result = vsnprintf(buffer, sizeof(buffer), format, args); - - static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger") - ->getMethod, jstring)>("log"); - - static auto logLevelFromInt = - JYogaLogLevel::javaClassStatic()->getStaticMethod("fromInt"); - - logFunc(jLogger->get(), - logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast(level)), - Environment::current()->NewStringUTF(buffer)); - - return result; -} - -static inline CSSNodeRef _jlong2CSSNodeRef(jlong addr) { - return reinterpret_cast(static_cast(addr)); -} - -void jni_CSSLayoutSetLogger(alias_ref clazz, alias_ref logger) { - if (jLogger) { - jLogger->releaseAlias(); - delete jLogger; - } - - if (logger) { - jLogger = new global_ref(make_global(logger)); - CSSLayoutSetLogger(_jniLog); - } else { - jLogger = NULL; - CSSLayoutSetLogger(NULL); - } -} - -void jni_CSSLog(alias_ref clazz, jint level, jstring message) { - const char *nMessage = Environment::current()->GetStringUTFChars(message, 0); - CSSLog(static_cast(level), "%s", nMessage); - Environment::current()->ReleaseStringUTFChars(message, nMessage); -} - -void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref clazz, - jint feature, - jboolean enabled) { - CSSLayoutSetExperimentalFeatureEnabled(static_cast(feature), enabled); -} - -jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref clazz, jint feature) { - return CSSLayoutIsExperimentalFeatureEnabled(static_cast(feature)); -} - -jint jni_CSSNodeGetInstanceCount(alias_ref clazz) { - return CSSNodeGetInstanceCount(); -} - -jlong jni_CSSNodeNew(alias_ref thiz) { - const CSSNodeRef node = CSSNodeNew(); - CSSNodeSetContext(node, new weak_ref(make_weak(thiz))); - CSSNodeSetPrintFunc(node, _jniPrint); - return reinterpret_cast(node); -} - -void jni_CSSNodeFree(alias_ref thiz, jlong nativePointer) { - const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer); - delete jobjectContext(node); - CSSNodeFree(node); -} - -void jni_CSSNodeReset(alias_ref thiz, jlong nativePointer) { - const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer); - void *context = CSSNodeGetContext(node); - CSSNodeReset(node); - CSSNodeSetContext(node, context); - CSSNodeSetPrintFunc(node, _jniPrint); -} - -void jni_CSSNodeInsertChild(alias_ref, - jlong nativePointer, - jlong childPointer, - jint index) { - CSSNodeInsertChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer), index); -} - -void jni_CSSNodeRemoveChild(alias_ref, jlong nativePointer, jlong childPointer) { - CSSNodeRemoveChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer)); -} - -void jni_CSSNodeCalculateLayout(alias_ref, jlong nativePointer) { - const CSSNodeRef root = _jlong2CSSNodeRef(nativePointer); - CSSNodeCalculateLayout(root, - YGUndefined, - YGUndefined, - CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer))); - _jniTransferLayoutOutputsRecursive(root); -} - -void jni_CSSNodeMarkDirty(alias_ref, jlong nativePointer) { - CSSNodeMarkDirty(_jlong2CSSNodeRef(nativePointer)); -} - -jboolean jni_CSSNodeIsDirty(alias_ref, jlong nativePointer) { - return (jboolean) CSSNodeIsDirty(_jlong2CSSNodeRef(nativePointer)); -} - -void jni_CSSNodeSetHasMeasureFunc(alias_ref, - jlong nativePointer, - jboolean hasMeasureFunc) { - CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL); -} - -jboolean jni_CSSNodeHasNewLayout(alias_ref, jlong nativePointer) { - return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer)); -} - -void jni_CSSNodeMarkLayoutSeen(alias_ref, jlong nativePointer) { - CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false); -} - -void jni_CSSNodeCopyStyle(alias_ref, jlong dstNativePointer, jlong srcNativePointer) { - CSSNodeCopyStyle(_jlong2CSSNodeRef(dstNativePointer), _jlong2CSSNodeRef(srcNativePointer)); -} - -#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \ - javatype jni_CSSNodeStyleGet##name(alias_ref, jlong nativePointer) { \ - return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \ - } \ - \ - void jni_CSSNodeStyleSet##name(alias_ref, jlong nativePointer, javatype value) { \ - CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), static_cast(value)); \ - } - -#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ - javatype jni_CSSNodeStyleGet##name(alias_ref, jlong nativePointer, jint edge) { \ - return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer), \ - static_cast(edge)); \ - } \ - \ - void jni_CSSNodeStyleSet##name(alias_ref, \ - jlong nativePointer, \ - jint edge, \ - javatype value) { \ - CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \ - static_cast(edge), \ - static_cast(value)); \ - } - -CSS_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction); -CSS_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection); -CSS_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent); -CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems); -CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf); -CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent); -CSS_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType); -CSS_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap); -CSS_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow); - -void jni_CSSNodeStyleSetFlex(alias_ref, jlong nativePointer, jfloat value) { - CSSNodeStyleSetFlex(_jlong2CSSNodeRef(nativePointer), static_cast(value)); -} -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis); - -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding); -CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border); - -CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); -CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); - -// Yoga specific properties, not compatible with flexbox specification -CSS_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); - -#define CSSMakeNativeMethod(name) makeNativeMethod(#name, name) - -jint JNI_OnLoad(JavaVM *vm, void *) { - return initialize(vm, [] { - registerNatives("com/facebook/csslayout/CSSNode", - { - CSSMakeNativeMethod(jni_CSSNodeNew), - CSSMakeNativeMethod(jni_CSSNodeFree), - CSSMakeNativeMethod(jni_CSSNodeReset), - CSSMakeNativeMethod(jni_CSSNodeInsertChild), - CSSMakeNativeMethod(jni_CSSNodeRemoveChild), - CSSMakeNativeMethod(jni_CSSNodeCalculateLayout), - CSSMakeNativeMethod(jni_CSSNodeHasNewLayout), - CSSMakeNativeMethod(jni_CSSNodeMarkDirty), - CSSMakeNativeMethod(jni_CSSNodeIsDirty), - CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen), - CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc), - CSSMakeNativeMethod(jni_CSSNodeCopyStyle), - - CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection), - CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection), - CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexDirection), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexDirection), - CSSMakeNativeMethod(jni_CSSNodeStyleGetJustifyContent), - CSSMakeNativeMethod(jni_CSSNodeStyleSetJustifyContent), - CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignItems), - CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignItems), - CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignSelf), - CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignSelf), - CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignContent), - CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignContent), - CSSMakeNativeMethod(jni_CSSNodeStyleGetPositionType), - CSSMakeNativeMethod(jni_CSSNodeStyleSetPositionType), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexWrap), - CSSMakeNativeMethod(jni_CSSNodeStyleGetOverflow), - CSSMakeNativeMethod(jni_CSSNodeStyleSetOverflow), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlex), - CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexGrow), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexGrow), - CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexShrink), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexShrink), - CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexBasis), - CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexBasis), - CSSMakeNativeMethod(jni_CSSNodeStyleGetMargin), - CSSMakeNativeMethod(jni_CSSNodeStyleSetMargin), - CSSMakeNativeMethod(jni_CSSNodeStyleGetPadding), - CSSMakeNativeMethod(jni_CSSNodeStyleSetPadding), - CSSMakeNativeMethod(jni_CSSNodeStyleGetBorder), - CSSMakeNativeMethod(jni_CSSNodeStyleSetBorder), - CSSMakeNativeMethod(jni_CSSNodeStyleGetPosition), - CSSMakeNativeMethod(jni_CSSNodeStyleSetPosition), - CSSMakeNativeMethod(jni_CSSNodeStyleGetWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleSetWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleGetHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleSetHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleGetMinWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleSetMinWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleGetMinHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleSetMinHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth), - CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight), - CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio), - CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio), - - CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount), - CSSMakeNativeMethod(jni_CSSLayoutSetLogger), - CSSMakeNativeMethod(jni_CSSLog), - CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled), - CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled), - }); - }); -} diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp new file mode 100644 index 00000000..a7d6d81b --- /dev/null +++ b/java/jni/YGJNI.cpp @@ -0,0 +1,333 @@ +/** + * 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. + */ + +#include +#include +#include + +using namespace facebook::jni; +using namespace std; + +static inline weak_ref *YGNodeJobject(YGNodeRef node) { + return reinterpret_cast *>(YGNodeGetContext(node)); +} + +static void YGTransferLayoutDirection(YGNodeRef node, alias_ref javaNode) { + static auto layoutDirectionField = javaNode->getClass()->getField("mLayoutDirection"); + javaNode->setFieldValue(layoutDirectionField, static_cast(YGNodeLayoutGetDirection(node))); +} + +static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { + if (auto obj = YGNodeJobject(root)->lockLocal()) { + static auto widthField = obj->getClass()->getField("mWidth"); + static auto heightField = obj->getClass()->getField("mHeight"); + static auto leftField = obj->getClass()->getField("mLeft"); + static auto topField = obj->getClass()->getField("mTop"); + + obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root)); + obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root)); + obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root)); + obj->setFieldValue(topField, YGNodeLayoutGetTop(root)); + YGTransferLayoutDirection(root, obj); + + for (uint32_t i = 0; i < YGNodeChildCount(root); i++) { + YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i)); + } + } else { + YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n"); + } +} + +static void YGPrint(YGNodeRef node) { + if (auto obj = YGNodeJobject(node)->lockLocal()) { + cout << obj->toString() << endl; + } else { + YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n"); + } +} + +static YGSize YGJNIMeasureFunc(YGNodeRef node, + float width, + YGMeasureMode widthMode, + float height, + YGMeasureMode heightMode) { + if (auto obj = YGNodeJobject(node)->lockLocal()) { + static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") + ->getMethod("measure"); + + YGTransferLayoutDirection(node, obj); + const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); + + static_assert(sizeof(measureResult) == 8, + "Expected measureResult to be 8 bytes, or two 32 bit ints"); + + const float measuredWidth = static_cast(0xFFFFFFFF & (measureResult >> 32)); + const float measuredHeight = static_cast(0xFFFFFFFF & measureResult); + + return YGSize{measuredWidth, measuredHeight}; + } else { + YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n"); + return YGSize{ + widthMode == YGMeasureModeUndefined ? 0 : width, + heightMode == YGMeasureModeUndefined ? 0 : height, + }; + } +} + +struct JYogaLogLevel : public JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;"; +}; + +static global_ref *jLogger; +static int YGLog(YGLogLevel level, const char *format, va_list args) { + char buffer[256]; + int result = vsnprintf(buffer, sizeof(buffer), format, args); + + static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger") + ->getMethod, jstring)>("log"); + + static auto logLevelFromInt = + JYogaLogLevel::javaClassStatic()->getStaticMethod("fromInt"); + + logFunc(jLogger->get(), + logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast(level)), + Environment::current()->NewStringUTF(buffer)); + + return result; +} + +static inline YGNodeRef _jlong2YGNodeRef(jlong addr) { + return reinterpret_cast(static_cast(addr)); +} + +void jni_YGSetLogger(alias_ref clazz, alias_ref logger) { + if (jLogger) { + jLogger->releaseAlias(); + delete jLogger; + } + + if (logger) { + jLogger = new global_ref(make_global(logger)); + YGSetLogger(YGLog); + } else { + jLogger = NULL; + YGSetLogger(NULL); + } +} + +void jni_YGLog(alias_ref clazz, jint level, jstring message) { + const char *nMessage = Environment::current()->GetStringUTFChars(message, 0); + YGLog(static_cast(level), "%s", nMessage); + Environment::current()->ReleaseStringUTFChars(message, nMessage); +} + +void jni_YGSetExperimentalFeatureEnabled(alias_ref clazz, jint feature, jboolean enabled) { + YGSetExperimentalFeatureEnabled(static_cast(feature), enabled); +} + +jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref clazz, jint feature) { + return YGIsExperimentalFeatureEnabled(static_cast(feature)); +} + +jint jni_YGNodeGetInstanceCount(alias_ref clazz) { + return YGNodeGetInstanceCount(); +} + +jlong jni_YGNodeNew(alias_ref thiz) { + const YGNodeRef node = YGNodeNew(); + YGNodeSetContext(node, new weak_ref(make_weak(thiz))); + YGNodeSetPrintFunc(node, YGPrint); + return reinterpret_cast(node); +} + +void jni_YGNodeFree(alias_ref thiz, jlong nativePointer) { + const YGNodeRef node = _jlong2YGNodeRef(nativePointer); + delete YGNodeJobject(node); + YGNodeFree(node); +} + +void jni_YGNodeReset(alias_ref thiz, jlong nativePointer) { + const YGNodeRef node = _jlong2YGNodeRef(nativePointer); + void *context = YGNodeGetContext(node); + YGNodeReset(node); + YGNodeSetContext(node, context); + YGNodeSetPrintFunc(node, YGPrint); +} + +void jni_YGNodeInsertChild(alias_ref, jlong nativePointer, jlong childPointer, jint index) { + YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); +} + +void jni_YGNodeRemoveChild(alias_ref, jlong nativePointer, jlong childPointer) { + YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer)); +} + +void jni_YGNodeCalculateLayout(alias_ref, jlong nativePointer) { + const YGNodeRef root = _jlong2YGNodeRef(nativePointer); + YGNodeCalculateLayout(root, + YGUndefined, + YGUndefined, + YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer))); + YGTransferLayoutOutputsRecursive(root); +} + +void jni_YGNodeMarkDirty(alias_ref, jlong nativePointer) { + YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer)); +} + +jboolean jni_YGNodeIsDirty(alias_ref, jlong nativePointer) { + return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer)); +} + +void jni_YGNodeSetHasMeasureFunc(alias_ref, jlong nativePointer, jboolean hasMeasureFunc) { + YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL); +} + +jboolean jni_YGNodeHasNewLayout(alias_ref, jlong nativePointer) { + return (jboolean) YGNodeGetHasNewLayout(_jlong2YGNodeRef(nativePointer)); +} + +void jni_YGNodeMarkLayoutSeen(alias_ref, jlong nativePointer) { + YGNodeSetHasNewLayout(_jlong2YGNodeRef(nativePointer), false); +} + +void jni_YGNodeCopyStyle(alias_ref, jlong dstNativePointer, jlong srcNativePointer) { + YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer)); +} + +#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ + javatype jni_YGNodeStyleGet##name(alias_ref, jlong nativePointer) { \ + return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ + } \ + \ + void jni_YGNodeStyleSet##name(alias_ref, jlong nativePointer, javatype value) { \ + YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast(value)); \ + } + +#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ + javatype jni_YGNodeStyleGet##name(alias_ref, jlong nativePointer, jint edge) { \ + return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \ + static_cast(edge)); \ + } \ + \ + void jni_YGNodeStyleSet##name(alias_ref, \ + jlong nativePointer, \ + jint edge, \ + javatype value) { \ + YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \ + static_cast(edge), \ + static_cast(value)); \ + } + +YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction); +YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection); +YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent); +YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems); +YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf); +YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent); +YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType); +YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap); +YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow); + +void jni_YGNodeStyleSetFlex(alias_ref, jlong nativePointer, jfloat value) { + YGNodeStyleSetFlex(_jlong2YGNodeRef(nativePointer), static_cast(value)); +} +YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow); +YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink); +YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis); + +YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position); +YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin); +YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding); +YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border); + +YG_NODE_JNI_STYLE_PROP(jfloat, float, Width); +YG_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth); +YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth); +YG_NODE_JNI_STYLE_PROP(jfloat, float, Height); +YG_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); +YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); + +// Yoga specific properties, not compatible with flexbox specification +YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); + +#define YGMakeNativeMethod(name) makeNativeMethod(#name, name) + +jint JNI_OnLoad(JavaVM *vm, void *) { + return initialize(vm, [] { + registerNatives("com/facebook/csslayout/CSSNode", + { + YGMakeNativeMethod(jni_YGNodeNew), + YGMakeNativeMethod(jni_YGNodeFree), + YGMakeNativeMethod(jni_YGNodeReset), + YGMakeNativeMethod(jni_YGNodeInsertChild), + YGMakeNativeMethod(jni_YGNodeRemoveChild), + YGMakeNativeMethod(jni_YGNodeCalculateLayout), + YGMakeNativeMethod(jni_YGNodeHasNewLayout), + YGMakeNativeMethod(jni_YGNodeMarkDirty), + YGMakeNativeMethod(jni_YGNodeIsDirty), + YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen), + YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc), + YGMakeNativeMethod(jni_YGNodeCopyStyle), + + YGMakeNativeMethod(jni_YGNodeStyleGetDirection), + YGMakeNativeMethod(jni_YGNodeStyleSetDirection), + YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection), + YGMakeNativeMethod(jni_YGNodeStyleSetFlexDirection), + YGMakeNativeMethod(jni_YGNodeStyleGetJustifyContent), + YGMakeNativeMethod(jni_YGNodeStyleSetJustifyContent), + YGMakeNativeMethod(jni_YGNodeStyleGetAlignItems), + YGMakeNativeMethod(jni_YGNodeStyleSetAlignItems), + YGMakeNativeMethod(jni_YGNodeStyleGetAlignSelf), + YGMakeNativeMethod(jni_YGNodeStyleSetAlignSelf), + YGMakeNativeMethod(jni_YGNodeStyleGetAlignContent), + YGMakeNativeMethod(jni_YGNodeStyleSetAlignContent), + YGMakeNativeMethod(jni_YGNodeStyleGetPositionType), + YGMakeNativeMethod(jni_YGNodeStyleSetPositionType), + YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap), + YGMakeNativeMethod(jni_YGNodeStyleGetOverflow), + YGMakeNativeMethod(jni_YGNodeStyleSetOverflow), + YGMakeNativeMethod(jni_YGNodeStyleSetFlex), + YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow), + YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow), + YGMakeNativeMethod(jni_YGNodeStyleGetFlexShrink), + YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink), + YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), + YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis), + YGMakeNativeMethod(jni_YGNodeStyleGetMargin), + YGMakeNativeMethod(jni_YGNodeStyleSetMargin), + YGMakeNativeMethod(jni_YGNodeStyleGetPadding), + YGMakeNativeMethod(jni_YGNodeStyleSetPadding), + YGMakeNativeMethod(jni_YGNodeStyleGetBorder), + YGMakeNativeMethod(jni_YGNodeStyleSetBorder), + YGMakeNativeMethod(jni_YGNodeStyleGetPosition), + YGMakeNativeMethod(jni_YGNodeStyleSetPosition), + YGMakeNativeMethod(jni_YGNodeStyleGetWidth), + YGMakeNativeMethod(jni_YGNodeStyleSetWidth), + YGMakeNativeMethod(jni_YGNodeStyleGetHeight), + YGMakeNativeMethod(jni_YGNodeStyleSetHeight), + YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), + YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth), + YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), + YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight), + YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), + YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth), + YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), + YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight), + YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio), + YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio), + + YGMakeNativeMethod(jni_YGNodeGetInstanceCount), + YGMakeNativeMethod(jni_YGSetLogger), + YGMakeNativeMethod(jni_YGLog), + YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled), + YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled), + }); + }); +} diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index 70eb8ce5..16bc3977 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -18,9 +18,9 @@ public class CSSNodeTest { @Test public void testInit() { - final int refCount = CSSNode.jni_CSSNodeGetInstanceCount(); + final int refCount = CSSNode.jni_YGNodeGetInstanceCount(); final CSSNode node = new CSSNode(); - assertEquals(refCount + 1, CSSNode.jni_CSSNodeGetInstanceCount()); + assertEquals(refCount + 1, CSSNode.jni_YGNodeGetInstanceCount()); } @Test @@ -52,7 +52,7 @@ public class CSSNodeTest { mLogMessage = message; } }); - CSSNode.jni_CSSLog(YogaLogLevel.DEBUG.intValue(), "Hello"); + CSSNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello"); assertEquals(YogaLogLevel.DEBUG, mLogLevel); assertEquals("Hello", mLogMessage); } @@ -68,7 +68,7 @@ public class CSSNodeTest { mLogMessage = message; } }); - CSSNode.jni_CSSLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox"); + CSSNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox"); assertEquals(YogaLogLevel.VERBOSE, mLogLevel); assertEquals("Flexbox", mLogMessage); } diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index 4e5bca75..8e3ce96b 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -9,286 +9,286 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html -#include +#include #include -TEST(CSSLayoutTest, absolute_layout_width_height_start_top) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, absolute_layout_width_height_start_top) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, absolute_layout_width_height_end_bottom) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, absolute_layout_start_top_end_bottom) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetOverflow(root, YGOverflowHidden); - CSSNodeStyleSetWidth(root, 50); - CSSNodeStyleSetHeight(root, 50); +TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetOverflow(root, YGOverflowHidden); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 0); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0_child0, 100); - CSSNodeStyleSetHeight(root_child0_child0, 100); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0_child0, 100); + YGNodeStyleSetHeight(root_child0_child0, 100); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(-50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, absolute_layout_within_border) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetMargin(root, YGEdgeLeft, 10); - CSSNodeStyleSetMargin(root, YGEdgeTop, 10); - CSSNodeStyleSetMargin(root, YGEdgeRight, 10); - CSSNodeStyleSetMargin(root, YGEdgeBottom, 10); - CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); - CSSNodeStyleSetPadding(root, YGEdgeTop, 10); - CSSNodeStyleSetPadding(root, YGEdgeRight, 10); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); - CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); - CSSNodeStyleSetBorder(root, YGEdgeTop, 10); - CSSNodeStyleSetBorder(root, YGEdgeRight, 10); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + 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); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child1, YGEdgeRight, 0); - CSSNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index eb0daa57..30c9b36e 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -9,391 +9,391 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html -#include +#include #include -TEST(CSSLayoutTest, align_content_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_content_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 50); - CSSNodeStyleSetHeight(root_child3, 10); - CSSNodeInsertChild(root, root_child3, 3); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); + YGNodeInsertChild(root, root_child3, 3); - const CSSNodeRef root_child4 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child4, 50); - CSSNodeStyleSetHeight(root_child4, 10); - CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child4 = YGNodeNew(); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_content_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, YGAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_content_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignContent(root, YGAlignFlexEnd); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 50); - CSSNodeStyleSetHeight(root_child3, 10); - CSSNodeInsertChild(root, root_child3, 3); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); + YGNodeInsertChild(root, root_child3, 3); - const CSSNodeRef root_child4 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child4, 50); - CSSNodeStyleSetHeight(root_child4, 10); - CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child4 = YGNodeNew(); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_content_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, YGAlignCenter); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_content_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignContent(root, YGAlignCenter); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 50); - CSSNodeStyleSetHeight(root_child3, 10); - CSSNodeInsertChild(root, root_child3, 3); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 10); + YGNodeInsertChild(root, root_child3, 3); - const CSSNodeRef root_child4 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child4, 50); - CSSNodeStyleSetHeight(root_child4, 10); - CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child4 = YGNodeNew(); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 10); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_content_stretch) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, YGAlignStretch); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_content_stretch) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignContent(root, YGAlignStretch); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 50); - CSSNodeInsertChild(root, root_child3, 3); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeInsertChild(root, root_child3, 3); - const CSSNodeRef root_child4 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child4, 50); - CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child4 = YGNodeNew(); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index 5c8db2c0..1092582c 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -9,151 +9,151 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html -#include +#include #include -TEST(CSSLayoutTest, align_items_stretch) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_items_stretch) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_items_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignCenter); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_items_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignCenter); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_items_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_items_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_items_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_items_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index bc183398..008f30c7 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -9,154 +9,154 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html -#include +#include #include -TEST(CSSLayoutTest, align_self_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_self_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, YGAlignCenter); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_self_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_self_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_self_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_self_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_self_flex_end_override_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAspectRatioTest.cpp b/tests/CSSLayoutAspectRatioTest.cpp index aba09889..5c35aac0 100644 --- a/tests/CSSLayoutAspectRatioTest.cpp +++ b/tests/CSSLayoutAspectRatioTest.cpp @@ -7,401 +7,401 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -static CSSSize _measure(CSSNodeRef node, +static YGSize _measure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - return CSSSize { + return YGSize { .width = widthMode == YGMeasureModeExactly ? width : 50, .height = heightMode == YGMeasureModeExactly ? height : 50, }; } -TEST(CSSLayoutTest, aspect_ratio_cross_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_cross_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_main_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_main_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_both_dimensions_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_both_dimensions_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_align_stretch) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_align_stretch) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_flex_grow) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_flex_grow) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_flex_shrink) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_flex_shrink) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 150); - CSSNodeStyleSetFlexShrink(root_child0, 1); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_basis) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_basis) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_absolute_layout_width_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_with_max_cross_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetMaxWidth(root_child0, 40); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetMaxWidth(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_with_max_main_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetMaxHeight(root_child0, 40); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMaxHeight(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(40, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_with_min_cross_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 30); - CSSNodeStyleSetMinWidth(root_child0, 40); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 30); + YGNodeStyleSetMinWidth(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(30, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_with_min_main_defined) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 30); - CSSNodeStyleSetMinHeight(root_child0, 40); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetMinHeight(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(40, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_double_cross) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_double_cross) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 2); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_half_cross) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_half_cross) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 100); - CSSNodeStyleSetAspectRatio(root_child0, 0.5); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetAspectRatio(root_child0, 0.5); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_double_main) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_double_main) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetAspectRatio(root_child0, 2); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_half_main) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_half_main) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 100); - CSSNodeStyleSetAspectRatio(root_child0, 0.5); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetAspectRatio(root_child0, 0.5); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, aspect_ratio_with_measure_func) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, aspect_ratio_with_measure_func) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeStyleSetAspectRatio(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index 42818c36..e4dc1bc5 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -9,186 +9,186 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html -#include +#include #include -TEST(CSSLayoutTest, border_no_size) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); - CSSNodeStyleSetBorder(root, YGEdgeTop, 10); - CSSNodeStyleSetBorder(root, YGEdgeRight, 10); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); +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); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, border_container_match_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); - CSSNodeStyleSetBorder(root, YGEdgeTop, 10); - CSSNodeStyleSetBorder(root, YGEdgeRight, 10); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, border_flex_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); - CSSNodeStyleSetBorder(root, YGEdgeTop, 10); - CSSNodeStyleSetBorder(root, YGEdgeRight, 10); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, border_stretch_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); - CSSNodeStyleSetBorder(root, YGEdgeTop, 10); - CSSNodeStyleSetBorder(root, YGEdgeRight, 10); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, border_center_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetAlignItems(root, YGAlignCenter); - CSSNodeStyleSetBorder(root, YGEdgeStart, 10); - CSSNodeStyleSetBorder(root, YGEdgeEnd, 20); - CSSNodeStyleSetBorder(root, YGEdgeBottom, 20); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutDefaultValuesTest.cpp b/tests/CSSLayoutDefaultValuesTest.cpp index 534607f2..8bb086b0 100644 --- a/tests/CSSLayoutDefaultValuesTest.cpp +++ b/tests/CSSLayoutDefaultValuesTest.cpp @@ -7,70 +7,70 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -TEST(CSSLayoutTest, assert_default_values) { - const CSSNodeRef root = CSSNodeNew(); +TEST(YogaTest, assert_default_values) { + const YGNodeRef root = YGNodeNew(); - ASSERT_EQ(0, CSSNodeChildCount(root)); - ASSERT_EQ(NULL, CSSNodeGetChild(root, 1)); + ASSERT_EQ(0, YGNodeChildCount(root)); + ASSERT_EQ(NULL, YGNodeGetChild(root, 1)); - ASSERT_EQ(YGDirectionInherit, CSSNodeStyleGetDirection(root)); - ASSERT_EQ(YGFlexDirectionColumn, CSSNodeStyleGetFlexDirection(root)); - ASSERT_EQ(YGJustifyFlexStart, CSSNodeStyleGetJustifyContent(root)); - ASSERT_EQ(YGAlignFlexStart, CSSNodeStyleGetAlignContent(root)); - ASSERT_EQ(YGAlignStretch, CSSNodeStyleGetAlignItems(root)); - ASSERT_EQ(YGAlignAuto, CSSNodeStyleGetAlignSelf(root)); - ASSERT_EQ(YGPositionTypeRelative, CSSNodeStyleGetPositionType(root)); - ASSERT_EQ(YGWrapNoWrap, CSSNodeStyleGetFlexWrap(root)); - ASSERT_EQ(YGOverflowVisible, CSSNodeStyleGetOverflow(root)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexGrow(root)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexShrink(root)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(root))); + ASSERT_EQ(YGDirectionInherit, YGNodeStyleGetDirection(root)); + ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(root)); + ASSERT_EQ(YGJustifyFlexStart, YGNodeStyleGetJustifyContent(root)); + ASSERT_EQ(YGAlignFlexStart, YGNodeStyleGetAlignContent(root)); + ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignItems(root)); + ASSERT_EQ(YGAlignAuto, YGNodeStyleGetAlignSelf(root)); + ASSERT_EQ(YGPositionTypeRelative, YGNodeStyleGetPositionType(root)); + ASSERT_EQ(YGWrapNoWrap, YGNodeStyleGetFlexWrap(root)); + ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); + ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetFlexBasis(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeLeft))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeTop))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeRight))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeBottom))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeEnd))); + 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_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, YGEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(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_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, YGEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(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_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, YGEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(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(CSSValueIsUndefined(CSSNodeStyleGetWidth(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetHeight(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMinWidth(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMinHeight(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxWidth(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(root))); + 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_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetRight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetBottom(root)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetWidth(root))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetHeight(root))); - ASSERT_EQ(YGDirectionInherit, CSSNodeLayoutGetDirection(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_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/CSSLayoutDirtyMarkingTest.cpp index 5177bfab..4682e534 100644 --- a/tests/CSSLayoutDirtyMarkingTest.cpp +++ b/tests/CSSLayoutDirtyMarkingTest.cpp @@ -7,90 +7,90 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -TEST(CSSLayoutTest, dirty_propagation) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, dirty_propagation) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 20); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetWidth(root_child0, 20); - EXPECT_TRUE(CSSNodeIsDirty(root_child0)); - EXPECT_FALSE(CSSNodeIsDirty(root_child1)); - EXPECT_TRUE(CSSNodeIsDirty(root)); + EXPECT_TRUE(YGNodeIsDirty(root_child0)); + EXPECT_FALSE(YGNodeIsDirty(root_child1)); + EXPECT_TRUE(YGNodeIsDirty(root)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - EXPECT_FALSE(CSSNodeIsDirty(root_child0)); - EXPECT_FALSE(CSSNodeIsDirty(root_child1)); - EXPECT_FALSE(CSSNodeIsDirty(root)); + EXPECT_FALSE(YGNodeIsDirty(root_child0)); + EXPECT_FALSE(YGNodeIsDirty(root_child1)); + EXPECT_FALSE(YGNodeIsDirty(root)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, dirty_propagation_only_if_prop_changed) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 20); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - CSSNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetWidth(root_child0, 50); - EXPECT_FALSE(CSSNodeIsDirty(root_child0)); - EXPECT_FALSE(CSSNodeIsDirty(root_child1)); - EXPECT_FALSE(CSSNodeIsDirty(root)); + EXPECT_FALSE(YGNodeIsDirty(root_child0)); + EXPECT_FALSE(YGNodeIsDirty(root_child1)); + EXPECT_FALSE(YGNodeIsDirty(root)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 50); - CSSNodeStyleSetHeight(root, 50); +TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); - const CSSNodeRef child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(child0, 50); - CSSNodeStyleSetHeight(child0, 25); - CSSNodeInsertChild(root, child0, 0); + const YGNodeRef child0 = YGNodeNew(); + YGNodeStyleSetWidth(child0, 50); + YGNodeStyleSetHeight(child0, 25); + YGNodeInsertChild(root, child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - const CSSNodeRef child1 = CSSNodeNew(); - CSSNodeRemoveChild(root, child1); - EXPECT_FALSE(CSSNodeIsDirty(root)); - CSSNodeFree(child1); + const YGNodeRef child1 = YGNodeNew(); + YGNodeRemoveChild(root, child1); + EXPECT_FALSE(YGNodeIsDirty(root)); + YGNodeFree(child1); - CSSNodeRemoveChild(root, child0); - EXPECT_TRUE(CSSNodeIsDirty(root)); - CSSNodeFree(child0); + YGNodeRemoveChild(root, child0); + EXPECT_TRUE(YGNodeIsDirty(root)); + YGNodeFree(child0); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutEdgeTest.cpp b/tests/CSSLayoutEdgeTest.cpp index 00d952fa..46a676f3 100644 --- a/tests/CSSLayoutEdgeTest.cpp +++ b/tests/CSSLayoutEdgeTest.cpp @@ -7,157 +7,157 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -TEST(CSSLayoutTest, start_overrides) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, start_overrides) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); - CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, end_overrides) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, end_overrides) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); - CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, horizontal_overridden) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, horizontal_overridden) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, vertical_overridden) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, vertical_overridden) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, horizontal_overrides_all) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, horizontal_overrides_all) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetBottom(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetBottom(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, vertical_overrides_all) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, vertical_overrides_all) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, all_overridden) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, all_overridden) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); - CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20); - CSSNodeInsertChild(root, root_child0, 0); + 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); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index 48ac2724..786073a9 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -9,385 +9,385 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html -#include +#include #include -TEST(CSSLayoutTest, flex_direction_column_no_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); +TEST(YogaTest, flex_direction_column_no_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_direction_row_no_width) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_direction_row_no_width) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_direction_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_direction_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_direction_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_direction_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_direction_column_reverse) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_direction_column_reverse) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_direction_row_reverse) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_direction_row_reverse) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index b31af0f6..5035a049 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -9,389 +9,389 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html -#include +#include #include -TEST(CSSLayoutTest, flex_basis_flex_grow_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_basis_flex_grow_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_basis_flex_grow_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_basis_flex_grow_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_basis_flex_shrink_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexShrink(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexBasis(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexBasis(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_basis_flex_shrink_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexShrink(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexBasis(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexBasis(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_shrink_to_zero) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetHeight(root, 75); +TEST(YogaTest, flex_shrink_to_zero) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetHeight(root, 75); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexShrink(root_child1, 1); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child1, 1); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeStyleSetHeight(root_child2, 50); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_basis_overrides_main_size) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_basis_overrides_main_size) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_grow_shrink_at_most) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_grow_shrink_at_most) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child0, 1); - CSSNodeStyleSetFlexShrink(root_child0_child0, 1); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0_child0, 1); + YGNodeStyleSetFlexShrink(root_child0_child0, 1); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index d4be92b5..0be05d5c 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -9,334 +9,334 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html -#include +#include #include -TEST(CSSLayoutTest, wrap_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, wrap_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 30); - CSSNodeStyleSetHeight(root_child0, 30); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 30); - CSSNodeStyleSetHeight(root_child1, 30); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 30); - CSSNodeStyleSetHeight(root_child2, 30); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 30); - CSSNodeStyleSetHeight(root_child3, 30); - CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, wrap_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); +TEST(YogaTest, wrap_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 30); - CSSNodeStyleSetHeight(root_child0, 30); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 30); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 30); - CSSNodeStyleSetHeight(root_child1, 30); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 30); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 30); - CSSNodeStyleSetHeight(root_child2, 30); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 30); - CSSNodeStyleSetHeight(root_child3, 30); - CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); +TEST(YogaTest, wrap_row_align_items_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 30); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 30); - CSSNodeStyleSetHeight(root_child1, 20); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 30); - CSSNodeStyleSetHeight(root_child2, 30); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 30); - CSSNodeStyleSetHeight(root_child3, 30); - CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, wrap_row_align_items_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, YGAlignCenter); - CSSNodeStyleSetFlexWrap(root, YGWrapWrap); - CSSNodeStyleSetWidth(root, 100); +TEST(YogaTest, wrap_row_align_items_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignCenter); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 30); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 30); - CSSNodeStyleSetHeight(root_child1, 20); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 30); - CSSNodeStyleSetHeight(root_child2, 30); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 30); + YGNodeStyleSetHeight(root_child2, 30); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child3, 30); - CSSNodeStyleSetHeight(root_child3, 30); - CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetWidth(root_child3, 30); + YGNodeStyleSetHeight(root_child3, 30); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(5, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(5, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index 9903c437..5a60b8c3 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -9,647 +9,647 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html -#include +#include #include -TEST(CSSLayoutTest, justify_content_row_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_row_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(82, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(72, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_row_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_row_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(72, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(82, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_row_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_row_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(36, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(56, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(56, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(36, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_row_space_between) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_row_space_between) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_row_space_around) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_row_space_around) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_column_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_column_flex_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_column_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_column_flex_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(72, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(82, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(72, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(82, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_column_center) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_column_center) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(36, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(56, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(36, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(56, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_column_space_between) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_column_space_between) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_column_space_around) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifySpaceAround); - CSSNodeStyleSetWidth(root, 102); - CSSNodeStyleSetHeight(root, 102); +TEST(YogaTest, justify_content_column_space_around) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index a10aa362..5d09ebdd 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -9,398 +9,398 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html -#include +#include #include -TEST(CSSLayoutTest, margin_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_start) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_top) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_top) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_bottom) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_bottom) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_and_flex_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_and_flex_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_and_flex_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_and_flex_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_and_stretch_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_and_stretch_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_and_stretch_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_and_stretch_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_with_sibling_row) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_with_sibling_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, margin_with_sibling_column) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, margin_with_sibling_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index 9a9674a0..2a4f4482 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -7,127 +7,127 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -static CSSSize _measureMax(CSSNodeRef node, +static YGSize _measureMax(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - int *measureCount = (int *)CSSNodeGetContext(node); + int *measureCount = (int *)YGNodeGetContext(node); (*measureCount)++; - return CSSSize { + return YGSize { .width = widthMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : height, }; } -static CSSSize _measureMin(CSSNodeRef node, +static YGSize _measureMin(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - int *measureCount = (int *)CSSNodeGetContext(node); + int *measureCount = (int *)YGNodeGetContext(node); *measureCount = *measureCount + 1; - return CSSSize { + return YGSize { .width = widthMode == YGMeasureModeUndefined || (widthMode == YGMeasureModeAtMost && width > 10) ? 10 : width, .height = heightMode == YGMeasureModeUndefined || (heightMode == YGMeasureModeAtMost && height > 10) ? 10 : height, }; } -TEST(CSSLayoutTest, measure_once_single_flexible_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, measure_once_single_flexible_child) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMax); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measureMax); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, remeasure_with_same_exact_width_larger_than_needed_height) { - const CSSNodeRef root = CSSNodeNew(); +TEST(YogaTest, remeasure_with_same_exact_width_larger_than_needed_height) { + const YGNodeRef root = YGNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMin); - CSSNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measureMin); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); - CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, remeasure_with_same_atmost_width_larger_than_needed_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); +TEST(YogaTest, remeasure_with_same_atmost_width_larger_than_needed_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - const CSSNodeRef root_child0 = CSSNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMin); - CSSNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measureMin); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); - CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, remeasure_with_computed_width_larger_than_needed_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); +TEST(YogaTest, remeasure_with_computed_width_larger_than_needed_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - const CSSNodeRef root_child0 = CSSNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMin); - CSSNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measureMin); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); - CSSNodeStyleSetAlignItems(root, YGAlignStretch); - CSSNodeCalculateLayout(root, 10, 50, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + YGNodeStyleSetAlignItems(root, YGAlignStretch); + YGNodeCalculateLayout(root, 10, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, remeasure_with_atmost_computed_width_undefined_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); +TEST(YogaTest, remeasure_with_atmost_computed_width_undefined_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); - const CSSNodeRef root_child0 = CSSNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMin); - CSSNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measureMin); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); - CSSNodeCalculateLayout(root, 10, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, 10, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/CSSLayoutMeasureModeTest.cpp index df86878c..358327ff 100644 --- a/tests/CSSLayoutMeasureModeTest.cpp +++ b/tests/CSSLayoutMeasureModeTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include struct _MeasureConstraint { @@ -22,12 +22,12 @@ struct _MeasureConstraintList { struct _MeasureConstraint *constraints; }; -static CSSSize _measure(CSSNodeRef node, +static YGSize _measure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)CSSNodeGetContext(node); + struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)YGNodeGetContext(node); struct _MeasureConstraint *constraints = constraintList->constraints; uint32_t currentIndex = constraintList->length; (&constraints[currentIndex])->width = width; @@ -36,28 +36,28 @@ static CSSSize _measure(CSSNodeRef node, (&constraints[currentIndex])->heightMode = heightMode; constraintList->length = currentIndex + 1; - return CSSSize { + return YGSize { .width = widthMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : width, }; } -TEST(CSSLayoutTest, exactly_measure_stretched_child_column) { +TEST(YogaTest, exactly_measure_stretched_child_column) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -65,26 +65,26 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_column) { ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].widthMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, exactly_measure_stretched_child_row) { +TEST(YogaTest, exactly_measure_stretched_child_row) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -92,25 +92,25 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) { ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, at_most_main_axis_column) { +TEST(YogaTest, at_most_main_axis_column) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -118,26 +118,26 @@ TEST(CSSLayoutTest, at_most_main_axis_column) { ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, at_most_cross_axis_column) { +TEST(YogaTest, at_most_cross_axis_column) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -145,26 +145,26 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) { ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, at_most_main_axis_row) { +TEST(YogaTest, at_most_main_axis_row) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -172,27 +172,27 @@ TEST(CSSLayoutTest, at_most_main_axis_row) { ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, at_most_cross_axis_row) { +TEST(YogaTest, at_most_cross_axis_row) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -200,25 +200,25 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) { ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_child) { +TEST(YogaTest, flex_child) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(2, constraintList.length); @@ -229,26 +229,26 @@ TEST(CSSLayoutTest, flex_child) { ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[1].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_child_with_flex_basis) { +TEST(YogaTest, flex_child_with_flex_basis) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 0); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 0); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); @@ -256,68 +256,68 @@ TEST(CSSLayoutTest, flex_child_with_flex_basis) { ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, overflow_scroll_column) { +TEST(YogaTest, overflow_scroll_column) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetOverflow(root, YGOverflowScroll); - CSSNodeStyleSetHeight(root, 100); - CSSNodeStyleSetWidth(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetOverflow(root, YGOverflowScroll); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); - ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].height)); + ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].height)); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, overflow_scroll_row) { +TEST(YogaTest, overflow_scroll_row) { struct _MeasureConstraintList constraintList = _MeasureConstraintList { .length = 0, .constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)), }; - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetOverflow(root, YGOverflowScroll); - CSSNodeStyleSetHeight(root, 100); - CSSNodeStyleSetWidth(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetOverflow(root, YGOverflowScroll); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetWidth(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &constraintList); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &constraintList); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); - ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].width)); + ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].width)); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index 4e84df94..0f12a06a 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -7,73 +7,73 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -static CSSSize _measure(CSSNodeRef node, +static YGSize _measure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - int *measureCount = (int*) CSSNodeGetContext(node); + int *measureCount = (int*) YGNodeGetContext(node); if (measureCount) { (*measureCount)++; } - return CSSSize { + return YGSize { .width = 10, .height = 10, }; } -TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, dont_measure_single_grow_shrink_child) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); int measureCount = 0; - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measure); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexShrink(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetContext(root_child0, &measureCount); + YGNodeSetMeasureFunc(root_child0, _measure); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, measureCount); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } #if GTEST_HAS_DEATH_TEST -TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeSetMeasureFunc(root, _measure); +TEST(YogaTest, cannot_add_child_to_node_with_measure_func) { + const YGNodeRef root = YGNodeNew(); + YGNodeSetMeasureFunc(root, _measure); - const CSSNodeRef root_child0 = CSSNodeNew(); - ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*"); - CSSNodeFree(root_child0); - CSSNodeFreeRecursive(root); + const YGNodeRef root_child0 = YGNodeNew(); + ASSERT_DEATH(YGNodeInsertChild(root, root_child0, 0), "Cannot add child.*"); + YGNodeFree(root_child0); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, cannot_add_nonnull_measure_func_to_non_leaf_node) { - const CSSNodeRef root = CSSNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeInsertChild(root, root_child0, 0); +TEST(YogaTest, cannot_add_nonnull_measure_func_to_non_leaf_node) { + const YGNodeRef root = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeInsertChild(root, root_child0, 0); - ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*"); - CSSNodeFreeRecursive(root); + ASSERT_DEATH(YGNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*"); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, can_nullify_measure_func_on_any_node) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeInsertChild(root, CSSNodeNew(), 0); +TEST(YogaTest, can_nullify_measure_func_on_any_node) { + const YGNodeRef root = YGNodeNew(); + YGNodeInsertChild(root, YGNodeNew(), 0); - CSSNodeSetMeasureFunc(root, NULL); - ASSERT_TRUE(CSSNodeGetMeasureFunc(root) == NULL); - CSSNodeFreeRecursive(root); + YGNodeSetMeasureFunc(root, NULL); + ASSERT_TRUE(YGNodeGetMeasureFunc(root) == NULL); + YGNodeFreeRecursive(root); } #endif diff --git a/tests/CSSLayoutMemoryFuncTest.cpp b/tests/CSSLayoutMemoryFuncTest.cpp index fa1e3901..cc0681d7 100644 --- a/tests/CSSLayoutMemoryFuncTest.cpp +++ b/tests/CSSLayoutMemoryFuncTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include extern int32_t gNodeInstanceCount; @@ -37,41 +37,41 @@ static void testFree(void *ptr) { free(ptr); } -TEST(CSSLayoutTest, memory_func_default) { - gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test - CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL); - const CSSNodeRef root = CSSNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeFreeRecursive(root); +TEST(YogaTest, memory_func_default) { + gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test + YGSetMemoryFuncs(NULL, NULL, NULL, NULL); + const YGNodeRef root = YGNodeNew(); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeInsertChild(root, root_child0, 0); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, memory_func_test_funcs) { - gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test - CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree); - const CSSNodeRef root = CSSNodeNew(); +TEST(YogaTest, memory_func_test_funcs) { + gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test + YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree); + const YGNodeRef root = YGNodeNew(); for (int i = 0; i < 10; i++) { - const CSSNodeRef child = CSSNodeNew(); - CSSNodeInsertChild(root, child, 0); + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, 0); } - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); ASSERT_NE(testMallocCount, 0); ASSERT_NE(testCallocCount, 0); ASSERT_NE(testReallocCount, 0); ASSERT_NE(testFreeCount, 0); - CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL); + YGSetMemoryFuncs(NULL, NULL, NULL, NULL); } #if GTEST_HAS_DEATH_TEST -TEST(CSSLayoutTest, memory_func_assert_zero_nodes) { - gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test - const CSSNodeRef root = CSSNodeNew(); - ASSERT_DEATH(CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first"); - CSSNodeFreeRecursive(root); +TEST(YogaTest, memory_func_assert_zero_nodes) { + gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test + const YGNodeRef root = YGNodeNew(); + ASSERT_DEATH(YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first"); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, memory_func_assert_all_non_null) { - gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test - ASSERT_DEATH(CSSLayoutSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL"); +TEST(YogaTest, memory_func_assert_all_non_null) { + gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test + ASSERT_DEATH(YGSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL"); } #endif diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index 3683464f..bd5a7dd8 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -9,424 +9,424 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html -#include +#include #include -TEST(CSSLayoutTest, max_width) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, max_width) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMaxWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, max_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, max_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetMaxHeight(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetMaxHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, min_height) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, min_height) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMinHeight(root_child0, 60); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMinHeight(root_child0, 60); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, min_width) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, min_width) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMinWidth(root_child0, 60); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetMinWidth(root_child0, 60); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_min_max) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetMinHeight(root, 100); - CSSNodeStyleSetMaxHeight(root, 200); +TEST(YogaTest, justify_content_min_max) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 200); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 60); - CSSNodeStyleSetHeight(root_child0, 60); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, align_items_min_max) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, YGAlignCenter); - CSSNodeStyleSetMinWidth(root, 100); - CSSNodeStyleSetMaxWidth(root, 200); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, align_items_min_max) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignCenter); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetMaxWidth(root, 200); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 60); - CSSNodeStyleSetHeight(root_child0, 60); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, justify_content_overflow_min_max) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetMinHeight(root, 100); - CSSNodeStyleSetMaxHeight(root, 110); +TEST(YogaTest, justify_content_overflow_min_max) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetMinHeight(root, 100); + YGNodeStyleSetMaxHeight(root, 110); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 50); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child1, 50); - CSSNodeStyleSetHeight(root_child1, 50); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child2, 50); - CSSNodeStyleSetHeight(root_child2, 50); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(110, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(-20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(110, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(-20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_grow_within_max_width) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 200); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_grow_within_max_width) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - CSSNodeStyleSetMaxWidth(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); + YGNodeStyleSetMaxWidth(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child0, 1); - CSSNodeStyleSetHeight(root_child0_child0, 20); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0_child0, 1); + YGNodeStyleSetHeight(root_child0_child0, 20); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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(100, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 200); - CSSNodeStyleSetHeight(root, 100); +TEST(YogaTest, flex_grow_within_constrained_max_width) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); - CSSNodeStyleSetMaxWidth(root_child0, 300); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); + YGNodeStyleSetMaxWidth(root_child0, 300); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child0, 1); - CSSNodeStyleSetHeight(root_child0_child0, 20); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0_child0, 1); + YGNodeStyleSetHeight(root_child0_child0, 20); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 2b9fae89..d5aa6820 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -9,228 +9,228 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html -#include +#include #include -TEST(CSSLayoutTest, padding_no_size) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); - CSSNodeStyleSetPadding(root, YGEdgeTop, 10); - CSSNodeStyleSetPadding(root, YGEdgeRight, 10); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); +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); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, padding_container_match_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); - CSSNodeStyleSetPadding(root, YGEdgeTop, 10); - CSSNodeStyleSetPadding(root, YGEdgeRight, 10); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, padding_flex_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); - CSSNodeStyleSetPadding(root, YGEdgeTop, 10); - CSSNodeStyleSetPadding(root, YGEdgeRight, 10); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, padding_stretch_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); - CSSNodeStyleSetPadding(root, YGEdgeTop, 10); - CSSNodeStyleSetPadding(root, YGEdgeRight, 10); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, padding_center_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); - CSSNodeStyleSetAlignItems(root, YGAlignCenter); - CSSNodeStyleSetPadding(root, YGEdgeStart, 10); - CSSNodeStyleSetPadding(root, YGEdgeEnd, 20); - CSSNodeStyleSetPadding(root, YGEdgeBottom, 20); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); +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); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } -TEST(CSSLayoutTest, child_with_padding_align_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); - CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); - CSSNodeStyleSetWidth(root, 200); - CSSNodeStyleSetHeight(root, 200); +TEST(YogaTest, child_with_padding_align_end) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + YGNodeStyleSetAlignItems(root, YGAlignFlexEnd); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); - CSSNodeStyleSetPadding(root_child0, YGEdgeTop, 20); - CSSNodeStyleSetPadding(root_child0, YGEdgeRight, 20); - CSSNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); - CSSNodeStyleSetWidth(root_child0, 100); - CSSNodeStyleSetHeight(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + 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); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetHeight(root)); + 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(100, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetHeight(root)); + 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, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp index 6028ed22..01cf4950 100644 --- a/tests/CSSLayoutRelayoutTest.cpp +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -7,25 +7,25 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); +TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeStyleSetFlexBasis(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeStyleSetFlexBasis(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); - CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR); - ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false); } diff --git a/tests/CSSLayoutRoundingMeasureFuncTest.cpp b/tests/CSSLayoutRoundingMeasureFuncTest.cpp index afd8deb5..d6f5f6d4 100644 --- a/tests/CSSLayoutRoundingMeasureFuncTest.cpp +++ b/tests/CSSLayoutRoundingMeasureFuncTest.cpp @@ -7,67 +7,67 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -static CSSSize _measureFloor(CSSNodeRef node, +static YGSize _measureFloor(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - return CSSSize{ + return YGSize{ width = 10.2, height = 10.2, }; } -static CSSSize _measureCeil(CSSNodeRef node, +static YGSize _measureCeil(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode) { - return CSSSize{ + return YGSize{ width = 10.5, height = 10.5, }; } -TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetMeasureFunc(root_child0, _measureFloor); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetMeasureFunc(root_child0, _measureFloor); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); + const YGNodeRef root = YGNodeNew(); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetMeasureFunc(root_child0, _measureCeil); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeSetMeasureFunc(root_child0, _measureCeil); + YGNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } diff --git a/tests/CSSLayoutRoundingTest.cpp b/tests/CSSLayoutRoundingTest.cpp index 635370da..9a14ea26 100644 --- a/tests/CSSLayoutRoundingTest.cpp +++ b/tests/CSSLayoutRoundingTest.cpp @@ -9,771 +9,771 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html -#include +#include #include -TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(34, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(34, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(67, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(67, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(67, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(67, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(34, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(34, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_flex_basis_flex_grow_row_prime_number_width) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 113); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 113); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeInsertChild(root, root_child2, 2); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeInsertChild(root, root_child2, 2); - const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child3, 1); - CSSNodeInsertChild(root, root_child3, 3); + const YGNodeRef root_child3 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child3, 1); + YGNodeInsertChild(root, root_child3, 3); - const CSSNodeRef root_child4 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child4, 1); - CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child4 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child4, 1); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(22, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(68, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(22, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(68, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(22, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_FLOAT_EQ(22, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child3)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(23, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_flex_basis_flex_shrink_row) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); - CSSNodeStyleSetWidth(root, 101); - CSSNodeStyleSetHeight(root, 100); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 101); + YGNodeStyleSetHeight(root, 100); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexShrink(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexBasis(root_child1, 25); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexBasis(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexBasis(root_child2, 25); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexBasis(root_child2, 25); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(101, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(101, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(51, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(51, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(51, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(51, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(76, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(76, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(101, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(101, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(51, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(51, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_flex_basis_overrides_main_size) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 113); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_total_fractial) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_total_fractial) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 87.4f); - CSSNodeStyleSetHeight(root, 113.4f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 0.7f); - CSSNodeStyleSetFlexBasis(root_child0, 50.3f); - CSSNodeStyleSetHeight(root_child0, 20.3f); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 0.7f); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1.6f); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1.6f); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1.1f); - CSSNodeStyleSetHeight(root_child2, 10.7f); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1.1f); + YGNodeStyleSetHeight(root_child2, 10.7f); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_total_fractial_nested) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_total_fractial_nested) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 87.4f); - CSSNodeStyleSetHeight(root, 113.4f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 87.4f); + YGNodeStyleSetHeight(root, 113.4f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 0.7f); - CSSNodeStyleSetFlexBasis(root_child0, 50.3f); - CSSNodeStyleSetHeight(root_child0, 20.3f); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 0.7f); + YGNodeStyleSetFlexBasis(root_child0, 50.3f); + YGNodeStyleSetHeight(root_child0, 20.3f); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f); - CSSNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); - CSSNodeStyleSetHeight(root_child0_child0, 9.9f); - CSSNodeInsertChild(root_child0, root_child0_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); + YGNodeInsertChild(root_child0, root_child0_child0, 0); - const CSSNodeRef root_child0_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child1, 4); - CSSNodeStyleSetFlexBasis(root_child0_child1, 0.3f); - CSSNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); - CSSNodeStyleSetHeight(root_child0_child1, 1.1f); - CSSNodeInsertChild(root_child0, root_child0_child1, 1); + 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); + YGNodeInsertChild(root_child0, root_child0_child1, 1); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1.6f); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1.6f); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1.1f); - CSSNodeStyleSetHeight(root_child2, 10.7f); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1.1f); + YGNodeStyleSetHeight(root_child2, 10.7f); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-13, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetHeight(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(47, CSSNodeLayoutGetHeight(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(47, YGNodeLayoutGetHeight(root_child0_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetHeight(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-13, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetHeight(root_child0_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(47, CSSNodeLayoutGetHeight(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(47, YGNodeLayoutGetHeight(root_child0_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(59, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_fractial_input_1) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_fractial_input_1) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 113.4f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_fractial_input_2) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_fractial_input_2) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 113.6f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.6f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(114, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(114, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(65, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(65, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(114, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(114, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(65, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(65, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_fractial_input_3) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_fractial_input_3) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPosition(root, YGEdgeTop, 0.3f); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 113.4f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(114, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(114, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(114, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(114, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } -TEST(CSSLayoutTest, rounding_fractial_input_4) { - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); +TEST(YogaTest, rounding_fractial_input_4) { + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPosition(root, YGEdgeTop, 0.7f); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 113.4f); + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 113.4f); - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetFlexBasis(root_child0, 50); - CSSNodeStyleSetHeight(root_child0, 20); - CSSNodeInsertChild(root, root_child0, 0); + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); - const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(root, root_child1, 1); + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); - const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1); - CSSNodeStyleSetHeight(root_child2, 10); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + const YGNodeRef root_child2 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child2, 1); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(1, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(1, CSSNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetHeight(root_child0)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(64, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root_child2)); - CSSNodeFreeRecursive(root); + YGNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } diff --git a/tests/CSSLayoutStyleTest.cpp b/tests/CSSLayoutStyleTest.cpp index fe2a7827..863cf52b 100644 --- a/tests/CSSLayoutStyleTest.cpp +++ b/tests/CSSLayoutStyleTest.cpp @@ -7,54 +7,54 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include -TEST(CSSLayoutTest, copy_style_same) { - const CSSNodeRef node0 = CSSNodeNew(); - const CSSNodeRef node1 = CSSNodeNew(); - ASSERT_FALSE(CSSNodeIsDirty(node0)); +TEST(YogaTest, copy_style_same) { + const YGNodeRef node0 = YGNodeNew(); + const YGNodeRef node1 = YGNodeNew(); + ASSERT_FALSE(YGNodeIsDirty(node0)); - CSSNodeCopyStyle(node0, node1); - ASSERT_FALSE(CSSNodeIsDirty(node0)); + YGNodeCopyStyle(node0, node1); + ASSERT_FALSE(YGNodeIsDirty(node0)); - CSSNodeFree(node0); - CSSNodeFree(node1); + YGNodeFree(node0); + YGNodeFree(node1); } -TEST(CSSLayoutTest, copy_style_modified) { - const CSSNodeRef node0 = CSSNodeNew(); - ASSERT_FALSE(CSSNodeIsDirty(node0)); - ASSERT_EQ(YGFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0))); +TEST(YogaTest, copy_style_modified) { + const YGNodeRef node0 = YGNodeNew(); + ASSERT_FALSE(YGNodeIsDirty(node0)); + ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); + ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(node0))); - const CSSNodeRef node1 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - CSSNodeStyleSetMaxHeight(node1, 10); + const YGNodeRef node1 = YGNodeNew(); + YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); + YGNodeStyleSetMaxHeight(node1, 10); - CSSNodeCopyStyle(node0, node1); - ASSERT_TRUE(CSSNodeIsDirty(node0)); - ASSERT_EQ(YGFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0)); - ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0)); + YGNodeCopyStyle(node0, node1); + ASSERT_TRUE(YGNodeIsDirty(node0)); + ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0)); + ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0)); - CSSNodeFree(node0); - CSSNodeFree(node1); + YGNodeFree(node0); + YGNodeFree(node1); } -TEST(CSSLayoutTest, copy_style_modified_same) { - const CSSNodeRef node0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node0, YGFlexDirectionRow); - CSSNodeStyleSetMaxHeight(node0, 10); - CSSNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR); - ASSERT_FALSE(CSSNodeIsDirty(node0)); +TEST(YogaTest, copy_style_modified_same) { + const YGNodeRef node0 = YGNodeNew(); + YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow); + YGNodeStyleSetMaxHeight(node0, 10); + YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FALSE(YGNodeIsDirty(node0)); - const CSSNodeRef node1 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); - CSSNodeStyleSetMaxHeight(node1, 10); + const YGNodeRef node1 = YGNodeNew(); + YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); + YGNodeStyleSetMaxHeight(node1, 10); - CSSNodeCopyStyle(node0, node1); - ASSERT_FALSE(CSSNodeIsDirty(node0)); + YGNodeCopyStyle(node0, node1); + ASSERT_FALSE(YGNodeIsDirty(node0)); - CSSNodeFree(node0); - CSSNodeFree(node1); + YGNodeFree(node0); + YGNodeFree(node1); }