From b938017ccf900489339a1aeb61180d57394ccd82 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Thu, 3 Nov 2016 13:00:02 -0700 Subject: [PATCH 001/108] Add Sizing API that doesn't change view's frame. Summary: This exposes an API so people can find out the resulting size of a layout calculation without changing the frame of the view. Reviewed By: emilsjolander Differential Revision: D4124630 fbshipit-source-id: f2b28d8a5474857cb1c92e021a1f161806826cda --- uikit/CSSLayout/Tests/CSSLayoutTests.m | 20 ++++++++++++++++++++ uikit/CSSLayout/UIView+CSSLayout.h | 5 ++++- uikit/CSSLayout/UIView+CSSLayout.m | 23 ++++++++++++++++------- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/uikit/CSSLayout/Tests/CSSLayoutTests.m b/uikit/CSSLayout/Tests/CSSLayoutTests.m index cd1e775a..1dfc5339 100644 --- a/uikit/CSSLayout/Tests/CSSLayoutTests.m +++ b/uikit/CSSLayout/Tests/CSSLayoutTests.m @@ -58,4 +58,24 @@ XCTAssertFalse([view css_usesFlexbox]); } +- (void)testSizeThatFitsAsserts +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + XCTAssertThrows([view css_sizeThatFits:CGSizeZero]); + + dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){ + XCTAssertThrows([view css_sizeThatFits:CGSizeZero]); + }); +} + +- (void)testSizeThatFitsSmoke +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + [view css_setUsesFlexbox:YES]; + + const CGSize constrainedSize = CGSizeMake(50, 50); + const CGSize actualSize = [view css_sizeThatFits:constrainedSize]; + XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize)); +} + @end diff --git a/uikit/CSSLayout/UIView+CSSLayout.h b/uikit/CSSLayout/UIView+CSSLayout.h index e17948b5..17bd97ca 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.h +++ b/uikit/CSSLayout/UIView+CSSLayout.h @@ -45,7 +45,10 @@ // Get the resolved direction of this node. This won't be CSSDirectionInherit - (CSSDirection)css_resolvedDirection; -// Perform a layout calculation and update the frames of the views in the hierarchy with th results +//! @abstract Perform a layout calculation and update the frames of the views in the hierarchy with th results - (void)css_applyLayout; +//! @abstract Compute the size of a layout with a constrained size. +- (CGSize)css_sizeThatFits:(CGSize)constrainedSize; + @end diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index 9a8eb645..1bc408d2 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -180,20 +180,29 @@ return CSSNodeLayoutGetDirection([self cssNode]); } -- (void)css_applyLayout +- (CGSize)css_sizeThatFits:(CGSize)constrainedSize { - NSAssert([NSThread isMainThread], @"Method called using a thread other than main!"); - NSAssert([self css_usesFlexbox], @"css_applyLayout must be called on a node using css styling!"); + NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); + NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); _attachNodesRecursive(self); - CSSNodeRef node = [self cssNode]; + const CSSNodeRef node = [self cssNode]; CSSNodeCalculateLayout( - [self cssNode], - CSSNodeStyleGetWidth(node), - CSSNodeStyleGetHeight(node), + node, + constrainedSize.width, + constrainedSize.height, CSSNodeStyleGetDirection(node)); + return (CGSize) { + .width = CSSNodeLayoutGetWidth(node), + .height = CSSNodeLayoutGetHeight(node), + }; +} + +- (void)css_applyLayout +{ + [self css_sizeThatFits:self.bounds.size]; _updateFrameRecursive(self); } From e00e30ca150b3212457bac3e4efd9e22383001ad Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Thu, 3 Nov 2016 13:30:34 -0700 Subject: [PATCH 002/108] Only mark Nodes dirty if an actual node is removed. Summary: Currently, when we try to remove a child from a node, that node is mark dirty //regardless of whether or not anything was actually removed//. This fixes it. Reviewed By: gkassabli Differential Revision: D4125453 fbshipit-source-id: 745cfc55269415fea106a80c72401eb3074f2d31 --- CSSLayout/CSSLayout.c | 7 ++++--- tests/CSSLayoutDirtyMarkingTest.cpp | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index dadaab50..dd63fb25 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -263,9 +263,10 @@ void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uin } void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child) { - CSSNodeListDelete(node->children, child); - child->parent = NULL; - _CSSNodeMarkDirty(node); + if (CSSNodeListDelete(node->children, child) != NULL) { + child->parent = NULL; + _CSSNodeMarkDirty(node); + } } CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index) { diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/CSSLayoutDirtyMarkingTest.cpp index 50d86c7c..7bafe352 100644 --- a/tests/CSSLayoutDirtyMarkingTest.cpp +++ b/tests/CSSLayoutDirtyMarkingTest.cpp @@ -69,3 +69,25 @@ TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) { CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 50); + CSSNodeStyleSetHeight(root, 50); + + const CSSNodeRef child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(child0, 50); + CSSNodeStyleSetHeight(child0, 25); + CSSNodeInsertChild(root, child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + CSSNodeRemoveChild(root, CSSNodeNew()); + EXPECT_FALSE(CSSNodeIsDirty(root)); + + CSSNodeRemoveChild(root, child0); + EXPECT_TRUE(CSSNodeIsDirty(root)); + + CSSNodeFreeRecursive(root); +} From 0f822bbef22eff80b4bb663c6ffa991966a5e7a4 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Fri, 4 Nov 2016 13:26:33 -0700 Subject: [PATCH 003/108] Remove overflow and flex from API. Summary: flex is just shorthand for flexBasis, flexGrow and flexShrink, and I don't want to expose overflow yet, so, removing them from the API. Reviewed By: ryanolsonk Differential Revision: D4126773 fbshipit-source-id: e3b9ef714832cb5665bd20d7fa92f97a266c9210 --- uikit/CSSLayout/UIView+CSSLayout.h | 2 -- uikit/CSSLayout/UIView+CSSLayout.m | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/uikit/CSSLayout/UIView+CSSLayout.h b/uikit/CSSLayout/UIView+CSSLayout.h index 17bd97ca..24bcc2bb 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.h +++ b/uikit/CSSLayout/UIView+CSSLayout.h @@ -23,9 +23,7 @@ - (void)css_setAlignSelf:(CSSAlign)alignSelf; - (void)css_setPositionType:(CSSPositionType)positionType; - (void)css_setFlexWrap:(CSSWrapType)flexWrap; -- (void)css_setOverflow:(CSSOverflow)overflow; -- (void)css_setFlex:(CGFloat)flex; - (void)css_setFlexGrow:(CGFloat)flexGrow; - (void)css_setFlexShrink:(CGFloat)flexShrink; - (void)css_setFlexBasis:(CGFloat)flexBasis; diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index 1bc408d2..576f7473 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -100,16 +100,6 @@ CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); } -- (void)css_setOverflow:(CSSOverflow)overflow -{ - CSSNodeStyleSetOverflow([self cssNode], overflow); -} - -- (void)css_setFlex:(CGFloat)flex -{ - CSSNodeStyleSetFlex([self cssNode], flex); -} - - (void)css_setFlexGrow:(CGFloat)flexGrow { CSSNodeStyleSetFlexGrow([self cssNode], flexGrow); From 9c1896043d8d24bc9b1e6cdc1baaadca598c49fa Mon Sep 17 00:00:00 2001 From: Andy Street Date: Mon, 7 Nov 2016 05:28:22 -0800 Subject: [PATCH 004/108] Assert that node can have measure function <==> node is a leaf node Summary: @public Instead of silently ignorning non-leaf nodes with measure functions, we should assert that we don't create those kinds of trees. Reviewed By: emilsjolander Differential Revision: D4130770 fbshipit-source-id: a3ef10a2e63bbc12b5aa07977e4b84c8d59e3ffe --- CSSLayout/CSSLayout.c | 17 +++++++++++++---- tests/CSSLayoutMeasureTest.cpp | 26 ++++++++++---------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index dd63fb25..07a0c695 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -255,8 +255,18 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) { } } +void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { + CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); + node->measure = measureFunc; +} + +CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef 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); child->parent = node; _CSSNodeMarkDirty(node); @@ -278,7 +288,7 @@ inline uint32_t CSSNodeChildCount(const CSSNodeRef node) { } void CSSNodeMarkDirty(const CSSNodeRef node) { - CSS_ASSERT(node->measure != NULL || CSSNodeChildCount(node) > 0, + CSS_ASSERT(node->measure != NULL, "Only leaf nodes with custom measure functions" "should manually mark themselves as dirty"); _CSSNodeMarkDirty(node); @@ -367,7 +377,6 @@ void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { } CSS_NODE_PROPERTY_IMPL(void *, Context, context, context); -CSS_NODE_PROPERTY_IMPL(CSSMeasureFunc, MeasureFunc, measureFunc, measure); CSS_NODE_PROPERTY_IMPL(CSSPrintFunc, PrintFunc, printFunc, print); CSS_NODE_PROPERTY_IMPL(bool, IsTextnode, isTextNode, isTextNode); CSS_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); @@ -1211,7 +1220,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // For content (text) nodes, determine the dimensions based on the text // contents. - if (node->measure && CSSNodeChildCount(node) == 0) { + if (node->measure) { const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; @@ -2185,7 +2194,7 @@ bool layoutNodeInternal(const CSSNodeRef node, // most // expensive to measure, so it's worth avoiding redundant measurements if at // all possible. - if (node->measure && CSSNodeChildCount(node) == 0) { + if (node->measure) { const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index e8362d0d..624ca125 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -15,30 +15,24 @@ static CSSSize _measure(CSSNodeRef node, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - int *measureCount = (int *)CSSNodeGetContext(node); - *measureCount = *measureCount + 1; return CSSSize { - .width = widthMode == CSSMeasureModeUndefined ? 10 : width, - .height = heightMode == CSSMeasureModeUndefined ? 10 : width, + .width = 0, + .height = 0, }; } -TEST(CSSLayoutTest, ignore_measure_on_non_leaf_node) { +TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root = CSSNodeNew(); - int measureCount = 0; - CSSNodeSetContext(root, &measureCount); CSSNodeSetMeasureFunc(root, _measure); const CSSNodeRef root_child0 = CSSNodeNew(); - int childMeasureCount = 0; - CSSNodeSetContext(root_child0, &childMeasureCount); - CSSNodeSetMeasureFunc(root_child0, _measure); + ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*"); +} + +TEST(CSSLayoutTest, cannot_add_measure_func_to_non_leaf_node) { + const CSSNodeRef root = CSSNodeNew(); + const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_EQ(0, measureCount); - ASSERT_EQ(1, childMeasureCount); - - CSSNodeFreeRecursive(root); + ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*"); } From 01a388142669804501385a70a98a56c4b1bd5f91 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Mon, 7 Nov 2016 05:40:11 -0800 Subject: [PATCH 005/108] Lazy create children list when first child is added Summary: @public We don't need to allocate a list for every node since leaf nodes don't have children. Reviewed By: emilsjolander Differential Revision: D4130818 fbshipit-source-id: 80d3e98fce9d2daa0676fd1cbed0e81edcf7adb3 --- java/com/facebook/csslayout/CSSNode.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index f07ad7de..b928c212 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -62,8 +62,6 @@ public class CSSNode implements CSSNodeAPI { if (mNativePointer == 0) { throw new IllegalStateException("Failed to allocate native memory"); } - - mChildren = new ArrayList<>(4); } private native void jni_CSSNodeFree(long nativePointer); @@ -98,7 +96,7 @@ public class CSSNode implements CSSNodeAPI { @Override public int getChildCount() { - return mChildren.size(); + return mChildren == null ? 0 : mChildren.size(); } @Override @@ -113,6 +111,9 @@ public class CSSNode implements CSSNodeAPI { throw new IllegalStateException("Child already has a parent, it must be removed first."); } + if (mChildren == null) { + mChildren = new ArrayList<>(4); + } mChildren.add(i, child); child.mParent = this; jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i); @@ -136,7 +137,7 @@ public class CSSNode implements CSSNodeAPI { @Override public int indexOf(CSSNode child) { - return mChildren.indexOf(child); + return mChildren == null ? -1 : mChildren.indexOf(child); } private native void jni_CSSNodeSetIsTextNode(long nativePointer, boolean isTextNode); From 6165d7a2be441a2602c71ba8a776df4e1dd1b968 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Mon, 7 Nov 2016 05:59:47 -0800 Subject: [PATCH 006/108] Make CSSNode#measure final, cache more correct methodid Summary: @public In the JNI portion of CSSLayout, there's a subtle bug where we were caching the jmethodid of the 'measure' of the first object that had measure called on it. However, if that class had overriden measure, then the jmethodid would be specific to that subclass's implementation and would not work for other classes. Conversely, if a regular CSSNode had been called first, then the super method would be called on the subclass instead of the proper overriden method. Since there's not really a reason to overriden measure anyway (since you can just provide a different measure function), it's safest to just mark it final and explicitly cache the appropriate methodid Reviewed By: emilsjolander Differential Revision: D4132428 fbshipit-source-id: 6fb51597d80f1c03681e6611153b52b73b392245 --- java/com/facebook/csslayout/CSSNode.java | 7 ++++++- java/jni/CSSJNI.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index b928c212..6d5d61b3 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -494,8 +494,13 @@ public class CSSNode implements CSSNodeAPI { jni_CSSNodeSetHasMeasureFunc(mNativePointer, measureFunction != null); } + // Implementation Note: Why this method needs to stay final + // + // We cache the jmethodid for this method in CSSLayout code. This means that even if a subclass + // were to override measure, we'd still call this implementation from layout code since the + // overriding method will have a different jmethodid. This is final to prevent that mistake. @DoNotStrip - public long measure(float width, int widthMode, float height, int heightMode) { + public final long measure(float width, int widthMode, float height, int heightMode) { if (!isMeasureDefined()) { throw new RuntimeException("Measure function isn't defined!"); } diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 3d9d488b..87c67cc8 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -51,8 +51,8 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, CSSMeasureMode heightMode) { auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); - static auto measureFunc = - obj->getClass()->getMethod("measure"); + static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") + ->getMethod("measure"); _jniTransferLayoutDirection(node, obj); const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); From 1ffce3edb184454791415952f88b8a1535218fc8 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 7 Nov 2016 06:52:16 -0800 Subject: [PATCH 007/108] Sanitize results from sizeThatFits:, fix bug where only one of the measure modes is CSSMeasureModeExactly. Summary: As I've begun to integrate this into the codebase, I've found that sometimes our layouts are affected by bad implementations of sizeThatFits:. For example, in certain configurations of UILabel it won't take clipping into account and return a size that is much larger than the max size we requested. This adds some checks to make sure we never return a size that is larger than the one specified by `_measure`. This also fixes the bug where `CSSMeasureModeExactly` won't be applied if the measure mode for other parameter is node `CSSMeasureModeExactly`. Reviewed By: emilsjolander Differential Revision: D4131195 fbshipit-source-id: 4659fd83892a2c149b3b70733b06b19217507bf9 --- uikit/CSSLayout/UIView+CSSLayout.m | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index 576f7473..af5b9965 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -205,6 +205,7 @@ static CSSSize _measure( float height, CSSMeasureMode heightMode) { + // sizeThatFits: can be expensive. If we can avoid it, lets do it. if ((widthMode == CSSMeasureModeExactly) && (heightMode == CSSMeasureModeExactly)) { return (CSSSize) { .width = width, @@ -212,18 +213,38 @@ static CSSSize _measure( }; } + const CGFloat constrainedWidth = (widthMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX : width; + const CGFloat constrainedHeight = (heightMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX: height; + UIView *view = (__bridge UIView*) CSSNodeGetContext(node); const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { - .width = widthMode == CSSMeasureModeUndefined ? CGFLOAT_MAX : width, - .height = heightMode == CSSMeasureModeUndefined ? CGFLOAT_MAX : height, + .width = constrainedWidth, + .height = constrainedHeight, }]; return (CSSSize) { - .width = sizeThatFits.width, - .height = sizeThatFits.height, + .width = _sanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), + .height = _sanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), }; } +static CGFloat _sanitizeMeasurement( + CGFloat constrainedSize, + CGFloat measuredSize, + CSSMeasureMode measureMode) +{ + CGFloat result; + if (measureMode == CSSMeasureModeExactly) { + result = constrainedSize; + } else if (measureMode == CSSMeasureModeAtMost) { + result = MIN(constrainedSize, measuredSize); + } else { + result = measuredSize; + } + + return result; +} + static void _attachNodesRecursive(UIView *view) { CSSNodeRef node = [view cssNode]; const BOOL usesFlexbox = [view css_usesFlexbox]; From 18fe0959f02b261b80fa188c72b68493c2565284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=A7=8B=E4=BA=AE?= Date: Mon, 7 Nov 2016 12:54:03 -0800 Subject: [PATCH 008/108] Add inline definition for Microsoft Visual Studio Summary: The inline keyword is available only in C++. The __inline and __forceinline keywords are available in both C and C++. For compatibility with previous versions, _inline is a synonym for __inline. https://msdn.microsoft.com/en-us/library/z8y1yy88(v=vs.120).aspx Closes https://github.com/facebook/css-layout/pull/239 Reviewed By: astreet Differential Revision: D4138941 Pulled By: emilsjolander fbshipit-source-id: cb59dc91ef285e5378036c4912217fd4ec8d9f79 --- CSSLayout/CSSLayout.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 07a0c695..ebde96c0 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -16,6 +16,10 @@ #include #define isnan _isnan +#ifndef __cplusplus +#define inline __inline +#endif + /* define fmaxf if < VC12 */ #if _MSC_VER < 1800 __forceinline const float fmaxf(const float a, const float b) { From 366a61af8d5293fc9317d57d697f63e344a106d6 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 7 Nov 2016 13:32:27 -0800 Subject: [PATCH 009/108] Take care of pixel rounding for UIView. Summary: You can lose a lot of performance on UIView's if they are not pixel-aligned. This protects it from happening in views which use css-layout. Reviewed By: emilsjolander Differential Revision: D4140306 fbshipit-source-id: 53493c08c084a7e3dcd4e05f6a665a99340ea5a6 --- uikit/CSSLayout/Tests/CSSLayoutTests.m | 29 ++++++++++++++++++++++ uikit/CSSLayout/UIView+CSSLayout.m | 33 +++++++++++++++++++++----- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/uikit/CSSLayout/Tests/CSSLayoutTests.m b/uikit/CSSLayout/Tests/CSSLayoutTests.m index 1dfc5339..e9ce9b1d 100644 --- a/uikit/CSSLayout/Tests/CSSLayoutTests.m +++ b/uikit/CSSLayout/Tests/CSSLayoutTests.m @@ -78,4 +78,33 @@ XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize)); } +- (void)testFrameAndOriginPlacement +{ + const CGSize containerSize = CGSizeMake(320, 50); + + UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + + for (int i = 0; i < 3; i++) { + UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; + [subview css_setUsesFlexbox:YES]; + [subview css_setFlexGrow:1]; + + [container addSubview:subview]; + } + [container css_applyLayout]; + + XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame)); + XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame)); + XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame)); + + CGFloat totalWidth = 0; + for (UIView *view in container.subviews) { + totalWidth += view.bounds.size.width; + } + + XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth); +} + @end diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index af5b9965..d7ed0cc6 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -277,22 +277,43 @@ static void _attachNodesRecursive(UIView *view) { } } +static CGFloat _roundPixelValue(CGFloat value) +{ + static CGFloat scale; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^(){ + scale = [UIScreen mainScreen].scale; + }); + + return round(value * scale) / scale; +} + static void _updateFrameRecursive(UIView *view) { + NSAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); CSSNodeRef node = [view cssNode]; - const BOOL usesFlexbox = [view css_usesFlexbox]; - const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0; + + const CGPoint topLeft = { + CSSNodeLayoutGetLeft(node), + CSSNodeLayoutGetTop(node), + }; + + const CGPoint bottomRight = { + topLeft.x + CSSNodeLayoutGetWidth(node), + topLeft.y + CSSNodeLayoutGetHeight(node), + }; view.frame = (CGRect) { .origin = { - .x = CSSNodeLayoutGetLeft(node), - .y = CSSNodeLayoutGetTop(node), + .x = _roundPixelValue(topLeft.x), + .y = _roundPixelValue(topLeft.y), }, .size = { - .width = CSSNodeLayoutGetWidth(node), - .height = CSSNodeLayoutGetHeight(node), + .width = _roundPixelValue(bottomRight.x) - _roundPixelValue(topLeft.x), + .height = _roundPixelValue(bottomRight.y) - _roundPixelValue(topLeft.y), }, }; + const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0; if (!isLeaf) { for (NSUInteger i = 0; i < view.subviews.count; i++) { _updateFrameRecursive(view.subviews[i]); From 7082734c6b0148627ef4c8f939150f39969800f4 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 7 Nov 2016 13:35:03 -0800 Subject: [PATCH 010/108] Kill border API. Summary: We don't want to expose this in our first usage. Lets kill it. Reviewed By: emilsjolander Differential Revision: D4140377 fbshipit-source-id: 0c53845ec65466692b847a5ce40c3b9823dd9557 --- uikit/CSSLayout/UIView+CSSLayout.h | 1 - uikit/CSSLayout/UIView+CSSLayout.m | 5 ----- 2 files changed, 6 deletions(-) diff --git a/uikit/CSSLayout/UIView+CSSLayout.h b/uikit/CSSLayout/UIView+CSSLayout.h index 24bcc2bb..f08daa94 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.h +++ b/uikit/CSSLayout/UIView+CSSLayout.h @@ -31,7 +31,6 @@ - (void)css_setPosition:(CGFloat)position forEdge:(CSSEdge)edge; - (void)css_setMargin:(CGFloat)margin forEdge:(CSSEdge)edge; - (void)css_setPadding:(CGFloat)padding forEdge:(CSSEdge)edge; -- (void)css_setBorder:(CGFloat)border forEdge:(CSSEdge)edge; - (void)css_setWidth:(CGFloat)width; - (void)css_setHeight:(CGFloat)height; diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index d7ed0cc6..ef42975a 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -130,11 +130,6 @@ CSSNodeStyleSetPadding([self cssNode], edge, padding); } -- (void)css_setBorder:(CGFloat)border forEdge:(CSSEdge)edge -{ - CSSNodeStyleSetBorder([self cssNode], edge, border); -} - - (void)css_setWidth:(CGFloat)width { CSSNodeStyleSetWidth([self cssNode], width); From 1c22a1aa5371c7716fdbd0d2ff15b93fc8684558 Mon Sep 17 00:00:00 2001 From: Rachit Siamwalla Date: Mon, 7 Nov 2016 13:55:52 -0800 Subject: [PATCH 011/108] Fix xplat CSSLayoutTests to compile on platforms without death tests. Summary: Not all platforms have gtest death tests. There is a define to check for that. Bracketed the relevant tests with the define. Reviewed By: youerkang Differential Revision: D4141823 fbshipit-source-id: 1396657f3ee83853fcda85d5a51708d4e77642cb --- tests/CSSLayoutMeasureTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index 624ca125..960f3e50 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -10,6 +10,7 @@ #include #include +#if GTEST_HAS_DEATH_TEST static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, @@ -36,3 +37,4 @@ TEST(CSSLayoutTest, cannot_add_measure_func_to_non_leaf_node) { ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*"); } +#endif From ffb90e6ff284c1cc01699ed86a5ad488b46841d0 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 7 Nov 2016 14:25:32 -0800 Subject: [PATCH 012/108] Remove check for both modes being exact as this will never happen Summary: css-layout will only call measure which it is unsure of the size of a node so it will never call measure with both modes equal to exact. Reviewed By: dshahidehpour Differential Revision: D4142193 fbshipit-source-id: fb8423cf0d45852ecb9df8fed042b25d1a443eea --- uikit/CSSLayout/UIView+CSSLayout.m | 8 -------- 1 file changed, 8 deletions(-) diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index ef42975a..e85cf1d3 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -200,14 +200,6 @@ static CSSSize _measure( float height, CSSMeasureMode heightMode) { - // sizeThatFits: can be expensive. If we can avoid it, lets do it. - if ((widthMode == CSSMeasureModeExactly) && (heightMode == CSSMeasureModeExactly)) { - return (CSSSize) { - .width = width, - .height = height, - }; - } - const CGFloat constrainedWidth = (widthMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX : width; const CGFloat constrainedHeight = (heightMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX: height; From 997088ffbb81edb8a07e2004e598a2d969a6ee07 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 7 Nov 2016 14:26:11 -0800 Subject: [PATCH 013/108] Fix broken unit tests. Summary: For some reason I didn't get a signal of this breakage. Fixing unit tests. Reviewed By: emilsjolander Differential Revision: D4140327 fbshipit-source-id: 95049b510a8869b6f68cc841e7f8731364417af9 --- uikit/CSSLayout/Tests/CSSLayoutTests.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uikit/CSSLayout/Tests/CSSLayoutTests.m b/uikit/CSSLayout/Tests/CSSLayoutTests.m index e9ce9b1d..4eb54b19 100644 --- a/uikit/CSSLayout/Tests/CSSLayoutTests.m +++ b/uikit/CSSLayout/Tests/CSSLayoutTests.m @@ -21,7 +21,7 @@ XCTAssertEqual(0, CSSNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - [view css_setFlex:1]; + [view css_setFlexBasis:1]; XCTAssertEqual(1, CSSNodeGetInstanceCount()); view = nil; @@ -33,11 +33,11 @@ XCTAssertEqual(0, CSSNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - [view css_setFlex:1]; + [view css_setFlexBasis:1]; for (int i=0; i<10; i++) { UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; - [subview css_setFlex:1]; + [subview css_setFlexBasis:1]; [view addSubview:subview]; } XCTAssertEqual(11, CSSNodeGetInstanceCount()); From ba2905dd1dbd0a82728c7db167bb11379a4cedc0 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Mon, 7 Nov 2016 19:31:29 -0800 Subject: [PATCH 014/108] Add C# test script for macOS Summary: - Updated README and added bash script for testing C# on macOS Reviewed By: emilsjolander Differential Revision: D4142507 fbshipit-source-id: c682778e42d10242e02f3fdafe8a23f906bfabc5 --- README.md | 3 ++ csharp/tests/Facebook.CSSLayout/test_macos.sh | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 csharp/tests/Facebook.CSSLayout/test_macos.sh diff --git a/README.md b/README.md index 37479cfe..fb1f8b45 100644 --- a/README.md +++ b/README.md @@ -152,5 +152,8 @@ Run `gentest/gentest.rb` to generate test code and re-run `buck test //:CSSLayou You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script. +#### .NET +.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.CSSLayout/test_macos.sh`. + ### Benchmarks Benchmarks are located in `benchmarks/CSSBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. diff --git a/csharp/tests/Facebook.CSSLayout/test_macos.sh b/csharp/tests/Facebook.CSSLayout/test_macos.sh new file mode 100755 index 00000000..27e39f64 --- /dev/null +++ b/csharp/tests/Facebook.CSSLayout/test_macos.sh @@ -0,0 +1,32 @@ +#!/bin/sh +if clang --version >/dev/null 2>&1; then true; else + echo "ERROR: Can't execute clang. You need to install Xcode and command line tools." + exit 1 +fi + +if mcs --version >/dev/null 2>&1; then true; else + echo "ERROR: Can't execute mcs. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment." + exit 1 +fi + +if mono64 --version >/dev/null 2>&1; then true; else + echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment." + exit 1 +fi + +NUNIT=NUnit-2.6.4/bin +if [ -d $NUNIT \ + -a -f $NUNIT/nunit-console.exe \ + -a -f $NUNIT/lib/nunit-console-runner.dll \ + -a -f $NUNIT/lib/nunit.core.dll \ + -a -f $NUNIT/lib/nunit.core.interfaces.dll \ + -a -f $NUNIT/lib/nunit.util.dll ]; then true; else + curl -L -O https://github.com/nunit/nunitv2/releases/download/2.6.4/NUnit-2.6.4.zip + unzip NUnit-2.6.4.zip + rm NUnit-2.6.4.zip +fi + +cd "$( dirname "$0" )" +clang -g -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp +mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs +MONO_PATH=$NUNIT mono64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll From b50090a04efe74bf5c6c6044838a5d9a1e940fae Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Tue, 8 Nov 2016 07:08:12 -0800 Subject: [PATCH 015/108] NSAssert -> NSCAssert. Summary: Not sure why this didn't catch during my testing, but, this causes a build error. #accept2ship Reviewed By: emilsjolander Differential Revision: D4143108 fbshipit-source-id: 01c35c5b91767c95485d615eb06e836b023e125a --- uikit/CSSLayout/UIView+CSSLayout.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index e85cf1d3..31cfbf1b 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -276,7 +276,7 @@ static CGFloat _roundPixelValue(CGFloat value) } static void _updateFrameRecursive(UIView *view) { - NSAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); + NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); CSSNodeRef node = [view cssNode]; const CGPoint topLeft = { From 1baa239389ca3943ea952d493163b13e39a74d8c Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 8 Nov 2016 09:07:48 -0800 Subject: [PATCH 016/108] Remove isTextNode optimization Summary: Scrolling through feed and logging when this optimization is hit leads to... 0 logs. If anything this just adds to confusion. It was initially added due to instinct and not data, which was a mistake. I am happy to add some similar optimization in the future if we have data that it is useful in real world situations, currently it just leads to bugs and confusion though. Reviewed By: astreet Differential Revision: D4146785 fbshipit-source-id: e20d780fbd5759b8f38b809e8cadf29cedee82a8 --- CSSLayout/CSSLayout.c | 13 ++----- CSSLayout/CSSLayout.h | 4 +- csharp/Facebook.CSSLayout/CSSNode.cs | 13 ------- csharp/Facebook.CSSLayout/Native.cs | 7 ---- java/com/facebook/csslayout/CSSNode.java | 12 ------ java/com/facebook/csslayout/CSSNodeAPI.java | 2 - .../facebook/csslayout/CSSNodeDEPRECATED.java | 11 ------ java/com/facebook/csslayout/LayoutEngine.java | 37 +------------------ java/jni/CSSJNI.cpp | 10 ----- tests/CSSLayoutMeasureCacheTest.cpp | 20 ---------- 10 files changed, 7 insertions(+), 122 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index ebde96c0..2e2b9960 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -89,7 +89,6 @@ typedef struct CSSNode { CSSLayout layout; uint32_t lineIndex; bool hasNewLayout; - bool isTextNode; CSSNodeRef parent; CSSNodeListRef children; bool isDirty; @@ -382,7 +381,6 @@ void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { CSS_NODE_PROPERTY_IMPL(void *, Context, context, context); CSS_NODE_PROPERTY_IMPL(CSSPrintFunc, PrintFunc, printFunc, print); -CSS_NODE_PROPERTY_IMPL(bool, IsTextnode, isTextNode, isTextNode); CSS_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); CSS_NODE_STYLE_PROPERTY_IMPL(CSSDirection, Direction, direction, direction); @@ -2104,8 +2102,7 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode lastSize > size && lastComputedSize <= size; } -bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, - const CSSMeasureMode widthMode, +bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, const float width, const CSSMeasureMode heightMode, const float height, @@ -2134,7 +2131,7 @@ bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, newMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); - const bool heightIsCompatible = isTextNode || hasSameHeightSpec || + const bool heightIsCompatible = hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, height - marginColumn, lastComputedHeight) || @@ -2203,8 +2200,7 @@ bool layoutNodeInternal(const CSSNodeRef node, const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); // First, try to use the layout cache. - if (CSSNodeCanUseCachedMeasurement(node->isTextNode, - widthMeasureMode, + if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, availableWidth, heightMeasureMode, availableHeight, @@ -2220,8 +2216,7 @@ bool layoutNodeInternal(const CSSNodeRef node, } else { // Try to use the measurement cache. for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) { - if (CSSNodeCanUseCachedMeasurement(node->isTextNode, - widthMeasureMode, + if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, availableWidth, heightMeasureMode, availableHeight, diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 881d8f3b..88272ad7 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -161,8 +161,7 @@ WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions option WIN_EXPORT bool CSSValueIsUndefined(const float value); -WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, - const CSSMeasureMode widthMode, +WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, const float width, const CSSMeasureMode heightMode, const float height, @@ -195,7 +194,6 @@ WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, CSS_NODE_PROPERTY(void *, Context, context); CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc); -CSS_NODE_PROPERTY(bool, IsTextnode, isTextNode); CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout); CSS_NODE_STYLE_PROPERTY(CSSDirection, Direction, direction); diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 1648617f..b28114d5 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -62,19 +62,6 @@ namespace Facebook.CSSLayout Native.CSSNodeMarkDirty(_cssNode); } - public bool IsTextNode - { - get - { - return Native.CSSNodeGetIsTextnode(_cssNode); - } - - set - { - Native.CSSNodeSetIsTextnode(_cssNode, value); - } - } - public bool HasNewLayout { get diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index 163f0049..0d736f36 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -92,13 +92,6 @@ namespace Facebook.CSSLayout [return: MarshalAs(UnmanagedType.FunctionPtr)] public static extern CSSMeasureFunc CSSNodeGetMeasureFunc(IntPtr node); - [DllImport(DllName)] - public static extern void CSSNodeSetIsTextnode(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool isTextNode); - - [DllImport(DllName)] - [return: MarshalAs(UnmanagedType.I1)] - public static extern bool CSSNodeGetIsTextnode(IntPtr node); - [DllImport(DllName)] public static extern void CSSNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 6d5d61b3..612be246 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -140,18 +140,6 @@ public class CSSNode implements CSSNodeAPI { return mChildren == null ? -1 : mChildren.indexOf(child); } - private native void jni_CSSNodeSetIsTextNode(long nativePointer, boolean isTextNode); - @Override - public void setIsTextNode(boolean isTextNode) { - jni_CSSNodeSetIsTextNode(mNativePointer, isTextNode); - } - - private native boolean jni_CSSNodeGetIsTextNode(long nativePointer); - @Override - public boolean isTextNode() { - return jni_CSSNodeGetIsTextNode(mNativePointer); - } - private native void jni_CSSNodeCalculateLayout(long nativePointer); @Override public void calculateLayout(CSSLayoutContext layoutContext) { diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/CSSNodeAPI.java index 5a5de382..dd18a54b 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/CSSNodeAPI.java @@ -31,8 +31,6 @@ public interface CSSNodeAPI { int indexOf(CSSNodeType child); void setMeasureFunction(MeasureFunction measureFunction); boolean isMeasureDefined(); - void setIsTextNode(boolean isTextNode); - boolean isTextNode(); void calculateLayout(CSSLayoutContext layoutContext); boolean isDirty(); boolean hasNewLayout(); diff --git a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java index 05632cf8..dc31cc04 100644 --- a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java +++ b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java @@ -58,7 +58,6 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { private @Nullable CSSNodeDEPRECATED mParent; private @Nullable MeasureFunction mMeasureFunction = null; private LayoutState mLayoutState = LayoutState.DIRTY; - private boolean mIsTextNode = false; private Object mData; @Override @@ -124,16 +123,6 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { return mMeasureFunction != null; } - @Override - public void setIsTextNode(boolean isTextNode) { - mIsTextNode = isTextNode; - } - - @Override - public boolean isTextNode() { - return mIsTextNode; - } - long measure(float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { if (!isMeasureDefined()) { throw new RuntimeException("Measure function isn't defined!"); diff --git a/java/com/facebook/csslayout/LayoutEngine.java b/java/com/facebook/csslayout/LayoutEngine.java index 79d33bce..c6fa42c2 100644 --- a/java/com/facebook/csslayout/LayoutEngine.java +++ b/java/com/facebook/csslayout/LayoutEngine.java @@ -240,7 +240,6 @@ public class LayoutEngine { } /*package*/ static boolean canUseCachedMeasurement( - boolean isTextNode, float availableWidth, float availableHeight, float marginRow, @@ -281,38 +280,6 @@ public class LayoutEngine { return true; } - // We know this to be text so we can apply some more specialized heuristics. - if (isTextNode) { - if (isWidthSame) { - if (heightMeasureMode == CSSMeasureMode.UNDEFINED) { - // Width is the same and height is not restricted. Re-use cahced value. - return true; - } - - if (heightMeasureMode == CSSMeasureMode.AT_MOST && - cachedLayout.computedHeight < (availableHeight - marginColumn)) { - // Width is the same and height restriction is greater than the cached height. Re-use cached value. - return true; - } - - // Width is the same but height restriction imposes smaller height than previously measured. - // Update the cached value to respect the new height restriction. - cachedLayout.computedHeight = availableHeight - marginColumn; - return true; - } - - if (cachedLayout.widthMeasureMode == CSSMeasureMode.UNDEFINED) { - if (widthMeasureMode == CSSMeasureMode.UNDEFINED || - (widthMeasureMode == CSSMeasureMode.AT_MOST && - cachedLayout.computedWidth <= (availableWidth - marginRow))) { - // Previsouly this text was measured with no width restriction, if width is now restricted - // but to a larger value than the previsouly measured width we can re-use the measurement - // as we know it will fit. - return true; - } - } - } - return false; } @@ -364,13 +331,13 @@ public class LayoutEngine { node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]); // First, try to use the layout cache. - if (canUseCachedMeasurement(node.isTextNode(), availableWidth, availableHeight, marginAxisRow, marginAxisColumn, + if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, widthMeasureMode, heightMeasureMode, layout.cachedLayout)) { cachedResults = layout.cachedLayout; } else { // Try to use the measurement cache. for (int i = 0; i < layout.nextCachedMeasurementsIndex; i++) { - if (canUseCachedMeasurement(node.isTextNode(), availableWidth, availableHeight, marginAxisRow, marginAxisColumn, + if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, widthMeasureMode, heightMeasureMode, layout.cachedMeasurements[i])) { cachedResults = layout.cachedMeasurements[i]; break; diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 87c67cc8..e1c86237 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -129,14 +129,6 @@ void jni_CSSNodeSetHasMeasureFunc(alias_ref, CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL); } -void jni_CSSNodeSetIsTextNode(alias_ref, jlong nativePointer, jboolean isTextNode) { - CSSNodeSetIsTextnode(_jlong2CSSNodeRef(nativePointer), isTextNode); -} - -jboolean jni_CSSNodeGetIsTextNode(alias_ref, jlong nativePointer) { - return (jboolean) CSSNodeGetIsTextnode(_jlong2CSSNodeRef(nativePointer)); -} - jboolean jni_CSSNodeHasNewLayout(alias_ref, jlong nativePointer) { return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer)); } @@ -209,8 +201,6 @@ jint JNI_OnLoad(JavaVM *vm, void *) { CSSMakeNativeMethod(jni_CSSNodeReset), CSSMakeNativeMethod(jni_CSSNodeInsertChild), CSSMakeNativeMethod(jni_CSSNodeRemoveChild), - CSSMakeNativeMethod(jni_CSSNodeSetIsTextNode), - CSSMakeNativeMethod(jni_CSSNodeGetIsTextNode), CSSMakeNativeMethod(jni_CSSNodeCalculateLayout), CSSMakeNativeMethod(jni_CSSNodeHasNewLayout), CSSMakeNativeMethod(jni_CSSNodeMarkDirty), diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index b2b90bbc..c0a8e6fa 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -59,26 +59,6 @@ TEST(CSSLayoutTest, measure_once_single_flexible_child) { CSSNodeFreeRecursive(root); } -TEST(CSSLayoutTest, remeasure_text_node_height_change) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetIsTextnode(root_child0, true); - CSSNodeStyleSetFlexGrow(root_child0, 1); - int measureCount = 0; - CSSNodeSetContext(root_child0, &measureCount); - CSSNodeSetMeasureFunc(root_child0, _measureMax); - CSSNodeInsertChild(root, root_child0, 0); - - CSSNodeCalculateLayout(root, 100, 10, CSSDirectionLTR); - CSSNodeCalculateLayout(root, 100, 20, CSSDirectionLTR); - - ASSERT_EQ(1, measureCount); - - CSSNodeFreeRecursive(root); -} - TEST(CSSLayoutTest, remeasure_with_same_exact_width_larger_than_needed_height) { const CSSNodeRef root = CSSNodeNew(); From 3e567fdcae10630670fe92afa8b725251fad3a33 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 8 Nov 2016 09:45:58 -0800 Subject: [PATCH 017/108] Fix flex within max width constraint Summary: Max dimension constraints were not correctly passed down to children. see https://github.com/facebook/css-layout/issues/230 for more info fixes #230 Reviewed By: gkassabli Differential Revision: D4147199 fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9 --- CSSLayout/CSSLayout.c | 30 ++++++++++ .../CSSLayoutMinMaxDimensionTest.cs | 59 +++++++++++++++++++ .../CSSLayoutMinMaxDimensionTest.html | 6 ++ .../CSSLayoutMinMaxDimensionTest.java | 58 ++++++++++++++++++ tests/CSSLayoutMinMaxDimensionTest.cpp | 57 ++++++++++++++++++ 5 files changed, 210 insertions(+) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 2e2b9960..d9d7d65b 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -964,6 +964,16 @@ static void computeChildFlexBasis(const CSSNodeRef node, childHeightMeasureMode = CSSMeasureModeExactly; } + if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) { + childWidth = child->style.maxDimensions[CSSDimensionWidth]; + childWidthMeasureMode = CSSMeasureModeAtMost; + } + + if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) { + childHeight = child->style.maxDimensions[CSSDimensionHeight]; + childHeightMeasureMode = CSSMeasureModeAtMost; + } + // Measure the child layoutNodeInternal(child, childWidth, @@ -1670,6 +1680,16 @@ static void layoutNodeImpl(const CSSNodeRef node, } } + if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionWidth])) { + childWidth = currentRelativeChild->style.maxDimensions[CSSDimensionWidth]; + childWidthMeasureMode = CSSMeasureModeAtMost; + } + + if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionHeight])) { + childHeight = currentRelativeChild->style.maxDimensions[CSSDimensionHeight]; + childHeightMeasureMode = CSSMeasureModeAtMost; + } + const bool requiresStretchLayout = !isStyleDimDefined(currentRelativeChild, crossAxis) && getAlignItem(node, currentRelativeChild) == CSSAlignStretch; @@ -1859,6 +1879,16 @@ static void layoutNodeImpl(const CSSNodeRef node, getMarginAxis(child, CSSFlexDirectionColumn); } + if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) { + childWidth = child->style.maxDimensions[CSSDimensionWidth]; + childWidthMeasureMode = CSSMeasureModeAtMost; + } + + if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) { + childHeight = child->style.maxDimensions[CSSDimensionHeight]; + childHeightMeasureMode = CSSMeasureModeAtMost; + } + // If the child defines a definite size for its cross axis, there's // no need to stretch. if (!isCrossSizeDefinite) { diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index 73a2a84f..f09deb1f 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -383,5 +389,58 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child2.LayoutHeight); } + [Test] + public void Test_flex_grow_within_max_width() + { + CSSNode root = new CSSNode(); + root.StyleWidth = 200; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexDirection = CSSFlexDirection.Row; + root_child0.StyleMaxWidth = 100; + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.FlexGrow = 1; + root_child0_child0.StyleHeight = 20; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(200, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(20, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(100, root_child0_child0.LayoutWidth); + Assert.AreEqual(20, root_child0_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(200, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(100, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(20, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(100, root_child0_child0.LayoutWidth); + Assert.AreEqual(20, root_child0_child0.LayoutHeight); + } + } } diff --git a/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html b/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html index d2925c04..599f3fe6 100644 --- a/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html +++ b/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html @@ -29,3 +29,9 @@
+ +
+
+
+
+
diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index 2607d23e..271f3a9f 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -375,4 +381,56 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(50, root_child2.getLayoutHeight(), 0.0f); } + @Test + public void test_flex_grow_within_max_width() { + final CSSNode root = new CSSNode(); + root.setStyleWidth(200); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexDirection(CSSFlexDirection.ROW); + root_child0.setStyleMaxWidth(100); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setStyleHeight(20); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(200, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(200, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(100, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + } + } diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index b58f22db..38358a36 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -363,3 +369,54 @@ TEST(CSSLayoutTest, justify_content_overflow_min_max) { CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, flex_grow_within_max_width) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 200); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(root_child0, CSSFlexDirectionRow); + CSSNodeStyleSetMaxWidth(root_child0, 100); + CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(100, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeFreeRecursive(root); +} From 12ebaa56b650f892f8cef52a63f1758e01951fcc Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 8 Nov 2016 15:23:08 -0800 Subject: [PATCH 018/108] Dont measure single flex grow+shrink child Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space. Reviewed By: gkassabli Differential Revision: D4147298 fbshipit-source-id: 51152e57eff8e322a833a6d698c30f8c5e2dcc35 --- CSSLayout/CSSLayout.c | 85 ++++++++++++++++++----------- java/jni/CSSJNI.cpp | 8 ++- tests/CSSLayoutMeasureCacheTest.cpp | 3 +- tests/CSSLayoutMeasureTest.cpp | 30 +++++++++- 4 files changed, 88 insertions(+), 38 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index d9d7d65b..75fa825c 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -259,7 +259,8 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) { } void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { - CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); + CSS_ASSERT(CSSNodeChildCount(node) == 0, + "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } @@ -269,7 +270,8 @@ CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) { 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."); + CSS_ASSERT(node->measure == NULL, + "Cannot add child: Nodes with measure functions cannot have children."); CSSNodeListInsert(&node->children, child, index); child->parent = node; _CSSNodeMarkDirty(node); @@ -1367,6 +1369,26 @@ static void layoutNodeImpl(const CSSNodeRef node, const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; + // If there is only one child with flexGrow + flexShrink it means we can set the + // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly + // match the remaining space + CSSNodeRef singleFlexChild = NULL; + if ((isMainAxisRow && widthMeasureMode != CSSMeasureModeUndefined) || + (!isMainAxisRow && heightMeasureMode != CSSMeasureModeUndefined)) { + for (uint32_t i = 0; i < childCount; i++) { + const CSSNodeRef child = CSSNodeGetChild(node, i); + if (singleFlexChild) { + if (isFlex(child)) { + // There is already a flexible child, abort. + singleFlexChild = NULL; + break; + } + } else if (CSSNodeStyleGetFlexGrow(child) > 0 && CSSNodeStyleGetFlexShrink(child) > 0) { + singleFlexChild = child; + } + } + } + // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM for (uint32_t i = 0; i < childCount; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); @@ -1391,13 +1413,17 @@ static void layoutNodeImpl(const CSSNodeRef node, currentAbsoluteChild = child; child->nextChild = NULL; } else { - computeChildFlexBasis(node, - child, - availableInnerWidth, - widthMeasureMode, - availableInnerHeight, - heightMeasureMode, - direction); + if (child == singleFlexChild) { + child->layout.computedFlexBasis = 0; + } else { + computeChildFlexBasis(node, + child, + availableInnerWidth, + widthMeasureMode, + availableInnerHeight, + heightMeasureMode, + direction); + } } } @@ -2133,17 +2159,17 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode } bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, - const float width, - const CSSMeasureMode heightMode, - const float height, - const CSSMeasureMode lastWidthMode, - const float lastWidth, - const CSSMeasureMode lastHeightMode, - const float lastHeight, - const float lastComputedWidth, - const float lastComputedHeight, - const float marginRow, - const float marginColumn) { + const float width, + const CSSMeasureMode heightMode, + const float height, + const CSSMeasureMode lastWidthMode, + const float lastWidth, + const CSSMeasureMode lastHeightMode, + const float lastHeight, + const float lastComputedWidth, + const float lastComputedHeight, + const float marginRow, + const float marginColumn) { if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } @@ -2161,19 +2187,16 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, newMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); - const bool heightIsCompatible = hasSameHeightSpec || - newSizeIsExactAndMatchesOldMeasuredSize(heightMode, - height - marginColumn, - lastComputedHeight) || - oldSizeIsUnspecifiedAndStillFits(heightMode, + const bool heightIsCompatible = + hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, height - marginColumn, - lastHeightMode, lastComputedHeight) || - newMeasureSizeIsStricterAndStillValid(heightMode, - height - marginColumn, - lastHeightMode, - lastHeight, - lastComputedHeight); + oldSizeIsUnspecifiedAndStillFits(heightMode, + height - marginColumn, + lastHeightMode, + lastComputedHeight) || + newMeasureSizeIsStricterAndStillValid( + heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight); return widthIsCompatible && heightIsCompatible; } diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index e1c86237..16869f1a 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -40,7 +40,8 @@ static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) { } static void _jniPrint(CSSNodeRef node) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local( + Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); cout << obj->toString() << endl; } @@ -49,10 +50,11 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local( + Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") - ->getMethod("measure"); + ->getMethod("measure"); _jniTransferLayoutDirection(node, obj); const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index c0a8e6fa..9378b579 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -17,7 +17,8 @@ static CSSSize _measureMax(CSSNodeRef node, CSSMeasureMode heightMode) { int *measureCount = (int *)CSSNodeGetContext(node); - *measureCount = *measureCount + 1; + (*measureCount)++; + return CSSSize { .width = widthMode == CSSMeasureModeUndefined ? 10 : width, .height = heightMode == CSSMeasureModeUndefined ? 10 : height, diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index 960f3e50..b238173c 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -10,18 +10,42 @@ #include #include -#if GTEST_HAS_DEATH_TEST static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { + int *measureCount = (int*) CSSNodeGetContext(node); + if (measureCount) { + (*measureCount)++; + } + return CSSSize { - .width = 0, - .height = 0, + .width = 10, + .height = 10, }; } +TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, measureCount); +} + +#if GTEST_HAS_DEATH_TEST TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root = CSSNodeNew(); CSSNodeSetMeasureFunc(root, _measure); From 502f3c7010c56894f6992417836082a6a9554425 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Wed, 9 Nov 2016 00:04:13 -0800 Subject: [PATCH 019/108] Reverted commit D4147298 Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space. Reviewed By: gkassabli Differential Revision: D4147298 fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d --- CSSLayout/CSSLayout.c | 85 +++++++++++------------------ java/jni/CSSJNI.cpp | 8 +-- tests/CSSLayoutMeasureCacheTest.cpp | 3 +- tests/CSSLayoutMeasureTest.cpp | 30 +--------- 4 files changed, 38 insertions(+), 88 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 75fa825c..d9d7d65b 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -259,8 +259,7 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) { } void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { - CSS_ASSERT(CSSNodeChildCount(node) == 0, - "Cannot set measure function: Nodes with measure functions cannot have children."); + CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } @@ -270,8 +269,7 @@ CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) { 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."); + CSS_ASSERT(node->measure == NULL, "Cannot add child: Nodes with measure functions cannot have children."); CSSNodeListInsert(&node->children, child, index); child->parent = node; _CSSNodeMarkDirty(node); @@ -1369,26 +1367,6 @@ static void layoutNodeImpl(const CSSNodeRef node, const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; - // If there is only one child with flexGrow + flexShrink it means we can set the - // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly - // match the remaining space - CSSNodeRef singleFlexChild = NULL; - if ((isMainAxisRow && widthMeasureMode != CSSMeasureModeUndefined) || - (!isMainAxisRow && heightMeasureMode != CSSMeasureModeUndefined)) { - for (uint32_t i = 0; i < childCount; i++) { - const CSSNodeRef child = CSSNodeGetChild(node, i); - if (singleFlexChild) { - if (isFlex(child)) { - // There is already a flexible child, abort. - singleFlexChild = NULL; - break; - } - } else if (CSSNodeStyleGetFlexGrow(child) > 0 && CSSNodeStyleGetFlexShrink(child) > 0) { - singleFlexChild = child; - } - } - } - // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM for (uint32_t i = 0; i < childCount; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); @@ -1413,17 +1391,13 @@ static void layoutNodeImpl(const CSSNodeRef node, currentAbsoluteChild = child; child->nextChild = NULL; } else { - if (child == singleFlexChild) { - child->layout.computedFlexBasis = 0; - } else { - computeChildFlexBasis(node, - child, - availableInnerWidth, - widthMeasureMode, - availableInnerHeight, - heightMeasureMode, - direction); - } + computeChildFlexBasis(node, + child, + availableInnerWidth, + widthMeasureMode, + availableInnerHeight, + heightMeasureMode, + direction); } } @@ -2159,17 +2133,17 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode } bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, - const float width, - const CSSMeasureMode heightMode, - const float height, - const CSSMeasureMode lastWidthMode, - const float lastWidth, - const CSSMeasureMode lastHeightMode, - const float lastHeight, - const float lastComputedWidth, - const float lastComputedHeight, - const float marginRow, - const float marginColumn) { + const float width, + const CSSMeasureMode heightMode, + const float height, + const CSSMeasureMode lastWidthMode, + const float lastWidth, + const CSSMeasureMode lastHeightMode, + const float lastHeight, + const float lastComputedWidth, + const float lastComputedHeight, + const float marginRow, + const float marginColumn) { if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } @@ -2187,16 +2161,19 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, newMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); - const bool heightIsCompatible = - hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, + const bool heightIsCompatible = hasSameHeightSpec || + newSizeIsExactAndMatchesOldMeasuredSize(heightMode, + height - marginColumn, + lastComputedHeight) || + oldSizeIsUnspecifiedAndStillFits(heightMode, height - marginColumn, + lastHeightMode, lastComputedHeight) || - oldSizeIsUnspecifiedAndStillFits(heightMode, - height - marginColumn, - lastHeightMode, - lastComputedHeight) || - newMeasureSizeIsStricterAndStillValid( - heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight); + newMeasureSizeIsStricterAndStillValid(heightMode, + height - marginColumn, + lastHeightMode, + lastHeight, + lastComputedHeight); return widthIsCompatible && heightIsCompatible; } diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 16869f1a..e1c86237 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -40,8 +40,7 @@ static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) { } static void _jniPrint(CSSNodeRef node) { - auto obj = adopt_local( - Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); cout << obj->toString() << endl; } @@ -50,11 +49,10 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - auto obj = adopt_local( - Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") - ->getMethod("measure"); + ->getMethod("measure"); _jniTransferLayoutDirection(node, obj); const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index 9378b579..c0a8e6fa 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -17,8 +17,7 @@ static CSSSize _measureMax(CSSNodeRef node, CSSMeasureMode heightMode) { int *measureCount = (int *)CSSNodeGetContext(node); - (*measureCount)++; - + *measureCount = *measureCount + 1; return CSSSize { .width = widthMode == CSSMeasureModeUndefined ? 10 : width, .height = heightMode == CSSMeasureModeUndefined ? 10 : height, diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index b238173c..960f3e50 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -10,42 +10,18 @@ #include #include +#if GTEST_HAS_DEATH_TEST static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - int *measureCount = (int*) CSSNodeGetContext(node); - if (measureCount) { - (*measureCount)++; - } - return CSSSize { - .width = 10, - .height = 10, + .width = 0, + .height = 0, }; } -TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(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); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_EQ(0, measureCount); -} - -#if GTEST_HAS_DEATH_TEST TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root = CSSNodeNew(); CSSNodeSetMeasureFunc(root, _measure); From e54af5e854a38ad6bed734945dac10b837b9d203 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Wed, 9 Nov 2016 08:42:45 -0800 Subject: [PATCH 020/108] Allow MeasureFunc to be set to NULL no matter how many children a node has. Summary: Within `UIView+CSSLayout`, we often nil out the measure function of a node because view hierarchy can often change. Unfortunately, this causes us to hit an assert which crashes the app. Instead, lets the measure func to be set to NULL, regardless of how many children a node might have. Reviewed By: emilsjolander Differential Revision: D4148727 fbshipit-source-id: 79a0f3ef1bf7b1dce9a14de96f870e35c042b78b --- CSSLayout/CSSLayout.c | 9 +++++++-- tests/CSSLayoutMeasureTest.cpp | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index d9d7d65b..4aac54ec 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -259,8 +259,13 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) { } void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { - CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); - node->measure = measureFunc; + // You can always NULLify the measure function of a node. + if (measureFunc == NULL) { + node->measure = NULL; + } else { + CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); + node->measure = measureFunc; + } } CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) { diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index 960f3e50..cfed9363 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -28,13 +28,25 @@ TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root_child0 = CSSNodeNew(); ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*"); + CSSNodeFreeRecursive(root); } -TEST(CSSLayoutTest, cannot_add_measure_func_to_non_leaf_node) { +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); ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*"); + CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, can_nullify_measure_func_on_any_node) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeInsertChild(root, CSSNodeNew(), 0); + + CSSNodeSetMeasureFunc(root, NULL); + ASSERT_TRUE(CSSNodeGetMeasureFunc(root) == NULL); + CSSNodeFreeRecursive(root); +} + #endif From 6a6efe07649cdea4995a78ab4d12520ab6286fe6 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 09:10:54 -0800 Subject: [PATCH 021/108] change default value of position styles Summary: Default value for positions should be undefined not 0px. Fixing this leads to more correct tests. Reviewed By: gkassabli Differential Revision: D4153329 fbshipit-source-id: d0f194f9c47eac93d3815ec7e55568a1016bc7fe --- .../CSSLayoutAbsolutePositionTest.cs | 4 +++- .../fixtures/CSSLayoutAbsolutePositionTest.html | 2 +- gentest/gentest.js | 17 +++++++++++++---- .../CSSLayoutAbsolutePositionTest.java | 4 +++- tests/CSSLayoutAbsolutePositionTest.cpp | 4 +++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index c9ae2bb6..b5ee81a3 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -27,7 +27,7 @@
-
+
@@ -219,6 +219,8 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; + root_child0.SetPosition(CSSEdge.Start, 0); + root_child0.SetPosition(CSSEdge.Top, 0); root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); diff --git a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html index bb6e5673..37ebffe8 100644 --- a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html +++ b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html @@ -15,7 +15,7 @@
-
+
diff --git a/gentest/gentest.js b/gentest/gentest.js index a680a9d0..07fef381 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -159,10 +159,10 @@ function checkDefaultValues() { {style:'overflow', value:'visible'}, {style:'flex-grow', value:'0'}, {style:'flex-shrink', value:'0'}, - {style:'left', value:'0px'}, - {style:'top', value:'0px'}, - {style:'right', value:'0px'}, - {style:'bottom', value:'0px'}, + {style:'left', value:'undefined'}, + {style:'top', value:'undefined'}, + {style:'right', value:'undefined'}, + {style:'bottom', value:'undefined'}, ].forEach(function(item) { assert(item.value === getDefaultStyleValue(item.style), item.style + ' should be ' + item.value); @@ -415,6 +415,15 @@ function getDefaultStyleValue(style) { if (style == 'position') { return 'relative'; } + switch (style) { + case 'left': + case 'top': + case 'right': + case 'bottom': + case 'start': + case 'end': + return 'undefined'; + } var node = document.getElementById('default'); return getComputedStyle(node, null).getPropertyValue(style); } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index c64be24e..f3703e70 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -27,7 +27,7 @@
-
+
@@ -213,6 +213,8 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); + root_child0.setPosition(Spacing.START, 0); + root_child0.setPosition(Spacing.TOP, 0); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index d817b6ff..92fd8f0f 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -27,7 +27,7 @@
-
+
@@ -204,6 +204,8 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 0); + CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); CSSNodeInsertChild(root, root_child0, 0); const CSSNodeRef root_child0_child0 = CSSNodeNew(); From f1fcd5e3823c23cdb9d6f9e00d38ed75e75e8231 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Wed, 9 Nov 2016 09:45:37 -0800 Subject: [PATCH 022/108] Update logging to support levels, print messages in Android logcat on assertion failures Summary: @public The goal of this diff is to have assertion failures show up as error logs on Android. To do this, I updated the logging API to take calls with log levels. We now have to pass around va_list unfortunately since you can't re-expand or pass along var-args to a subcall. Reviewed By: emilsjolander Differential Revision: D4140898 fbshipit-source-id: e0eb9a1f0b08a7d90a8233f66bb857d5b871b6ad --- CSSLayout/CSSLayout.c | 116 +++++++++++++++++++++++++++--------------- CSSLayout/CSSLayout.h | 11 +++- CSSLayout/CSSMacros.h | 2 +- 3 files changed, 86 insertions(+), 43 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 4aac54ec..25ab962f 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -104,16 +104,43 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node); #ifdef ANDROID #include -static int _csslayoutAndroidLog(const char *format, ...) { - va_list args; - va_start(args, format); - const int result = __android_log_vprint(ANDROID_LOG_DEBUG, "css-layout", format, args); - va_end(args); +static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) { + int androidLevel = CSSLogLevelDebug; + switch (level) { + case CSSLogLevelError: + androidLevel = ANDROID_LOG_ERROR; + break; + case CSSLogLevelWarn: + androidLevel = ANDROID_LOG_WARN; + break; + case CSSLogLevelInfo: + androidLevel = ANDROID_LOG_INFO; + break; + case CSSLogLevelDebug: + androidLevel = ANDROID_LOG_DEBUG; + break; + case CSSLogLevelVerbose: + androidLevel = ANDROID_LOG_VERBOSE; + break; + } + const int result = __android_log_vprint(androidLevel, "css-layout", format, args); return result; } static CSSLogger gLogger = &_csslayoutAndroidLog; #else -static CSSLogger gLogger = &printf; +static int _csslayoutDefaultLog(CSSLogLevel level, const char *format, va_list args) { + switch (level) { + case CSSLogLevelError: + return vfprintf(stderr, format, args); + case CSSLogLevelWarn: + case CSSLogLevelInfo: + case CSSLogLevelDebug: + case CSSLogLevelVerbose: + default: + return vprintf(format, args); + } +} +static CSSLogger gLogger = &_csslayoutDefaultLog; #endif static inline float computedEdgeValue(const float edges[CSSEdgeCount], @@ -446,19 +473,19 @@ static inline bool eq(const float a, const float b) { static void indent(const uint32_t n) { for (uint32_t i = 0; i < n; i++) { - gLogger(" "); + CSSLog(CSSLogLevelDebug, " "); } } static void printNumberIfNotZero(const char *str, const float number) { if (!eq(number, 0)) { - gLogger("%s: %g, ", str, number); + CSSLog(CSSLogLevelDebug, "%s: %g, ", str, number); } } static void printNumberIfNotUndefined(const char *str, const float number) { if (!CSSValueIsUndefined(number)) { - gLogger("%s: %g, ", str, number); + CSSLog(CSSLogLevelDebug, "%s: %g, ", str, number); } } @@ -470,66 +497,66 @@ static void _CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options, const uint32_t level) { indent(level); - gLogger("{"); + CSSLog(CSSLogLevelDebug, "{"); if (node->print) { node->print(node); } if (options & CSSPrintOptionsLayout) { - gLogger("layout: {"); - gLogger("width: %g, ", node->layout.dimensions[CSSDimensionWidth]); - gLogger("height: %g, ", node->layout.dimensions[CSSDimensionHeight]); - gLogger("top: %g, ", node->layout.position[CSSEdgeTop]); - gLogger("left: %g", node->layout.position[CSSEdgeLeft]); - gLogger("}, "); + CSSLog(CSSLogLevelDebug, "layout: {"); + CSSLog(CSSLogLevelDebug, "width: %g, ", node->layout.dimensions[CSSDimensionWidth]); + CSSLog(CSSLogLevelDebug, "height: %g, ", node->layout.dimensions[CSSDimensionHeight]); + CSSLog(CSSLogLevelDebug, "top: %g, ", node->layout.position[CSSEdgeTop]); + CSSLog(CSSLogLevelDebug, "left: %g", node->layout.position[CSSEdgeLeft]); + CSSLog(CSSLogLevelDebug, "}, "); } if (options & CSSPrintOptionsStyle) { if (node->style.flexDirection == CSSFlexDirectionColumn) { - gLogger("flexDirection: 'column', "); + CSSLog(CSSLogLevelDebug, "flexDirection: 'column', "); } else if (node->style.flexDirection == CSSFlexDirectionColumnReverse) { - gLogger("flexDirection: 'column-reverse', "); + CSSLog(CSSLogLevelDebug, "flexDirection: 'column-reverse', "); } else if (node->style.flexDirection == CSSFlexDirectionRow) { - gLogger("flexDirection: 'row', "); + CSSLog(CSSLogLevelDebug, "flexDirection: 'row', "); } else if (node->style.flexDirection == CSSFlexDirectionRowReverse) { - gLogger("flexDirection: 'row-reverse', "); + CSSLog(CSSLogLevelDebug, "flexDirection: 'row-reverse', "); } if (node->style.justifyContent == CSSJustifyCenter) { - gLogger("justifyContent: 'center', "); + CSSLog(CSSLogLevelDebug, "justifyContent: 'center', "); } else if (node->style.justifyContent == CSSJustifyFlexEnd) { - gLogger("justifyContent: 'flex-end', "); + CSSLog(CSSLogLevelDebug, "justifyContent: 'flex-end', "); } else if (node->style.justifyContent == CSSJustifySpaceAround) { - gLogger("justifyContent: 'space-around', "); + CSSLog(CSSLogLevelDebug, "justifyContent: 'space-around', "); } else if (node->style.justifyContent == CSSJustifySpaceBetween) { - gLogger("justifyContent: 'space-between', "); + CSSLog(CSSLogLevelDebug, "justifyContent: 'space-between', "); } if (node->style.alignItems == CSSAlignCenter) { - gLogger("alignItems: 'center', "); + CSSLog(CSSLogLevelDebug, "alignItems: 'center', "); } else if (node->style.alignItems == CSSAlignFlexEnd) { - gLogger("alignItems: 'flex-end', "); + CSSLog(CSSLogLevelDebug, "alignItems: 'flex-end', "); } else if (node->style.alignItems == CSSAlignStretch) { - gLogger("alignItems: 'stretch', "); + CSSLog(CSSLogLevelDebug, "alignItems: 'stretch', "); } if (node->style.alignContent == CSSAlignCenter) { - gLogger("alignContent: 'center', "); + CSSLog(CSSLogLevelDebug, "alignContent: 'center', "); } else if (node->style.alignContent == CSSAlignFlexEnd) { - gLogger("alignContent: 'flex-end', "); + CSSLog(CSSLogLevelDebug, "alignContent: 'flex-end', "); } else if (node->style.alignContent == CSSAlignStretch) { - gLogger("alignContent: 'stretch', "); + CSSLog(CSSLogLevelDebug, "alignContent: 'stretch', "); } if (node->style.alignSelf == CSSAlignFlexStart) { - gLogger("alignSelf: 'flex-start', "); + CSSLog(CSSLogLevelDebug, "alignSelf: 'flex-start', "); } else if (node->style.alignSelf == CSSAlignCenter) { - gLogger("alignSelf: 'center', "); + CSSLog(CSSLogLevelDebug, "alignSelf: 'center', "); } else if (node->style.alignSelf == CSSAlignFlexEnd) { - gLogger("alignSelf: 'flex-end', "); + CSSLog(CSSLogLevelDebug, "alignSelf: 'flex-end', "); } else if (node->style.alignSelf == CSSAlignStretch) { - gLogger("alignSelf: 'stretch', "); + CSSLog(CSSLogLevelDebug, "alignSelf: 'stretch', "); } printNumberIfNotUndefined("flexGrow", CSSNodeStyleGetFlexGrow(node)); @@ -537,11 +564,11 @@ static void _CSSNodePrint(const CSSNodeRef node, printNumberIfNotUndefined("flexBasis", CSSNodeStyleGetFlexBasis(node)); if (node->style.overflow == CSSOverflowHidden) { - gLogger("overflow: 'hidden', "); + CSSLog(CSSLogLevelDebug, "overflow: 'hidden', "); } else if (node->style.overflow == CSSOverflowVisible) { - gLogger("overflow: 'visible', "); + CSSLog(CSSLogLevelDebug, "overflow: 'visible', "); } else if (node->style.overflow == CSSOverflowScroll) { - gLogger("overflow: 'scroll', "); + CSSLog(CSSLogLevelDebug, "overflow: 'scroll', "); } if (eqFour(node->style.margin)) { @@ -590,7 +617,7 @@ static void _CSSNodePrint(const CSSNodeRef node, printNumberIfNotUndefined("minHeight", node->style.minDimensions[CSSDimensionHeight]); if (node->style.positionType == CSSPositionTypeAbsolute) { - gLogger("position: 'absolute', "); + CSSLog(CSSLogLevelDebug, "position: 'absolute', "); } printNumberIfNotUndefined("left", @@ -605,14 +632,14 @@ static void _CSSNodePrint(const CSSNodeRef node, const uint32_t childCount = CSSNodeListCount(node->children); if (options & CSSPrintOptionsChildren && childCount > 0) { - gLogger("children: [\n"); + CSSLog(CSSLogLevelDebug, "children: [\n"); for (uint32_t i = 0; i < childCount; i++) { _CSSNodePrint(CSSNodeGetChild(node, i), options, level + 1); } indent(level); - gLogger("]},\n"); + CSSLog(CSSLogLevelDebug, "]},\n"); } else { - gLogger("},\n"); + CSSLog(CSSLogLevelDebug, "},\n"); } } @@ -2441,6 +2468,13 @@ void CSSLayoutSetLogger(CSSLogger logger) { gLogger = logger; } +void CSSLog(CSSLogLevel level, const char *format, ...) { + va_list args; + va_start(args, format); + gLogger(level, format, args); + va_end(args); +} + #ifdef CSS_ASSERT_FAIL_ENABLED static CSSAssertFailFunc gAssertFailFunc; diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 88272ad7..39f134f2 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -115,6 +115,14 @@ typedef struct CSSSize { float height; } CSSSize; +typedef enum CSSLogLevel { + CSSLogLevelError, + CSSLogLevelWarn, + CSSLogLevelInfo, + CSSLogLevelDebug, + CSSLogLevelVerbose, +} CSSLogLevel; + typedef struct CSSNode *CSSNodeRef; typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float width, @@ -122,7 +130,7 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float height, CSSMeasureMode heightMode); typedef void (*CSSPrintFunc)(CSSNodeRef node); -typedef int (*CSSLogger)(const char *format, ...); +typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args); #ifdef CSS_ASSERT_FAIL_ENABLED typedef void (*CSSAssertFailFunc)(const char *message); @@ -232,6 +240,7 @@ CSS_NODE_LAYOUT_PROPERTY(float, Height); CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); +WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); #ifdef CSS_ASSERT_FAIL_ENABLED // Assert diff --git a/CSSLayout/CSSMacros.h b/CSSLayout/CSSMacros.h index b9b1faad..65e68964 100644 --- a/CSSLayout/CSSMacros.h +++ b/CSSLayout/CSSMacros.h @@ -36,7 +36,7 @@ #if CSS_ASSERT_FAIL_ENABLED #define CSS_ERROR_FUNC(message) CSSAssertFail(message) #else -#define CSS_ERROR_FUNC(message) fprintf(stderr, "%s", message) +#define CSS_ERROR_FUNC(message) CSSLog(CSSLogLevelError, "%s", message) #endif #ifndef CSS_ASSERT From 863378d74efbf7e20791e4b9d006552e44691dae Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Wed, 9 Nov 2016 10:14:22 -0800 Subject: [PATCH 023/108] Sync Logger API Summary: - Sync Logger API with C implementation Reviewed By: emilsjolander Differential Revision: D4143019 fbshipit-source-id: f20203320bad5b8f4b9cce01a5b2e7c615a4d923 --- csharp/CSSLayout/CSSInterop.cpp | 7 ++----- csharp/CSSLayout/CSSInterop.h | 2 +- csharp/Facebook.CSSLayout/CSSLogLevel.cs | 20 ++++++++++++++++++++ csharp/Facebook.CSSLayout/CSSLogger.cs | 6 +++--- csharp/Facebook.CSSLayout/CSSNode.cs | 5 +++-- 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 csharp/Facebook.CSSLayout/CSSLogLevel.cs diff --git a/csharp/CSSLayout/CSSInterop.cpp b/csharp/CSSLayout/CSSInterop.cpp index 56c5597e..679d6544 100644 --- a/csharp/CSSLayout/CSSInterop.cpp +++ b/csharp/CSSLayout/CSSInterop.cpp @@ -11,15 +11,12 @@ static CSSInteropLoggerFunc gManagedFunc; -static int unmanagedLogger(const char *format, ...) { +static int unmanagedLogger(CSSLogLevel level, const char *format, va_list args) { int result = 0; if (gManagedFunc) { - va_list args; - va_start(args, format); char buffer[256]; result = vsnprintf(buffer, sizeof(buffer), format, args); - (*gManagedFunc)(buffer); - va_end(args); + (*gManagedFunc)(level, buffer); } return result; } diff --git a/csharp/CSSLayout/CSSInterop.h b/csharp/CSSLayout/CSSInterop.h index 7533cfd3..bbff6072 100644 --- a/csharp/CSSLayout/CSSInterop.h +++ b/csharp/CSSLayout/CSSInterop.h @@ -13,7 +13,7 @@ CSS_EXTERN_C_BEGIN -typedef void (*CSSInteropLoggerFunc)(const char *message); +typedef void (*CSSInteropLoggerFunc)(CSSLogLevel level, const char *message); WIN_EXPORT void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc); diff --git a/csharp/Facebook.CSSLayout/CSSLogLevel.cs b/csharp/Facebook.CSSLayout/CSSLogLevel.cs new file mode 100644 index 00000000..a0316b8d --- /dev/null +++ b/csharp/Facebook.CSSLayout/CSSLogLevel.cs @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.CSSLayout +{ + public enum CSSLogLevel + { + Error, + Warn, + Info, + Debug, + Verbose, + } +} diff --git a/csharp/Facebook.CSSLayout/CSSLogger.cs b/csharp/Facebook.CSSLayout/CSSLogger.cs index a5a95d0f..c6c4ae37 100644 --- a/csharp/Facebook.CSSLayout/CSSLogger.cs +++ b/csharp/Facebook.CSSLayout/CSSLogger.cs @@ -15,7 +15,7 @@ namespace Facebook.CSSLayout internal static class CSSLogger { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Func(string message); + public delegate void Func(CSSLogLevel level, string message); private static bool _initialized; private static Func _managedLogger = null; @@ -26,10 +26,10 @@ namespace Facebook.CSSLayout { if (!_initialized) { - _managedLogger = (message) => { + _managedLogger = (level, message) => { if (Logger != null) { - Logger(message); + Logger(level, message); } }; Native.CSSInteropSetLogger(_managedLogger); diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index b28114d5..6267001e 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -528,9 +528,10 @@ namespace Facebook.CSSLayout CSSPrintOptions.Layout|CSSPrintOptions.Style|CSSPrintOptions.Children) { StringBuilder sb = new StringBuilder(); - CSSLogger.Logger = (message) => {sb.Append(message);}; + CSSLogger.Func orig = CSSLogger.Logger; + CSSLogger.Logger = (level, message) => {sb.Append(message);}; Native.CSSNodePrint(_cssNode, options); - CSSLogger.Logger = null; + CSSLogger.Logger = orig; return sb.ToString(); } From a253c6fbb7a890ac62932df7e1fb8d11177b1541 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 11:23:21 -0800 Subject: [PATCH 024/108] Dont measure single flex grow+shrink child Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space. This is a re-land of D4147298. I have updated the diff to check explicitly for exact measure mode to also handle at_most case correctly. Reviewed By: gkassabli Differential Revision: D4153133 fbshipit-source-id: 2333150a83857cc30078cc8d52761cbd00652830 --- CSSLayout/CSSLayout.c | 83 ++++++++++++------- .../Facebook.CSSLayout/CSSLayoutFlexTest.cs | 57 +++++++++++++ gentest/fixtures/CSSLayoutFlexTest.html | 6 ++ java/jni/CSSJNI.cpp | 8 +- .../facebook/csslayout/CSSLayoutFlexTest.java | 56 +++++++++++++ tests/CSSLayoutFlexTest.cpp | 55 ++++++++++++ tests/CSSLayoutMeasureCacheTest.cpp | 3 +- tests/CSSLayoutMeasureTest.cpp | 30 ++++++- 8 files changed, 260 insertions(+), 38 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 25ab962f..7b5c3b4a 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -286,7 +286,6 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) { } void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { - // You can always NULLify the measure function of a node. if (measureFunc == NULL) { node->measure = NULL; } else { @@ -301,7 +300,8 @@ CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) { 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."); + CSS_ASSERT(node->measure == NULL, + "Cannot add child: Nodes with measure functions cannot have children."); CSSNodeListInsert(&node->children, child, index); child->parent = node; _CSSNodeMarkDirty(node); @@ -1399,6 +1399,26 @@ static void layoutNodeImpl(const CSSNodeRef node, const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; + // If there is only one child with flexGrow + flexShrink it means we can set the + // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly + // match the remaining space + CSSNodeRef singleFlexChild = NULL; + if ((isMainAxisRow && widthMeasureMode == CSSMeasureModeExactly) || + (!isMainAxisRow && heightMeasureMode == CSSMeasureModeExactly)) { + for (uint32_t i = 0; i < childCount; i++) { + const CSSNodeRef child = CSSNodeGetChild(node, i); + if (singleFlexChild) { + if (isFlex(child)) { + // There is already a flexible child, abort. + singleFlexChild = NULL; + break; + } + } else if (CSSNodeStyleGetFlexGrow(child) > 0 && CSSNodeStyleGetFlexShrink(child) > 0) { + singleFlexChild = child; + } + } + } + // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM for (uint32_t i = 0; i < childCount; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); @@ -1423,13 +1443,17 @@ static void layoutNodeImpl(const CSSNodeRef node, currentAbsoluteChild = child; child->nextChild = NULL; } else { - computeChildFlexBasis(node, - child, - availableInnerWidth, - widthMeasureMode, - availableInnerHeight, - heightMeasureMode, - direction); + if (child == singleFlexChild) { + child->layout.computedFlexBasis = 0; + } else { + computeChildFlexBasis(node, + child, + availableInnerWidth, + widthMeasureMode, + availableInnerHeight, + heightMeasureMode, + direction); + } } } @@ -2165,17 +2189,17 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode } bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, - const float width, - const CSSMeasureMode heightMode, - const float height, - const CSSMeasureMode lastWidthMode, - const float lastWidth, - const CSSMeasureMode lastHeightMode, - const float lastHeight, - const float lastComputedWidth, - const float lastComputedHeight, - const float marginRow, - const float marginColumn) { + const float width, + const CSSMeasureMode heightMode, + const float height, + const CSSMeasureMode lastWidthMode, + const float lastWidth, + const CSSMeasureMode lastHeightMode, + const float lastHeight, + const float lastComputedWidth, + const float lastComputedHeight, + const float marginRow, + const float marginColumn) { if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } @@ -2193,19 +2217,16 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, newMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); - const bool heightIsCompatible = hasSameHeightSpec || - newSizeIsExactAndMatchesOldMeasuredSize(heightMode, - height - marginColumn, - lastComputedHeight) || - oldSizeIsUnspecifiedAndStillFits(heightMode, + const bool heightIsCompatible = + hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, height - marginColumn, - lastHeightMode, lastComputedHeight) || - newMeasureSizeIsStricterAndStillValid(heightMode, - height - marginColumn, - lastHeightMode, - lastHeight, - lastComputedHeight); + oldSizeIsUnspecifiedAndStillFits(heightMode, + height - marginColumn, + lastHeightMode, + lastComputedHeight) || + newMeasureSizeIsStricterAndStillValid( + heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight); return widthIsCompatible && heightIsCompatible; } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs index 90c99330..72042ac2 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -399,5 +405,56 @@ namespace Facebook.CSSLayout Assert.AreEqual(20, root_child2.LayoutHeight); } + [Test] + public void Test_flex_grow_shrink_at_most() + { + CSSNode root = new CSSNode(); + root.StyleWidth = 100; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.FlexGrow = 1; + root_child0_child0.FlexShrink = 1; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(0, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(100, root_child0_child0.LayoutWidth); + Assert.AreEqual(0, root_child0_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(0, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(100, root_child0_child0.LayoutWidth); + Assert.AreEqual(0, root_child0_child0.LayoutHeight); + } + } } diff --git a/gentest/fixtures/CSSLayoutFlexTest.html b/gentest/fixtures/CSSLayoutFlexTest.html index 5689a6e7..30da202e 100644 --- a/gentest/fixtures/CSSLayoutFlexTest.html +++ b/gentest/fixtures/CSSLayoutFlexTest.html @@ -29,3 +29,9 @@
+ +
+
+
+
+
diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index e1c86237..16869f1a 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -40,7 +40,8 @@ static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) { } static void _jniPrint(CSSNodeRef node) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local( + Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); cout << obj->toString() << endl; } @@ -49,10 +50,11 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + auto obj = adopt_local( + Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") - ->getMethod("measure"); + ->getMethod("measure"); _jniTransferLayoutDirection(node, obj); const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java index 5056e307..ccc641c6 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -392,4 +398,54 @@ public class CSSLayoutFlexTest { assertEquals(20, root_child2.getLayoutHeight(), 0.0f); } + @Test + public void test_flex_grow_shrink_at_most() { + final CSSNode root = new CSSNode(); + root.setStyleWidth(100); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); + } + } diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index 7a5c76e7..65991c06 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -41,6 +41,12 @@
+ +
+
+
+
+
* */ @@ -381,3 +387,52 @@ TEST(CSSLayoutTest, flex_basis_overrides_main_size) { CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, flex_grow_shrink_at_most) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeFreeRecursive(root); +} diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index c0a8e6fa..9378b579 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -17,7 +17,8 @@ static CSSSize _measureMax(CSSNodeRef node, CSSMeasureMode heightMode) { int *measureCount = (int *)CSSNodeGetContext(node); - *measureCount = *measureCount + 1; + (*measureCount)++; + return CSSSize { .width = widthMode == CSSMeasureModeUndefined ? 10 : width, .height = heightMode == CSSMeasureModeUndefined ? 10 : height, diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index cfed9363..e31063c2 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -10,18 +10,42 @@ #include #include -#if GTEST_HAS_DEATH_TEST static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { + int *measureCount = (int*) CSSNodeGetContext(node); + if (measureCount) { + (*measureCount)++; + } + return CSSSize { - .width = 0, - .height = 0, + .width = 10, + .height = 10, }; } +TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, measureCount); +} + +#if GTEST_HAS_DEATH_TEST TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root = CSSNodeNew(); CSSNodeSetMeasureFunc(root, _measure); From f5912a97e4884407bb2132c23e222188520ab747 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 11:31:22 -0800 Subject: [PATCH 025/108] Fix issues with running test in open source Summary: Travis builds have been broken for a while. This diff fixes some of the issues surrounding bad buck file configuration as well as missing jni.h file. Reviewed By: astreet Differential Revision: D4148724 fbshipit-source-id: 1e284db61280326a4bcbb9337e804a4804348aa6 --- CSSLAYOUT_DEFS | 4 +- java/BUCK | 11 +- lib/fb/BUCK | 3 +- lib/jni/BUCK | 17 + lib/jni/jni.h | 16 + lib/jni/real/jni.h | 1141 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1186 insertions(+), 6 deletions(-) create mode 100644 lib/jni/BUCK create mode 100644 lib/jni/jni.h create mode 100644 lib/jni/real/jni.h diff --git a/CSSLAYOUT_DEFS b/CSSLAYOUT_DEFS index c73f54ff..5937d48a 100644 --- a/CSSLAYOUT_DEFS +++ b/CSSLAYOUT_DEFS @@ -7,7 +7,9 @@ PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotat SOLOADER_TARGET = '//lib/soloader:soloader' GTEST_TARGET = '//lib/gtest:gtest' GTEST_DL_URL = 'https://github.com/google/googletest/archive/release-1.7.0.zip' -JNI_DEPS = ['//lib/fb:fbjni'] + +JNI_TARGET = '//lib/jni:jni' +FBJNI_TARGET = '//lib/fb:fbjni' CXX_LIBRARY_WHITELIST = [ '//lib/fb:fbjni', diff --git a/java/BUCK b/java/BUCK index 67c1217e..25f55852 100644 --- a/java/BUCK +++ b/java/BUCK @@ -20,7 +20,9 @@ cxx_library( '-O3', '-std=c++11', ], - deps = JNI_DEPS + [ + deps = [ + FBJNI_TARGET, + JNI_TARGET, csslayout_dep(':CSSLayout'), ], visibility = ['PUBLIC'], @@ -30,7 +32,7 @@ java_library( name = 'java', srcs = glob(['com/facebook/csslayout/*.java']), tests=[ - csslayout_dep('/java:tests'), + csslayout_dep('java:tests'), ], source = '1.7', target = '1.7', @@ -47,10 +49,11 @@ java_library( java_test( name = 'tests', srcs = glob(['tests/**/*.java']), + use_cxx_libraries = True, + cxx_library_whitelist = CXX_LIBRARY_WHITELIST, deps = [ ':java', JUNIT_TARGET, ], - use_cxx_libraries = True, - cxx_library_whitelist = CXX_LIBRARY_WHITELIST, + visibility = ['PUBLIC'], ) diff --git a/lib/fb/BUCK b/lib/fb/BUCK index 11779067..ea3fa8c3 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -34,8 +34,9 @@ cxx_library( '-Wno-unused-parameter', '-std=c++11', ], - deps = JNI_DEPS + [ + deps = [ ':ndklog', + JNI_TARGET, ], visibility = ['PUBLIC'], ) diff --git a/lib/jni/BUCK b/lib/jni/BUCK new file mode 100644 index 00000000..5a8808ff --- /dev/null +++ b/lib/jni/BUCK @@ -0,0 +1,17 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +cxx_library( + name = 'jni', + force_static = True, + header_namespace = '', + exported_headers = [ + 'jni.h', + 'real/jni.h', + ], + visibility = ['PUBLIC'], +) diff --git a/lib/jni/jni.h b/lib/jni/jni.h new file mode 100644 index 00000000..d768a112 --- /dev/null +++ b/lib/jni/jni.h @@ -0,0 +1,16 @@ +/** + * 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 + +#ifdef __ANDROID__ +#include_next +#else +#include "real/jni.h" +#endif diff --git a/lib/jni/real/jni.h b/lib/jni/real/jni.h new file mode 100644 index 00000000..1c2fb0cd --- /dev/null +++ b/lib/jni/real/jni.h @@ -0,0 +1,1141 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * JNI specification, as defined by Sun: + * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html + * + * Everything here is expected to be VM-neutral. + */ + +#ifndef JNI_H_ +#define JNI_H_ + +#include +#include + +/* Primitive types that match up with Java equivalents. */ +typedef uint8_t jboolean; /* unsigned 8 bits */ +typedef int8_t jbyte; /* signed 8 bits */ +typedef uint16_t jchar; /* unsigned 16 bits */ +typedef int16_t jshort; /* signed 16 bits */ +typedef int32_t jint; /* signed 32 bits */ +typedef int64_t jlong; /* signed 64 bits */ +typedef float jfloat; /* 32-bit IEEE 754 */ +typedef double jdouble; /* 64-bit IEEE 754 */ + +/* "cardinal indices and sizes" */ +typedef jint jsize; + +#ifdef __cplusplus +/* + * Reference types, in C++ + */ +class _jobject {}; +class _jclass : public _jobject {}; +class _jstring : public _jobject {}; +class _jarray : public _jobject {}; +class _jobjectArray : public _jarray {}; +class _jbooleanArray : public _jarray {}; +class _jbyteArray : public _jarray {}; +class _jcharArray : public _jarray {}; +class _jshortArray : public _jarray {}; +class _jintArray : public _jarray {}; +class _jlongArray : public _jarray {}; +class _jfloatArray : public _jarray {}; +class _jdoubleArray : public _jarray {}; +class _jthrowable : public _jobject {}; + +typedef _jobject* jobject; +typedef _jclass* jclass; +typedef _jstring* jstring; +typedef _jarray* jarray; +typedef _jobjectArray* jobjectArray; +typedef _jbooleanArray* jbooleanArray; +typedef _jbyteArray* jbyteArray; +typedef _jcharArray* jcharArray; +typedef _jshortArray* jshortArray; +typedef _jintArray* jintArray; +typedef _jlongArray* jlongArray; +typedef _jfloatArray* jfloatArray; +typedef _jdoubleArray* jdoubleArray; +typedef _jthrowable* jthrowable; +typedef _jobject* jweak; + + +#else /* not __cplusplus */ + +/* + * Reference types, in C. + */ +typedef void* jobject; +typedef jobject jclass; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jobjectArray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jobject jthrowable; +typedef jobject jweak; + +#endif /* not __cplusplus */ + +struct _jfieldID; /* opaque structure */ +typedef struct _jfieldID* jfieldID; /* field IDs */ + +struct _jmethodID; /* opaque structure */ +typedef struct _jmethodID* jmethodID; /* method IDs */ + +struct JNIInvokeInterface; + +typedef union jvalue { + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; +} jvalue; + +typedef enum jobjectRefType { + JNIInvalidRefType = 0, + JNILocalRefType = 1, + JNIGlobalRefType = 2, + JNIWeakGlobalRefType = 3 +} jobjectRefType; + +typedef struct { + const char* name; + const char* signature; + void* fnPtr; +} JNINativeMethod; + +struct _JNIEnv; +struct _JavaVM; +typedef const struct JNINativeInterface* C_JNIEnv; + +#if defined(__cplusplus) +typedef _JNIEnv JNIEnv; +typedef _JavaVM JavaVM; +#else +typedef const struct JNINativeInterface* JNIEnv; +typedef const struct JNIInvokeInterface* JavaVM; +#endif + +/* + * Table of interface function pointers. + */ +struct JNINativeInterface { + void* reserved0; + void* reserved1; + void* reserved2; + void* reserved3; + + jint (*GetVersion)(JNIEnv *); + + jclass (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*, + jsize); + jclass (*FindClass)(JNIEnv*, const char*); + + jmethodID (*FromReflectedMethod)(JNIEnv*, jobject); + jfieldID (*FromReflectedField)(JNIEnv*, jobject); + /* spec doesn't show jboolean parameter */ + jobject (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean); + + jclass (*GetSuperclass)(JNIEnv*, jclass); + jboolean (*IsAssignableFrom)(JNIEnv*, jclass, jclass); + + /* spec doesn't show jboolean parameter */ + jobject (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean); + + jint (*Throw)(JNIEnv*, jthrowable); + jint (*ThrowNew)(JNIEnv *, jclass, const char *); + jthrowable (*ExceptionOccurred)(JNIEnv*); + void (*ExceptionDescribe)(JNIEnv*); + void (*ExceptionClear)(JNIEnv*); + void (*FatalError)(JNIEnv*, const char*); + + jint (*PushLocalFrame)(JNIEnv*, jint); + jobject (*PopLocalFrame)(JNIEnv*, jobject); + + jobject (*NewGlobalRef)(JNIEnv*, jobject); + void (*DeleteGlobalRef)(JNIEnv*, jobject); + void (*DeleteLocalRef)(JNIEnv*, jobject); + jboolean (*IsSameObject)(JNIEnv*, jobject, jobject); + + jobject (*NewLocalRef)(JNIEnv*, jobject); + jint (*EnsureLocalCapacity)(JNIEnv*, jint); + + jobject (*AllocObject)(JNIEnv*, jclass); + jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...); + jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); + jobject (*NewObjectA)(JNIEnv*, jclass, jmethodID, jvalue*); + + jclass (*GetObjectClass)(JNIEnv*, jobject); + jboolean (*IsInstanceOf)(JNIEnv*, jobject, jclass); + jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*); + + jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); + jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jobject (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); + jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jboolean (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); + jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jbyte (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); + jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jchar (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); + jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jshort (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); + jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jint (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); + jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jlong (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); + jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jfloat (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); + jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); + jdouble (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); + void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); + void (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); + + jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jobject (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jbyte (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jchar (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jshort (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jint (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jlong (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jfloat (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, + jmethodID, ...); + void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, + jmethodID, va_list); + void (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass, + jmethodID, jvalue*); + + jfieldID (*GetFieldID)(JNIEnv*, jclass, const char*, const char*); + + jobject (*GetObjectField)(JNIEnv*, jobject, jfieldID); + jboolean (*GetBooleanField)(JNIEnv*, jobject, jfieldID); + jbyte (*GetByteField)(JNIEnv*, jobject, jfieldID); + jchar (*GetCharField)(JNIEnv*, jobject, jfieldID); + jshort (*GetShortField)(JNIEnv*, jobject, jfieldID); + jint (*GetIntField)(JNIEnv*, jobject, jfieldID); + jlong (*GetLongField)(JNIEnv*, jobject, jfieldID); + jfloat (*GetFloatField)(JNIEnv*, jobject, jfieldID); + jdouble (*GetDoubleField)(JNIEnv*, jobject, jfieldID); + + void (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject); + void (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean); + void (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte); + void (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar); + void (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort); + void (*SetIntField)(JNIEnv*, jobject, jfieldID, jint); + void (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong); + void (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat); + void (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble); + + jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*); + + jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); + jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jobject (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); + jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, + va_list); + jboolean (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, + jvalue*); + jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); + jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jbyte (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); + jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jchar (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); + jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jshort (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); + jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jint (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); + jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jlong (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); + jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jfloat (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); + jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); + jdouble (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); + void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); + void (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); + + jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const char*, + const char*); + + jobject (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID); + jboolean (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID); + jbyte (*GetStaticByteField)(JNIEnv*, jclass, jfieldID); + jchar (*GetStaticCharField)(JNIEnv*, jclass, jfieldID); + jshort (*GetStaticShortField)(JNIEnv*, jclass, jfieldID); + jint (*GetStaticIntField)(JNIEnv*, jclass, jfieldID); + jlong (*GetStaticLongField)(JNIEnv*, jclass, jfieldID); + jfloat (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID); + jdouble (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID); + + void (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject); + void (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean); + void (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte); + void (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar); + void (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort); + void (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint); + void (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong); + void (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat); + void (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble); + + jstring (*NewString)(JNIEnv*, const jchar*, jsize); + jsize (*GetStringLength)(JNIEnv*, jstring); + const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*); + void (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*); + jstring (*NewStringUTF)(JNIEnv*, const char*); + jsize (*GetStringUTFLength)(JNIEnv*, jstring); + /* JNI spec says this returns const jbyte*, but that's inconsistent */ + const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*); + void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*); + jsize (*GetArrayLength)(JNIEnv*, jarray); + jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject); + jobject (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize); + void (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject); + + jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize); + jbyteArray (*NewByteArray)(JNIEnv*, jsize); + jcharArray (*NewCharArray)(JNIEnv*, jsize); + jshortArray (*NewShortArray)(JNIEnv*, jsize); + jintArray (*NewIntArray)(JNIEnv*, jsize); + jlongArray (*NewLongArray)(JNIEnv*, jsize); + jfloatArray (*NewFloatArray)(JNIEnv*, jsize); + jdoubleArray (*NewDoubleArray)(JNIEnv*, jsize); + + jboolean* (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*); + jbyte* (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*); + jchar* (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*); + jshort* (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*); + jint* (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*); + jlong* (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*); + jfloat* (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*); + jdouble* (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*); + + void (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray, + jboolean*, jint); + void (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray, + jbyte*, jint); + void (*ReleaseCharArrayElements)(JNIEnv*, jcharArray, + jchar*, jint); + void (*ReleaseShortArrayElements)(JNIEnv*, jshortArray, + jshort*, jint); + void (*ReleaseIntArrayElements)(JNIEnv*, jintArray, + jint*, jint); + void (*ReleaseLongArrayElements)(JNIEnv*, jlongArray, + jlong*, jint); + void (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray, + jfloat*, jint); + void (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray, + jdouble*, jint); + + void (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray, + jsize, jsize, jboolean*); + void (*GetByteArrayRegion)(JNIEnv*, jbyteArray, + jsize, jsize, jbyte*); + void (*GetCharArrayRegion)(JNIEnv*, jcharArray, + jsize, jsize, jchar*); + void (*GetShortArrayRegion)(JNIEnv*, jshortArray, + jsize, jsize, jshort*); + void (*GetIntArrayRegion)(JNIEnv*, jintArray, + jsize, jsize, jint*); + void (*GetLongArrayRegion)(JNIEnv*, jlongArray, + jsize, jsize, jlong*); + void (*GetFloatArrayRegion)(JNIEnv*, jfloatArray, + jsize, jsize, jfloat*); + void (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray, + jsize, jsize, jdouble*); + + /* spec shows these without const; some jni.h do, some don't */ + void (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray, + jsize, jsize, const jboolean*); + void (*SetByteArrayRegion)(JNIEnv*, jbyteArray, + jsize, jsize, const jbyte*); + void (*SetCharArrayRegion)(JNIEnv*, jcharArray, + jsize, jsize, const jchar*); + void (*SetShortArrayRegion)(JNIEnv*, jshortArray, + jsize, jsize, const jshort*); + void (*SetIntArrayRegion)(JNIEnv*, jintArray, + jsize, jsize, const jint*); + void (*SetLongArrayRegion)(JNIEnv*, jlongArray, + jsize, jsize, const jlong*); + void (*SetFloatArrayRegion)(JNIEnv*, jfloatArray, + jsize, jsize, const jfloat*); + void (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray, + jsize, jsize, const jdouble*); + + jint (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*, + jint); + jint (*UnregisterNatives)(JNIEnv*, jclass); + jint (*MonitorEnter)(JNIEnv*, jobject); + jint (*MonitorExit)(JNIEnv*, jobject); + jint (*GetJavaVM)(JNIEnv*, JavaVM**); + + void (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*); + void (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*); + + void* (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*); + void (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint); + + const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*); + void (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*); + + jweak (*NewWeakGlobalRef)(JNIEnv*, jobject); + void (*DeleteWeakGlobalRef)(JNIEnv*, jweak); + + jboolean (*ExceptionCheck)(JNIEnv*); + + jobject (*NewDirectByteBuffer)(JNIEnv*, void*, jlong); + void* (*GetDirectBufferAddress)(JNIEnv*, jobject); + jlong (*GetDirectBufferCapacity)(JNIEnv*, jobject); + + /* added in JNI 1.6 */ + jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject); +}; + +/* + * C++ object wrapper. + * + * This is usually overlaid on a C struct whose first element is a + * JNINativeInterface*. We rely somewhat on compiler behavior. + */ +struct _JNIEnv { + /* do not rename this; it does not seem to be entirely opaque */ + const struct JNINativeInterface* functions; + +#if defined(__cplusplus) + + jint GetVersion() + { return functions->GetVersion(this); } + + jclass DefineClass(const char *name, jobject loader, const jbyte* buf, + jsize bufLen) + { return functions->DefineClass(this, name, loader, buf, bufLen); } + + jclass FindClass(const char* name) + { return functions->FindClass(this, name); } + + jmethodID FromReflectedMethod(jobject method) + { return functions->FromReflectedMethod(this, method); } + + jfieldID FromReflectedField(jobject field) + { return functions->FromReflectedField(this, field); } + + jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) + { return functions->ToReflectedMethod(this, cls, methodID, isStatic); } + + jclass GetSuperclass(jclass clazz) + { return functions->GetSuperclass(this, clazz); } + + jboolean IsAssignableFrom(jclass clazz1, jclass clazz2) + { return functions->IsAssignableFrom(this, clazz1, clazz2); } + + jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) + { return functions->ToReflectedField(this, cls, fieldID, isStatic); } + + jint Throw(jthrowable obj) + { return functions->Throw(this, obj); } + + jint ThrowNew(jclass clazz, const char* message) + { return functions->ThrowNew(this, clazz, message); } + + jthrowable ExceptionOccurred() + { return functions->ExceptionOccurred(this); } + + void ExceptionDescribe() + { functions->ExceptionDescribe(this); } + + void ExceptionClear() + { functions->ExceptionClear(this); } + + void FatalError(const char* msg) + { functions->FatalError(this, msg); } + + jint PushLocalFrame(jint capacity) + { return functions->PushLocalFrame(this, capacity); } + + jobject PopLocalFrame(jobject result) + { return functions->PopLocalFrame(this, result); } + + jobject NewGlobalRef(jobject obj) + { return functions->NewGlobalRef(this, obj); } + + void DeleteGlobalRef(jobject globalRef) + { functions->DeleteGlobalRef(this, globalRef); } + + void DeleteLocalRef(jobject localRef) + { functions->DeleteLocalRef(this, localRef); } + + jboolean IsSameObject(jobject ref1, jobject ref2) + { return functions->IsSameObject(this, ref1, ref2); } + + jobject NewLocalRef(jobject ref) + { return functions->NewLocalRef(this, ref); } + + jint EnsureLocalCapacity(jint capacity) + { return functions->EnsureLocalCapacity(this, capacity); } + + jobject AllocObject(jclass clazz) + { return functions->AllocObject(this, clazz); } + + jobject NewObject(jclass clazz, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + jobject result = functions->NewObjectV(this, clazz, methodID, args); + va_end(args); + return result; + } + + jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args) + { return functions->NewObjectV(this, clazz, methodID, args); } + + jobject NewObjectA(jclass clazz, jmethodID methodID, jvalue* args) + { return functions->NewObjectA(this, clazz, methodID, args); } + + jclass GetObjectClass(jobject obj) + { return functions->GetObjectClass(this, obj); } + + jboolean IsInstanceOf(jobject obj, jclass clazz) + { return functions->IsInstanceOf(this, obj, clazz); } + + jmethodID GetMethodID(jclass clazz, const char* name, const char* sig) + { return functions->GetMethodID(this, clazz, name, sig); } + +#define CALL_TYPE_METHOD(_jtype, _jname) \ + _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->Call##_jname##MethodV(this, obj, methodID, \ + args); \ + va_end(args); \ + return result; \ + } +#define CALL_TYPE_METHODV(_jtype, _jname) \ + _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \ + va_list args) \ + { return functions->Call##_jname##MethodV(this, obj, methodID, args); } +#define CALL_TYPE_METHODA(_jtype, _jname) \ + _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \ + jvalue* args) \ + { return functions->Call##_jname##MethodA(this, obj, methodID, args); } + +#define CALL_TYPE(_jtype, _jname) \ + CALL_TYPE_METHOD(_jtype, _jname) \ + CALL_TYPE_METHODV(_jtype, _jname) \ + CALL_TYPE_METHODA(_jtype, _jname) + + CALL_TYPE(jobject, Object) + CALL_TYPE(jboolean, Boolean) + CALL_TYPE(jbyte, Byte) + CALL_TYPE(jchar, Char) + CALL_TYPE(jshort, Short) + CALL_TYPE(jint, Int) + CALL_TYPE(jlong, Long) + CALL_TYPE(jfloat, Float) + CALL_TYPE(jdouble, Double) + + void CallVoidMethod(jobject obj, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallVoidMethodV(this, obj, methodID, args); + va_end(args); + } + void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args) + { functions->CallVoidMethodV(this, obj, methodID, args); } + void CallVoidMethodA(jobject obj, jmethodID methodID, jvalue* args) + { functions->CallVoidMethodA(this, obj, methodID, args); } + +#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \ + jmethodID methodID, ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallNonvirtual##_jname##MethodV(this, obj, \ + clazz, methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \ + jmethodID methodID, va_list args) \ + { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \ + methodID, args); } +#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \ + _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \ + jmethodID methodID, jvalue* args) \ + { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \ + methodID, args); } + +#define CALL_NONVIRT_TYPE(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ + CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) + + CALL_NONVIRT_TYPE(jobject, Object) + CALL_NONVIRT_TYPE(jboolean, Boolean) + CALL_NONVIRT_TYPE(jbyte, Byte) + CALL_NONVIRT_TYPE(jchar, Char) + CALL_NONVIRT_TYPE(jshort, Short) + CALL_NONVIRT_TYPE(jint, Int) + CALL_NONVIRT_TYPE(jlong, Long) + CALL_NONVIRT_TYPE(jfloat, Float) + CALL_NONVIRT_TYPE(jdouble, Double) + + void CallNonvirtualVoidMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); + va_end(args); + } + void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) + { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); } + void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue* args) + { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); } + + jfieldID GetFieldID(jclass clazz, const char* name, const char* sig) + { return functions->GetFieldID(this, clazz, name, sig); } + + jobject GetObjectField(jobject obj, jfieldID fieldID) + { return functions->GetObjectField(this, obj, fieldID); } + jboolean GetBooleanField(jobject obj, jfieldID fieldID) + { return functions->GetBooleanField(this, obj, fieldID); } + jbyte GetByteField(jobject obj, jfieldID fieldID) + { return functions->GetByteField(this, obj, fieldID); } + jchar GetCharField(jobject obj, jfieldID fieldID) + { return functions->GetCharField(this, obj, fieldID); } + jshort GetShortField(jobject obj, jfieldID fieldID) + { return functions->GetShortField(this, obj, fieldID); } + jint GetIntField(jobject obj, jfieldID fieldID) + { return functions->GetIntField(this, obj, fieldID); } + jlong GetLongField(jobject obj, jfieldID fieldID) + { return functions->GetLongField(this, obj, fieldID); } + jfloat GetFloatField(jobject obj, jfieldID fieldID) + { return functions->GetFloatField(this, obj, fieldID); } + jdouble GetDoubleField(jobject obj, jfieldID fieldID) + { return functions->GetDoubleField(this, obj, fieldID); } + + void SetObjectField(jobject obj, jfieldID fieldID, jobject value) + { functions->SetObjectField(this, obj, fieldID, value); } + void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value) + { functions->SetBooleanField(this, obj, fieldID, value); } + void SetByteField(jobject obj, jfieldID fieldID, jbyte value) + { functions->SetByteField(this, obj, fieldID, value); } + void SetCharField(jobject obj, jfieldID fieldID, jchar value) + { functions->SetCharField(this, obj, fieldID, value); } + void SetShortField(jobject obj, jfieldID fieldID, jshort value) + { functions->SetShortField(this, obj, fieldID, value); } + void SetIntField(jobject obj, jfieldID fieldID, jint value) + { functions->SetIntField(this, obj, fieldID, value); } + void SetLongField(jobject obj, jfieldID fieldID, jlong value) + { functions->SetLongField(this, obj, fieldID, value); } + void SetFloatField(jobject obj, jfieldID fieldID, jfloat value) + { functions->SetFloatField(this, obj, fieldID, value); } + void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value) + { functions->SetDoubleField(this, obj, fieldID, value); } + + jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig) + { return functions->GetStaticMethodID(this, clazz, name, sig); } + +#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \ + ...) \ + { \ + _jtype result; \ + va_list args; \ + va_start(args, methodID); \ + result = functions->CallStatic##_jname##MethodV(this, clazz, \ + methodID, args); \ + va_end(args); \ + return result; \ + } +#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \ + va_list args) \ + { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \ + args); } +#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \ + _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \ + jvalue* args) \ + { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \ + args); } + +#define CALL_STATIC_TYPE(_jtype, _jname) \ + CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ + CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ + CALL_STATIC_TYPE_METHODA(_jtype, _jname) + + CALL_STATIC_TYPE(jobject, Object) + CALL_STATIC_TYPE(jboolean, Boolean) + CALL_STATIC_TYPE(jbyte, Byte) + CALL_STATIC_TYPE(jchar, Char) + CALL_STATIC_TYPE(jshort, Short) + CALL_STATIC_TYPE(jint, Int) + CALL_STATIC_TYPE(jlong, Long) + CALL_STATIC_TYPE(jfloat, Float) + CALL_STATIC_TYPE(jdouble, Double) + + void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...) + { + va_list args; + va_start(args, methodID); + functions->CallStaticVoidMethodV(this, clazz, methodID, args); + va_end(args); + } + void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args) + { functions->CallStaticVoidMethodV(this, clazz, methodID, args); } + void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, jvalue* args) + { functions->CallStaticVoidMethodA(this, clazz, methodID, args); } + + jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig) + { return functions->GetStaticFieldID(this, clazz, name, sig); } + + jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticObjectField(this, clazz, fieldID); } + jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticBooleanField(this, clazz, fieldID); } + jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticByteField(this, clazz, fieldID); } + jchar GetStaticCharField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticCharField(this, clazz, fieldID); } + jshort GetStaticShortField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticShortField(this, clazz, fieldID); } + jint GetStaticIntField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticIntField(this, clazz, fieldID); } + jlong GetStaticLongField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticLongField(this, clazz, fieldID); } + jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticFloatField(this, clazz, fieldID); } + jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) + { return functions->GetStaticDoubleField(this, clazz, fieldID); } + + void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value) + { functions->SetStaticObjectField(this, clazz, fieldID, value); } + void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value) + { functions->SetStaticBooleanField(this, clazz, fieldID, value); } + void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value) + { functions->SetStaticByteField(this, clazz, fieldID, value); } + void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value) + { functions->SetStaticCharField(this, clazz, fieldID, value); } + void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value) + { functions->SetStaticShortField(this, clazz, fieldID, value); } + void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value) + { functions->SetStaticIntField(this, clazz, fieldID, value); } + void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value) + { functions->SetStaticLongField(this, clazz, fieldID, value); } + void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value) + { functions->SetStaticFloatField(this, clazz, fieldID, value); } + void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value) + { functions->SetStaticDoubleField(this, clazz, fieldID, value); } + + jstring NewString(const jchar* unicodeChars, jsize len) + { return functions->NewString(this, unicodeChars, len); } + + jsize GetStringLength(jstring string) + { return functions->GetStringLength(this, string); } + + const jchar* GetStringChars(jstring string, jboolean* isCopy) + { return functions->GetStringChars(this, string, isCopy); } + + void ReleaseStringChars(jstring string, const jchar* chars) + { functions->ReleaseStringChars(this, string, chars); } + + jstring NewStringUTF(const char* bytes) + { return functions->NewStringUTF(this, bytes); } + + jsize GetStringUTFLength(jstring string) + { return functions->GetStringUTFLength(this, string); } + + const char* GetStringUTFChars(jstring string, jboolean* isCopy) + { return functions->GetStringUTFChars(this, string, isCopy); } + + void ReleaseStringUTFChars(jstring string, const char* utf) + { functions->ReleaseStringUTFChars(this, string, utf); } + + jsize GetArrayLength(jarray array) + { return functions->GetArrayLength(this, array); } + + jobjectArray NewObjectArray(jsize length, jclass elementClass, + jobject initialElement) + { return functions->NewObjectArray(this, length, elementClass, + initialElement); } + + jobject GetObjectArrayElement(jobjectArray array, jsize index) + { return functions->GetObjectArrayElement(this, array, index); } + + void SetObjectArrayElement(jobjectArray array, jsize index, jobject value) + { functions->SetObjectArrayElement(this, array, index, value); } + + jbooleanArray NewBooleanArray(jsize length) + { return functions->NewBooleanArray(this, length); } + jbyteArray NewByteArray(jsize length) + { return functions->NewByteArray(this, length); } + jcharArray NewCharArray(jsize length) + { return functions->NewCharArray(this, length); } + jshortArray NewShortArray(jsize length) + { return functions->NewShortArray(this, length); } + jintArray NewIntArray(jsize length) + { return functions->NewIntArray(this, length); } + jlongArray NewLongArray(jsize length) + { return functions->NewLongArray(this, length); } + jfloatArray NewFloatArray(jsize length) + { return functions->NewFloatArray(this, length); } + jdoubleArray NewDoubleArray(jsize length) + { return functions->NewDoubleArray(this, length); } + + jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy) + { return functions->GetBooleanArrayElements(this, array, isCopy); } + jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy) + { return functions->GetByteArrayElements(this, array, isCopy); } + jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy) + { return functions->GetCharArrayElements(this, array, isCopy); } + jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy) + { return functions->GetShortArrayElements(this, array, isCopy); } + jint* GetIntArrayElements(jintArray array, jboolean* isCopy) + { return functions->GetIntArrayElements(this, array, isCopy); } + jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy) + { return functions->GetLongArrayElements(this, array, isCopy); } + jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy) + { return functions->GetFloatArrayElements(this, array, isCopy); } + jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy) + { return functions->GetDoubleArrayElements(this, array, isCopy); } + + void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems, + jint mode) + { functions->ReleaseBooleanArrayElements(this, array, elems, mode); } + void ReleaseByteArrayElements(jbyteArray array, jbyte* elems, + jint mode) + { functions->ReleaseByteArrayElements(this, array, elems, mode); } + void ReleaseCharArrayElements(jcharArray array, jchar* elems, + jint mode) + { functions->ReleaseCharArrayElements(this, array, elems, mode); } + void ReleaseShortArrayElements(jshortArray array, jshort* elems, + jint mode) + { functions->ReleaseShortArrayElements(this, array, elems, mode); } + void ReleaseIntArrayElements(jintArray array, jint* elems, + jint mode) + { functions->ReleaseIntArrayElements(this, array, elems, mode); } + void ReleaseLongArrayElements(jlongArray array, jlong* elems, + jint mode) + { functions->ReleaseLongArrayElements(this, array, elems, mode); } + void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems, + jint mode) + { functions->ReleaseFloatArrayElements(this, array, elems, mode); } + void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems, + jint mode) + { functions->ReleaseDoubleArrayElements(this, array, elems, mode); } + + void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + jboolean* buf) + { functions->GetBooleanArrayRegion(this, array, start, len, buf); } + void GetByteArrayRegion(jbyteArray array, jsize start, jsize len, + jbyte* buf) + { functions->GetByteArrayRegion(this, array, start, len, buf); } + void GetCharArrayRegion(jcharArray array, jsize start, jsize len, + jchar* buf) + { functions->GetCharArrayRegion(this, array, start, len, buf); } + void GetShortArrayRegion(jshortArray array, jsize start, jsize len, + jshort* buf) + { functions->GetShortArrayRegion(this, array, start, len, buf); } + void GetIntArrayRegion(jintArray array, jsize start, jsize len, + jint* buf) + { functions->GetIntArrayRegion(this, array, start, len, buf); } + void GetLongArrayRegion(jlongArray array, jsize start, jsize len, + jlong* buf) + { functions->GetLongArrayRegion(this, array, start, len, buf); } + void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + jfloat* buf) + { functions->GetFloatArrayRegion(this, array, start, len, buf); } + void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + jdouble* buf) + { functions->GetDoubleArrayRegion(this, array, start, len, buf); } + + void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + const jboolean* buf) + { functions->SetBooleanArrayRegion(this, array, start, len, buf); } + void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, + const jbyte* buf) + { functions->SetByteArrayRegion(this, array, start, len, buf); } + void SetCharArrayRegion(jcharArray array, jsize start, jsize len, + const jchar* buf) + { functions->SetCharArrayRegion(this, array, start, len, buf); } + void SetShortArrayRegion(jshortArray array, jsize start, jsize len, + const jshort* buf) + { functions->SetShortArrayRegion(this, array, start, len, buf); } + void SetIntArrayRegion(jintArray array, jsize start, jsize len, + const jint* buf) + { functions->SetIntArrayRegion(this, array, start, len, buf); } + void SetLongArrayRegion(jlongArray array, jsize start, jsize len, + const jlong* buf) + { functions->SetLongArrayRegion(this, array, start, len, buf); } + void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + const jfloat* buf) + { functions->SetFloatArrayRegion(this, array, start, len, buf); } + void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + const jdouble* buf) + { functions->SetDoubleArrayRegion(this, array, start, len, buf); } + + jint RegisterNatives(jclass clazz, const JNINativeMethod* methods, + jint nMethods) + { return functions->RegisterNatives(this, clazz, methods, nMethods); } + + jint UnregisterNatives(jclass clazz) + { return functions->UnregisterNatives(this, clazz); } + + jint MonitorEnter(jobject obj) + { return functions->MonitorEnter(this, obj); } + + jint MonitorExit(jobject obj) + { return functions->MonitorExit(this, obj); } + + jint GetJavaVM(JavaVM** vm) + { return functions->GetJavaVM(this, vm); } + + void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf) + { functions->GetStringRegion(this, str, start, len, buf); } + + void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf) + { return functions->GetStringUTFRegion(this, str, start, len, buf); } + + void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy) + { return functions->GetPrimitiveArrayCritical(this, array, isCopy); } + + void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode) + { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); } + + const jchar* GetStringCritical(jstring string, jboolean* isCopy) + { return functions->GetStringCritical(this, string, isCopy); } + + void ReleaseStringCritical(jstring string, const jchar* carray) + { functions->ReleaseStringCritical(this, string, carray); } + + jweak NewWeakGlobalRef(jobject obj) + { return functions->NewWeakGlobalRef(this, obj); } + + void DeleteWeakGlobalRef(jweak obj) + { functions->DeleteWeakGlobalRef(this, obj); } + + jboolean ExceptionCheck() + { return functions->ExceptionCheck(this); } + + jobject NewDirectByteBuffer(void* address, jlong capacity) + { return functions->NewDirectByteBuffer(this, address, capacity); } + + void* GetDirectBufferAddress(jobject buf) + { return functions->GetDirectBufferAddress(this, buf); } + + jlong GetDirectBufferCapacity(jobject buf) + { return functions->GetDirectBufferCapacity(this, buf); } + + /* added in JNI 1.6 */ + jobjectRefType GetObjectRefType(jobject obj) + { return functions->GetObjectRefType(this, obj); } +#endif /*__cplusplus*/ +}; + + +/* + * JNI invocation interface. + */ +struct JNIInvokeInterface { + void* reserved0; + void* reserved1; + void* reserved2; + + jint (*DestroyJavaVM)(JavaVM*); + jint (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*); + jint (*DetachCurrentThread)(JavaVM*); + jint (*GetEnv)(JavaVM*, void**, jint); + jint (*AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*); +}; + +/* + * C++ version. + */ +struct _JavaVM { + const struct JNIInvokeInterface* functions; + +#if defined(__cplusplus) + jint DestroyJavaVM() + { return functions->DestroyJavaVM(this); } + jint AttachCurrentThread(JNIEnv** p_env, void* thr_args) + { return functions->AttachCurrentThread(this, p_env, thr_args); } + jint DetachCurrentThread() + { return functions->DetachCurrentThread(this); } + jint GetEnv(void** env, jint version) + { return functions->GetEnv(this, env, version); } + jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args) + { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); } +#endif /*__cplusplus*/ +}; + +struct JavaVMAttachArgs { + jint version; /* must be >= JNI_VERSION_1_2 */ + const char* name; /* NULL or name of thread as modified UTF-8 str */ + jobject group; /* global ref of a ThreadGroup object, or NULL */ +}; +typedef struct JavaVMAttachArgs JavaVMAttachArgs; + +/* + * JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no + * longer supported.) + */ +typedef struct JavaVMOption { + const char* optionString; + void* extraInfo; +} JavaVMOption; + +typedef struct JavaVMInitArgs { + jint version; /* use JNI_VERSION_1_2 or later */ + + jint nOptions; + JavaVMOption* options; + jboolean ignoreUnrecognized; +} JavaVMInitArgs; + +#ifdef __cplusplus +extern "C" { +#endif +/* + * VM initialization functions. + * + * Note these are the only symbols exported for JNI by the VM. + */ +jint JNI_GetDefaultJavaVMInitArgs(void*); +jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); +jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); + +#define JNIIMPORT +#define JNIEXPORT __attribute__ ((visibility ("default"))) +#define JNICALL + +/* + * Prototypes for functions exported by loadable shared libs. These are + * called by JNI, not provided by JNI. + */ +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved); +JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved); + +#ifdef __cplusplus +} +#endif + + +/* + * Manifest constants. + */ +#define JNI_FALSE 0 +#define JNI_TRUE 1 + +#define JNI_VERSION_1_1 0x00010001 +#define JNI_VERSION_1_2 0x00010002 +#define JNI_VERSION_1_4 0x00010004 +#define JNI_VERSION_1_6 0x00010006 + +#define JNI_OK (0) /* no error */ +#define JNI_ERR (-1) /* generic error */ +#define JNI_EDETACHED (-2) /* thread detached from the VM */ +#define JNI_EVERSION (-3) /* JNI version error */ + +#define JNI_COMMIT 1 /* copy content, do not free buffer */ +#define JNI_ABORT 2 /* free buffer w/o copying back */ + +#endif /* JNI_H_ */ From ff602d4606d1af2c571e4d241dd750adeff13560 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 11:45:18 -0800 Subject: [PATCH 026/108] Absolute positioned items should apear inside padding but outside border Summary: Absolute positioned elements were not correctly respecting border / padding. https://github.com/facebook/css-layout/issues/245 fixes #245 Reviewed By: gkassabli Differential Revision: D4153332 fbshipit-source-id: 251e29e02018a433f60349b78c03feb121512797 --- CSSLayout/CSSLayout.c | 16 ++-- .../CSSLayoutAbsolutePositionTest.cs | 76 +++++++++++++++++++ .../CSSLayoutAbsolutePositionTest.html | 5 ++ .../CSSLayoutAbsolutePositionTest.java | 75 ++++++++++++++++++ tests/CSSLayoutAbsolutePositionTest.cpp | 74 ++++++++++++++++++ 5 files changed, 239 insertions(+), 7 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 7b5c3b4a..e8e4d21c 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1115,12 +1115,14 @@ static void absoluteLayoutChild(const CSSNodeRef node, if (isTrailingPosDefined(child, mainAxis) && !isLeadingPosDefined(child, mainAxis)) { child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] - child->layout.measuredDimensions[dim[mainAxis]] - + getTrailingBorder(node, mainAxis) - getTrailingPosition(child, mainAxis); } if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) { child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - + getTrailingBorder(node, crossAxis) - getTrailingPosition(child, crossAxis); } } @@ -1830,16 +1832,14 @@ static void layoutNodeImpl(const CSSNodeRef node, getLeadingMargin(child, mainAxis); } } else { - if (performLayout) { - // If the child is position absolute (without top/left) or relative, - // we put it at the current accumulated offset. - child->layout.position[pos[mainAxis]] += mainDim; - } - // Now that we placed the element, we need to update the variables. // We need to do that only for relative elements. Absolute elements // do not take part in that phase. if (child->style.positionType == CSSPositionTypeRelative) { + if (performLayout) { + child->layout.position[pos[mainAxis]] += mainDim; + } + if (canSkipFlex) { // If we skipped the flex step, then we can't rely on the // measuredDims because @@ -1857,6 +1857,8 @@ static void layoutNodeImpl(const CSSNodeRef node, // can only be one element in that cross dimension. crossDim = fmaxf(crossDim, getDimWithMargin(child, crossAxis)); } + } else if (performLayout) { + child->layout.position[pos[mainAxis]] += getLeadingBorder(node, mainAxis) + leadingMainDim; } } } @@ -1901,7 +1903,7 @@ static void layoutNodeImpl(const CSSNodeRef node, getLeadingMargin(child, crossAxis); } else { child->layout.position[pos[crossAxis]] = - leadingPaddingAndBorderCross + getLeadingMargin(child, crossAxis); + getLeadingBorder(node, crossAxis) + getLeadingMargin(child, crossAxis); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index b5ee81a3..c1884387 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -31,6 +31,11 @@
+ +
+
+
+
* */ @@ -264,5 +269,76 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0_child0.LayoutHeight); } + [Test] + public void Test_absolute_layout_within_border() + { + CSSNode root = new CSSNode(); + root.SetMargin(CSSEdge.Left, 10); + root.SetMargin(CSSEdge.Top, 10); + root.SetMargin(CSSEdge.Right, 10); + root.SetMargin(CSSEdge.Bottom, 10); + root.SetPadding(CSSEdge.Left, 10); + root.SetPadding(CSSEdge.Top, 10); + root.SetPadding(CSSEdge.Right, 10); + root.SetPadding(CSSEdge.Bottom, 10); + root.SetBorder(CSSEdge.Left, 10); + root.SetBorder(CSSEdge.Top, 10); + root.SetBorder(CSSEdge.Right, 10); + root.SetBorder(CSSEdge.Bottom, 10); + root.StyleWidth = 100; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root_child0.PositionType = CSSPositionType.Absolute; + root_child0.SetPosition(CSSEdge.Left, 0); + root_child0.SetPosition(CSSEdge.Top, 0); + root_child0.StyleWidth = 50; + root_child0.StyleHeight = 50; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.PositionType = CSSPositionType.Absolute; + root_child1.SetPosition(CSSEdge.Right, 0); + root_child1.SetPosition(CSSEdge.Bottom, 0); + root_child1.StyleWidth = 50; + root_child1.StyleHeight = 50; + root.Insert(1, root_child1); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(10, root.LayoutX); + Assert.AreEqual(10, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(10, root_child0.LayoutX); + Assert.AreEqual(10, root_child0.LayoutY); + Assert.AreEqual(50, root_child0.LayoutWidth); + Assert.AreEqual(50, root_child0.LayoutHeight); + + Assert.AreEqual(40, root_child1.LayoutX); + Assert.AreEqual(40, root_child1.LayoutY); + Assert.AreEqual(50, root_child1.LayoutWidth); + Assert.AreEqual(50, root_child1.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(10, root.LayoutX); + Assert.AreEqual(10, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(10, root_child0.LayoutX); + Assert.AreEqual(10, root_child0.LayoutY); + Assert.AreEqual(50, root_child0.LayoutWidth); + Assert.AreEqual(50, root_child0.LayoutHeight); + + Assert.AreEqual(40, root_child1.LayoutX); + Assert.AreEqual(40, root_child1.LayoutY); + Assert.AreEqual(50, root_child1.LayoutWidth); + Assert.AreEqual(50, root_child1.LayoutHeight); + } + } } diff --git a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html index 37ebffe8..8530e045 100644 --- a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html +++ b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html @@ -19,3 +19,8 @@
+ +
+
+
+
diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index f3703e70..e4ced9fc 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -31,6 +31,11 @@
+ +
+
+
+
* */ @@ -258,4 +263,74 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_absolute_layout_within_border() { + final CSSNode root = new CSSNode(); + root.setMargin(Spacing.LEFT, 10); + root.setMargin(Spacing.TOP, 10); + root.setMargin(Spacing.RIGHT, 10); + root.setMargin(Spacing.BOTTOM, 10); + root.setPadding(Spacing.LEFT, 10); + root.setPadding(Spacing.TOP, 10); + root.setPadding(Spacing.RIGHT, 10); + root.setPadding(Spacing.BOTTOM, 10); + root.setBorder(Spacing.LEFT, 10); + root.setBorder(Spacing.TOP, 10); + root.setBorder(Spacing.RIGHT, 10); + root.setBorder(Spacing.BOTTOM, 10); + root.setStyleWidth(100); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setPositionType(CSSPositionType.ABSOLUTE); + root_child0.setPosition(Spacing.LEFT, 0); + root_child0.setPosition(Spacing.TOP, 0); + root_child0.setStyleWidth(50); + root_child0.setStyleHeight(50); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setPositionType(CSSPositionType.ABSOLUTE); + root_child1.setPosition(Spacing.RIGHT, 0); + root_child1.setPosition(Spacing.BOTTOM, 0); + root_child1.setStyleWidth(50); + root_child1.setStyleHeight(50); + root.addChildAt(root_child1, 1); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(10, root.getLayoutX(), 0.0f); + assertEquals(10, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(10, root_child0.getLayoutX(), 0.0f); + assertEquals(10, root_child0.getLayoutY(), 0.0f); + assertEquals(50, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40, root_child1.getLayoutX(), 0.0f); + assertEquals(40, root_child1.getLayoutY(), 0.0f); + assertEquals(50, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(10, root.getLayoutX(), 0.0f); + assertEquals(10, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(10, root_child0.getLayoutX(), 0.0f); + assertEquals(10, root_child0.getLayoutY(), 0.0f); + assertEquals(50, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40, root_child1.getLayoutX(), 0.0f); + assertEquals(40, root_child1.getLayoutY(), 0.0f); + assertEquals(50, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + } + } diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index 92fd8f0f..905cd73b 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -31,6 +31,11 @@
+ +
+
+
+
* */ @@ -248,3 +253,72 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, absolute_layout_within_border) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetMargin(root, CSSEdgeLeft, 10); + CSSNodeStyleSetMargin(root, CSSEdgeTop, 10); + CSSNodeStyleSetMargin(root, CSSEdgeRight, 10); + CSSNodeStyleSetMargin(root, CSSEdgeBottom, 10); + CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); + CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); + CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); + CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); + CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); + CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); + CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); + CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); + CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + CSSNodeStyleSetWidth(root_child0, 50); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetPositionType(root_child1, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child1, CSSEdgeRight, 0); + CSSNodeStyleSetPosition(root_child1, CSSEdgeBottom, 0); + CSSNodeStyleSetWidth(root_child1, 50); + CSSNodeStyleSetHeight(root_child1, 50); + CSSNodeInsertChild(root, root_child1, 1); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeFreeRecursive(root); +} From 8a7183f465858d3696f2db47d637456462c16b13 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Wed, 9 Nov 2016 13:17:44 -0800 Subject: [PATCH 027/108] Add tests for SetMeasureFunction Summary: Add tests for checking C side asserts in managed Reviewed By: emilsjolander Differential Revision: D4154869 fbshipit-source-id: 5203db27eff963d46f188de448f607a24ed63fab --- .../tests/Facebook.CSSLayout/CSSNodeTest.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index f46ef24d..badf4639 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -161,6 +161,30 @@ namespace Facebook.CSSLayout Assert.AreEqual(150, (int)node.LayoutHeight); } + [Test] + [ExpectedException("System.InvalidOperationException")] + public void TestChildWithMeasureFunc() + { + CSSNode node = new CSSNode(); + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }); + CSSNode child = new CSSNode(); + node.Insert(0, child); + } + + [Test] + [ExpectedException("System.InvalidOperationException")] + public void TestMeasureFuncWithChild() + { + CSSNode node = new CSSNode(); + CSSNode child = new CSSNode(); + node.Insert(0, child); + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }); + } + [Test] public void TestPrint() { From c382d513fbdf3be01b08e30499d18a9c6a350db2 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Wed, 9 Nov 2016 17:26:48 -0800 Subject: [PATCH 028/108] Remove CSSAssertSetFailFunc Summary: Remove CSSAssertSetFailFunc and use CSSLogLevelError for throwing managed exception. Reviewed By: emilsjolander Differential Revision: D4155452 fbshipit-source-id: 5a19c79a212f204d13064527fd6e5843bab76e6b --- CSSLayout/CSSLayout.c | 14 -------- CSSLayout/CSSLayout.h | 10 ------ CSSLayout/CSSMacros.h | 14 +++----- csharp/Facebook.CSSLayout/CSSAssert.cs | 35 ------------------- csharp/Facebook.CSSLayout/CSSLogger.cs | 5 +++ csharp/Facebook.CSSLayout/CSSNode.cs | 1 - csharp/Facebook.CSSLayout/Native.cs | 4 --- csharp/tests/Facebook.CSSLayout/test_macos.sh | 2 +- 8 files changed, 10 insertions(+), 75 deletions(-) delete mode 100644 csharp/Facebook.CSSLayout/CSSAssert.cs diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index e8e4d21c..7c4e97d2 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2497,17 +2497,3 @@ void CSSLog(CSSLogLevel level, const char *format, ...) { gLogger(level, format, args); va_end(args); } - -#ifdef CSS_ASSERT_FAIL_ENABLED -static CSSAssertFailFunc gAssertFailFunc; - -void CSSAssertSetFailFunc(CSSAssertFailFunc func) { - gAssertFailFunc = func; -} - -void CSSAssertFail(const char *message) { - if (gAssertFailFunc) { - (*gAssertFailFunc)(message); - } -} -#endif diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 39f134f2..fb06d6d4 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -132,10 +132,6 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, typedef void (*CSSPrintFunc)(CSSNodeRef node); typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args); -#ifdef CSS_ASSERT_FAIL_ENABLED -typedef void (*CSSAssertFailFunc)(const char *message); -#endif - // CSSNode WIN_EXPORT CSSNodeRef CSSNodeNew(void); WIN_EXPORT void CSSNodeInit(const CSSNodeRef node); @@ -242,10 +238,4 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); -#ifdef CSS_ASSERT_FAIL_ENABLED -// Assert -WIN_EXPORT void CSSAssertSetFailFunc(CSSAssertFailFunc func); -WIN_EXPORT void CSSAssertFail(const char *message); -#endif - CSS_EXTERN_C_END diff --git a/CSSLayout/CSSMacros.h b/CSSLayout/CSSMacros.h index 65e68964..8d2375e5 100644 --- a/CSSLayout/CSSMacros.h +++ b/CSSLayout/CSSMacros.h @@ -33,16 +33,10 @@ #define CSS_ABORT() #endif -#if CSS_ASSERT_FAIL_ENABLED -#define CSS_ERROR_FUNC(message) CSSAssertFail(message) -#else -#define CSS_ERROR_FUNC(message) CSSLog(CSSLogLevelError, "%s", message) -#endif - #ifndef CSS_ASSERT -#define CSS_ASSERT(X, message) \ - if (!(X)) { \ - CSS_ERROR_FUNC(message); \ - CSS_ABORT(); \ +#define CSS_ASSERT(X, message) \ + if (!(X)) { \ + CSSLog(CSSLogLevelError, "%s", message); \ + CSS_ABORT(); \ } #endif diff --git a/csharp/Facebook.CSSLayout/CSSAssert.cs b/csharp/Facebook.CSSLayout/CSSAssert.cs deleted file mode 100644 index 848c9119..00000000 --- a/csharp/Facebook.CSSLayout/CSSAssert.cs +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -using System; -using System.Runtime.InteropServices; - -namespace Facebook.CSSLayout -{ - internal static class CSSAssert - { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void FailFunc(string message); - - private static bool _assertInitialized; - private static FailFunc _failFunc; - - public static void Initialize() - { - if (!_assertInitialized) - { - _failFunc = (message) => { - throw new InvalidOperationException(message); - }; - Native.CSSAssertSetFailFunc(_failFunc); - _assertInitialized = true; - } - } - } -} diff --git a/csharp/Facebook.CSSLayout/CSSLogger.cs b/csharp/Facebook.CSSLayout/CSSLogger.cs index c6c4ae37..60122f27 100644 --- a/csharp/Facebook.CSSLayout/CSSLogger.cs +++ b/csharp/Facebook.CSSLayout/CSSLogger.cs @@ -31,6 +31,11 @@ namespace Facebook.CSSLayout { Logger(level, message); } + + if (level == CSSLogLevel.Error) + { + throw new InvalidOperationException(message); + } }; Native.CSSInteropSetLogger(_managedLogger); _initialized = true; diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 6267001e..1fea4c8a 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -26,7 +26,6 @@ namespace Facebook.CSSLayout public CSSNode() { - CSSAssert.Initialize(); CSSLogger.Initialize(); _cssNode = Native.CSSNodeNew(); diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index 0d736f36..105652aa 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -24,10 +24,6 @@ namespace Facebook.CSSLayout public static extern void CSSInteropSetLogger( [MarshalAs(UnmanagedType.FunctionPtr)] CSSLogger.Func func); - [DllImport(DllName)] - public static extern void CSSAssertSetFailFunc( - [MarshalAs(UnmanagedType.FunctionPtr)] CSSAssert.FailFunc func); - [DllImport(DllName)] public static extern IntPtr CSSNodeNew(); diff --git a/csharp/tests/Facebook.CSSLayout/test_macos.sh b/csharp/tests/Facebook.CSSLayout/test_macos.sh index 27e39f64..c37247b8 100755 --- a/csharp/tests/Facebook.CSSLayout/test_macos.sh +++ b/csharp/tests/Facebook.CSSLayout/test_macos.sh @@ -27,6 +27,6 @@ if [ -d $NUNIT \ fi cd "$( dirname "$0" )" -clang -g -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp +clang -g -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs MONO_PATH=$NUNIT mono64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll From 087d1f3a8239ede5fd7fa82fa343e0f957fffaf8 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 20:17:30 -0800 Subject: [PATCH 029/108] Fix benchmark Summary: It was always a mistake to have a measure function here but the recent addition of an assertion made us notice it. Reviewed By: splhack Differential Revision: D4156754 fbshipit-source-id: 98fcea6e233cb4f5706ebca37028c8d67edb4c09 --- benchmark/CSSBenchmark.c | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmark/CSSBenchmark.c b/benchmark/CSSBenchmark.c index e08a1df7..0bab9511 100644 --- a/benchmark/CSSBenchmark.c +++ b/benchmark/CSSBenchmark.c @@ -59,7 +59,6 @@ CSS_BENCHMARKS({ for (uint32_t i = 0; i < 10; i++) { const CSSNodeRef child = CSSNodeNew(); - CSSNodeSetMeasureFunc(child, _measure); CSSNodeStyleSetFlex(child, 1); CSSNodeInsertChild(root, child, 0); From f222d22ba858093adfaf66bae89c0d83f6470538 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 10 Nov 2016 08:43:54 -0800 Subject: [PATCH 030/108] Remove useless store in CSSLayout.c Summary: Pointed out by the Xcode analyzer Reviewed By: emilsjolander Differential Revision: D4159938 fbshipit-source-id: 8b9ff3896c0e222e8e89546881129214bc6ba566 --- CSSLayout/CSSLayout.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 7c4e97d2..470c048c 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1939,12 +1939,10 @@ static void layoutNodeImpl(const CSSNodeRef node, if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) { childWidth = child->style.maxDimensions[CSSDimensionWidth]; - childWidthMeasureMode = CSSMeasureModeAtMost; } if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) { childHeight = child->style.maxDimensions[CSSDimensionHeight]; - childHeightMeasureMode = CSSMeasureModeAtMost; } // If the child defines a definite size for its cross axis, there's From 0dbbfc5910febe2c8d7b9306cb2b8a29bbfc4397 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 10 Nov 2016 19:13:19 -0800 Subject: [PATCH 031/108] Add convenient cast method for MeasureOutput.Make Summary: Same as Java, it allows to use float and double values in Make arguments. Reviewed By: emilsjolander Differential Revision: D4163347 fbshipit-source-id: f373247b3f37e7940a66044000cca2935068decf --- csharp/Facebook.CSSLayout/MeasureFunction.cs | 12 ++++++------ csharp/Facebook.CSSLayout/MeasureOutput.cs | 11 ++++++++--- csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/csharp/Facebook.CSSLayout/MeasureFunction.cs b/csharp/Facebook.CSSLayout/MeasureFunction.cs index b727dfc5..51614e17 100644 --- a/csharp/Facebook.CSSLayout/MeasureFunction.cs +++ b/csharp/Facebook.CSSLayout/MeasureFunction.cs @@ -9,10 +9,10 @@ namespace Facebook.CSSLayout { - public delegate long MeasureFunction( - CSSNode node, - float width, - CSSMeasureMode widthMode, - float height, - CSSMeasureMode heightMode); + public delegate long MeasureFunction( + CSSNode node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode); } diff --git a/csharp/Facebook.CSSLayout/MeasureOutput.cs b/csharp/Facebook.CSSLayout/MeasureOutput.cs index 5fabf348..5ae6b9b0 100644 --- a/csharp/Facebook.CSSLayout/MeasureOutput.cs +++ b/csharp/Facebook.CSSLayout/MeasureOutput.cs @@ -11,19 +11,24 @@ namespace Facebook.CSSLayout { public class MeasureOutput { + public static long Make(double width, double height) + { + return Make((int) width, (int) height); + } + public static long Make(int width, int height) { - return (long)(((ulong) width) << 32 | ((ulong) height)); + return (long)(((ulong) width) << 32 | ((ulong) height)); } public static int GetWidth(long measureOutput) { - return (int) (0xFFFFFFFF & (measureOutput >> 32)); + return (int) (0xFFFFFFFF & (measureOutput >> 32)); } public static int GetHeight(long measureOutput) { - return (int) (0xFFFFFFFF & measureOutput); + return (int) (0xFFFFFFFF & measureOutput); } } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index badf4639..5677da91 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -157,8 +157,20 @@ namespace Facebook.CSSLayout return MeasureOutput.Make(100, 150); }); node.CalculateLayout(); - Assert.AreEqual(100, (int)node.LayoutWidth); - Assert.AreEqual(150, (int)node.LayoutHeight); + Assert.AreEqual(100, node.LayoutWidth); + Assert.AreEqual(150, node.LayoutHeight); + } + + [Test] + public void TestMeasureFuncWithFloat() + { + CSSNode node = new CSSNode(); + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(123.4f, 81.7f); + }); + node.CalculateLayout(); + Assert.AreEqual(123, node.LayoutWidth); + Assert.AreEqual(81, node.LayoutHeight); } [Test] From 3e2c13f418f3dcd4af8f52558fa1e4ea3ca96a47 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 10 Nov 2016 19:48:31 -0800 Subject: [PATCH 032/108] Fix running ios tests in travis Summary: Currently travis logs indicate it is building with the wrong cxx platform. Explicitly set this to and ios simulator for ios tests Reviewed By: dshahidehpour Differential Revision: D4162159 fbshipit-source-id: 50f563132456ee4ba4e5b3b4b1f50b636cb94306 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e205105..253f4c41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: script: - buck test //:CSSLayout - buck test //java:java - - buck test //uikit/CSSLayout:CSSLayout + - buck test //uikit/CSSLayout:CSSLayout --config cxx.default_platform=iphonesimulator-x86_64 - buck run //benchmark:benchmark - git checkout HEAD^ - buck run //benchmark:benchmark From 70e01a447624fd7f6d0a74a5206fc09986aacdca Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Fri, 11 Nov 2016 07:36:39 -0800 Subject: [PATCH 033/108] Rename uikit/CSSLayout to CSSLayoutKit. Summary: When trying to integrate this into an Xcode project that already included CSSLayout.[c|h], we were getting a linker error. Upon digging in, I found out that Xcode was becoming confused because the imports of the uikit library and the c library are both `#import `. So, it needed a new name. Reviewed By: emilsjolander Differential Revision: D4162621 fbshipit-source-id: b5f7624eb29f1b9eaebbed5104ec9ea8a12ad2e5 --- .travis.yml | 2 +- {uikit/CSSLayout => CSSLayoutKit}/BUCK | 8 ++++---- {uikit/CSSLayout => CSSLayoutKit}/Tests/CSSLayoutTests.m | 0 {uikit/CSSLayout => CSSLayoutKit}/Tests/Info.plist | 0 {uikit/CSSLayout => CSSLayoutKit}/UIView+CSSLayout.h | 0 {uikit/CSSLayout => CSSLayoutKit}/UIView+CSSLayout.m | 0 README.md | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename {uikit/CSSLayout => CSSLayoutKit}/BUCK (90%) rename {uikit/CSSLayout => CSSLayoutKit}/Tests/CSSLayoutTests.m (100%) rename {uikit/CSSLayout => CSSLayoutKit}/Tests/Info.plist (100%) rename {uikit/CSSLayout => CSSLayoutKit}/UIView+CSSLayout.h (100%) rename {uikit/CSSLayout => CSSLayoutKit}/UIView+CSSLayout.m (100%) diff --git a/.travis.yml b/.travis.yml index 253f4c41..09a753b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: script: - buck test //:CSSLayout - buck test //java:java - - buck test //uikit/CSSLayout:CSSLayout --config cxx.default_platform=iphonesimulator-x86_64 + - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 - buck run //benchmark:benchmark - git checkout HEAD^ - buck run //benchmark:benchmark diff --git a/uikit/CSSLayout/BUCK b/CSSLayoutKit/BUCK similarity index 90% rename from uikit/CSSLayout/BUCK rename to CSSLayoutKit/BUCK index 2c9ec8fd..089d6f09 100644 --- a/uikit/CSSLayout/BUCK +++ b/CSSLayoutKit/BUCK @@ -10,9 +10,9 @@ include_defs('//CSSLAYOUT_DEFS') UIKIT_CSSLAYOUT_COMPILER_FLAGS = ['-fobjc-arc'] apple_library( - name = 'CSSLayout', + name = 'CSSLayoutKit', compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, - tests = [':CSSLayoutTests'], + tests = [':CSSLayoutKitTests'], srcs = glob(['*.m']), exported_headers = glob(['*.h']), frameworks = [ @@ -26,7 +26,7 @@ apple_library( ) apple_test( - name = 'CSSLayoutTests', + name = 'CSSLayoutKitTests', compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, info_plist = 'Tests/Info.plist', srcs = glob(['Tests/**/*.m']), @@ -35,7 +35,7 @@ apple_test( '$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework', ], deps = [ - ':CSSLayout', + ':CSSLayoutKit', ], visibility = ['PUBLIC'], ) diff --git a/uikit/CSSLayout/Tests/CSSLayoutTests.m b/CSSLayoutKit/Tests/CSSLayoutTests.m similarity index 100% rename from uikit/CSSLayout/Tests/CSSLayoutTests.m rename to CSSLayoutKit/Tests/CSSLayoutTests.m diff --git a/uikit/CSSLayout/Tests/Info.plist b/CSSLayoutKit/Tests/Info.plist similarity index 100% rename from uikit/CSSLayout/Tests/Info.plist rename to CSSLayoutKit/Tests/Info.plist diff --git a/uikit/CSSLayout/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h similarity index 100% rename from uikit/CSSLayout/UIView+CSSLayout.h rename to CSSLayoutKit/UIView+CSSLayout.h diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m similarity index 100% rename from uikit/CSSLayout/UIView+CSSLayout.m rename to CSSLayoutKit/UIView+CSSLayout.m diff --git a/README.md b/README.md index fb1f8b45..2b9c9f55 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ root.getLayoutHeight(); ``` ### UIKit -The full API can be found in `uikit/CSSLayout/UIView+CSSLayout.h`. +The full API can be found in `CSSLayoutKit/UIView+CSSLayout.h`. ```objective-c UIView *root = [UIView new]; From aaa977f6455f4605d528e3d2b47b92351a3533c6 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 11 Nov 2016 08:05:44 -0800 Subject: [PATCH 034/108] Fix flex within max size if max size is not constraint to Summary: Previous fix for flex in max size constraint was not entirely correct and was missing a test case for the time when the max constraint is not applied. This diff addresses that. Reviewed By: gkassabli Differential Revision: D4162104 fbshipit-source-id: 08feba6cb4e789c9aa12179e2cdeadc66b011841 --- CSSLayout/CSSLayout.c | 81 +++++++++++-------- .../CSSLayoutMinMaxDimensionTest.cs | 59 ++++++++++++++ .../CSSLayoutMinMaxDimensionTest.html | 6 ++ .../CSSLayoutMinMaxDimensionTest.java | 58 +++++++++++++ tests/CSSLayoutMinMaxDimensionTest.cpp | 57 +++++++++++++ 5 files changed, 227 insertions(+), 34 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 470c048c..f2d884b7 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -107,7 +107,7 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node); static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) { int androidLevel = CSSLogLevelDebug; switch (level) { - case CSSLogLevelError: + case CSSLogLevelError: androidLevel = ANDROID_LOG_ERROR; break; case CSSLogLevelWarn: @@ -116,7 +116,7 @@ static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list a case CSSLogLevelInfo: androidLevel = ANDROID_LOG_INFO; break; - case CSSLogLevelDebug: + case CSSLogLevelDebug: androidLevel = ANDROID_LOG_DEBUG; break; case CSSLogLevelVerbose: @@ -130,11 +130,11 @@ static CSSLogger gLogger = &_csslayoutAndroidLog; #else static int _csslayoutDefaultLog(CSSLogLevel level, const char *format, va_list args) { switch (level) { - case CSSLogLevelError: + case CSSLogLevelError: return vfprintf(stderr, format, args); case CSSLogLevelWarn: case CSSLogLevelInfo: - case CSSLogLevelDebug: + case CSSLogLevelDebug: case CSSLogLevelVerbose: default: return vprintf(format, args); @@ -289,7 +289,8 @@ void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) { if (measureFunc == NULL) { node->measure = NULL; } else { - CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); + CSS_ASSERT(CSSNodeChildCount(node) == 0, + "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } } @@ -897,6 +898,23 @@ static float getRelativePosition(const CSSNodeRef node, const CSSFlexDirection a : -getTrailingPosition(node, axis); } +static void constrainMaxSizeForMode(const float maxSize, CSSMeasureMode *mode, float *size) { + switch (*mode) { + case CSSMeasureModeExactly: + case CSSMeasureModeAtMost: + *size = (CSSValueIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; + break; + case CSSMeasureModeUndefined: + if (!CSSValueIsUndefined(maxSize)) { + *mode = CSSMeasureModeAtMost; + *size = maxSize; + } + break; + case CSSMeasureModeCount: + break; + } +} + static void setPosition(const CSSNodeRef node, const CSSDirection direction) { const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); @@ -996,15 +1014,12 @@ static void computeChildFlexBasis(const CSSNodeRef node, childHeightMeasureMode = CSSMeasureModeExactly; } - if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) { - childWidth = child->style.maxDimensions[CSSDimensionWidth]; - childWidthMeasureMode = CSSMeasureModeAtMost; - } - - if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) { - childHeight = child->style.maxDimensions[CSSDimensionHeight]; - childHeightMeasureMode = CSSMeasureModeAtMost; - } + constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], + &childWidthMeasureMode, + &childWidth); + constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionHeight], + &childHeightMeasureMode, + &childHeight); // Measure the child layoutNodeInternal(child, @@ -1122,7 +1137,7 @@ static void absoluteLayoutChild(const CSSNodeRef node, if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) { child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] - child->layout.measuredDimensions[dim[crossAxis]] - - getTrailingBorder(node, crossAxis) - + getTrailingBorder(node, crossAxis) - getTrailingPosition(child, crossAxis); } } @@ -1738,15 +1753,12 @@ static void layoutNodeImpl(const CSSNodeRef node, } } - if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionWidth])) { - childWidth = currentRelativeChild->style.maxDimensions[CSSDimensionWidth]; - childWidthMeasureMode = CSSMeasureModeAtMost; - } - - if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionHeight])) { - childHeight = currentRelativeChild->style.maxDimensions[CSSDimensionHeight]; - childHeightMeasureMode = CSSMeasureModeAtMost; - } + constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionWidth], + &childWidthMeasureMode, + &childWidth); + constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionHeight], + &childHeightMeasureMode, + &childHeight); const bool requiresStretchLayout = !isStyleDimDefined(currentRelativeChild, crossAxis) && @@ -1858,7 +1870,8 @@ static void layoutNodeImpl(const CSSNodeRef node, crossDim = fmaxf(crossDim, getDimWithMargin(child, crossAxis)); } } else if (performLayout) { - child->layout.position[pos[mainAxis]] += getLeadingBorder(node, mainAxis) + leadingMainDim; + child->layout.position[pos[mainAxis]] += + getLeadingBorder(node, mainAxis) + leadingMainDim; } } } @@ -1924,8 +1937,8 @@ static void layoutNodeImpl(const CSSNodeRef node, float childWidth; float childHeight; - CSSMeasureMode childWidthMeasureMode; - CSSMeasureMode childHeightMeasureMode; + CSSMeasureMode childWidthMeasureMode = CSSMeasureModeExactly; + CSSMeasureMode childHeightMeasureMode = CSSMeasureModeExactly; if (isMainAxisRow) { childHeight = crossDim; @@ -1937,13 +1950,12 @@ static void layoutNodeImpl(const CSSNodeRef node, getMarginAxis(child, CSSFlexDirectionColumn); } - if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) { - childWidth = child->style.maxDimensions[CSSDimensionWidth]; - } - - if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) { - childHeight = child->style.maxDimensions[CSSDimensionHeight]; - } + constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], + &childWidthMeasureMode, + &childWidth); + constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionHeight], + &childHeightMeasureMode, + &childHeight); // If the child defines a definite size for its cross axis, there's // no need to stretch. @@ -1952,6 +1964,7 @@ static void layoutNodeImpl(const CSSNodeRef node, CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; childHeightMeasureMode = CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; + layoutNodeInternal(child, childWidth, childHeight, diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index f09deb1f..8365a082 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -47,6 +47,12 @@
+ +
+
+
+
+
* */ @@ -442,5 +448,58 @@ namespace Facebook.CSSLayout Assert.AreEqual(20, root_child0_child0.LayoutHeight); } + [Test] + public void Test_flex_grow_within_constrained_max_width() + { + CSSNode root = new CSSNode(); + root.StyleWidth = 200; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexDirection = CSSFlexDirection.Row; + root_child0.StyleMaxWidth = 300; + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.FlexGrow = 1; + root_child0_child0.StyleHeight = 20; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(200, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(200, root_child0.LayoutWidth); + Assert.AreEqual(20, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(20, root_child0_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(200, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(200, root_child0.LayoutWidth); + Assert.AreEqual(20, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(20, root_child0_child0.LayoutHeight); + } + } } diff --git a/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html b/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html index 599f3fe6..6e469707 100644 --- a/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html +++ b/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html @@ -35,3 +35,9 @@
+ +
+
+
+
+
diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index 271f3a9f..d513f5e4 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -47,6 +47,12 @@
+ +
+
+
+
+
* */ @@ -433,4 +439,56 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_flex_grow_within_constrained_max_width() { + final CSSNode root = new CSSNode(); + root.setStyleWidth(200); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexDirection(CSSFlexDirection.ROW); + root_child0.setStyleMaxWidth(300); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setStyleHeight(20); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(200, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(200, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + } + } diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index 38358a36..b9bec882 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -47,6 +47,12 @@
+ +
+
+
+
+
* */ @@ -420,3 +426,54 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) { CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 200); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(root_child0, CSSFlexDirectionRow); + CSSNodeStyleSetMaxWidth(root_child0, 300); + CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeFreeRecursive(root); +} From cd054ecf265f2e9ec532eebd2a97d40244e90de1 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 11 Nov 2016 08:08:28 -0800 Subject: [PATCH 035/108] Expose CSSLayoutSetLogger to java Summary: Expose CSSLayoutSetLogger to java Reviewed By: astreet Differential Revision: D4153502 fbshipit-source-id: 630909d9d0d36d94d7cd3027476ddb52668b8cc0 --- java/com/facebook/csslayout/CSSLogger.java | 27 ++++++++++++++ java/com/facebook/csslayout/CSSNode.java | 6 ++++ java/jni/CSSJNI.cpp | 35 +++++++++++++++++++ .../com/facebook/csslayout/CSSNodeTest.java | 32 +++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 java/com/facebook/csslayout/CSSLogger.java diff --git a/java/com/facebook/csslayout/CSSLogger.java b/java/com/facebook/csslayout/CSSLogger.java new file mode 100644 index 00000000..44536c46 --- /dev/null +++ b/java/com/facebook/csslayout/CSSLogger.java @@ -0,0 +1,27 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +import com.facebook.proguard.annotations.DoNotStrip; + +/** + * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); + * LOG_LEVEL_ERROR indicated a fatal error. + */ +public interface CSSLogger { + public final int LOG_LEVEL_ERROR = 0; + public final int LOG_LEVEL_WARN = 1; + public final int LOG_LEVEL_INFO = 2; + public final int LOG_LEVEL_DEBUG = 3; + public final int LOG_LEVEL_VERBOSE = 4; + + @DoNotStrip + void log(int level, String message); +} diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 612be246..9cc47686 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -33,6 +33,12 @@ 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); + + private static native void jni_CSSLayoutSetLogger(Object logger); + public static void setLogger(CSSLogger logger) { + jni_CSSLayoutSetLogger(logger); + } private CSSNode mParent; private List mChildren; diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 16869f1a..1b5d1de9 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -68,10 +68,43 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, return CSSSize{measuredWidth, measuredHeight}; } +static global_ref *jLogger; +static int _jniLog(CSSLogLevel 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("log"); + logFunc(jLogger->get(), 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); +} + jint jni_CSSNodeGetInstanceCount(alias_ref clazz) { return CSSNodeGetInstanceCount(); } @@ -256,6 +289,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) { CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight), CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount), + CSSMakeNativeMethod(jni_CSSLayoutSetLogger), + CSSMakeNativeMethod(jni_CSSLog), }); }); } diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index c61b8988..5f2d3ae2 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -39,4 +39,36 @@ public class CSSNodeTest { assertEquals(100, (int) node.getLayoutWidth()); assertEquals(100, (int) node.getLayoutHeight()); } + + private int mLogLevel; + private String mLogMessage; + + @Test + public void testLogger() { + CSSNode.setLogger(new CSSLogger() { + public void log(int level, String message) { + mLogLevel = level; + mLogMessage = message; + } + }); + CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_DEBUG, "Hello"); + assertEquals(CSSLogger.LOG_LEVEL_DEBUG, mLogLevel); + assertEquals("Hello", mLogMessage); + } + + @Test + public void testUpdateLogger() { + CSSNode.setLogger(new CSSLogger() { + public void log(int level, String message) {} + }); + CSSNode.setLogger(new CSSLogger() { + public void log(int level, String message) { + mLogLevel = level; + mLogMessage = message; + } + }); + CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_VERBOSE, "Flexbox"); + assertEquals(CSSLogger.LOG_LEVEL_VERBOSE, mLogLevel); + assertEquals("Flexbox", mLogMessage); + } } From e40af30fa5c8f73a0593b5342865d7380641ee48 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 11 Nov 2016 09:04:31 -0800 Subject: [PATCH 036/108] Update .travis.yml for C# test Summary: Closes https://github.com/facebook/css-layout/pull/246 Reviewed By: emilsjolander Differential Revision: D4167133 Pulled By: splhack fbshipit-source-id: d55c0ff5155311f4da859b12b6485b120dac480b --- .travis.yml | 2 ++ csharp/tests/Facebook.CSSLayout/test_macos.sh | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09a753b4..8c126cdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,11 +15,13 @@ before_install: - brew tap facebook/fb - brew install buck - brew outdated xctool || brew upgrade xctool + - brew install mono script: - buck test //:CSSLayout - buck test //java:java - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 + - sh csharp/tests/Facebook.CSSLayout/test_macos.sh - buck run //benchmark:benchmark - git checkout HEAD^ - buck run //benchmark:benchmark diff --git a/csharp/tests/Facebook.CSSLayout/test_macos.sh b/csharp/tests/Facebook.CSSLayout/test_macos.sh index c37247b8..566170e4 100755 --- a/csharp/tests/Facebook.CSSLayout/test_macos.sh +++ b/csharp/tests/Facebook.CSSLayout/test_macos.sh @@ -9,11 +9,13 @@ if mcs --version >/dev/null 2>&1; then true; else exit 1 fi -if mono64 --version >/dev/null 2>&1; then true; else +if mono --version >/dev/null 2>&1; then true; else echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment." exit 1 fi +cd "$( dirname "$0" )" + NUNIT=NUnit-2.6.4/bin if [ -d $NUNIT \ -a -f $NUNIT/nunit-console.exe \ @@ -22,11 +24,10 @@ if [ -d $NUNIT \ -a -f $NUNIT/lib/nunit.core.interfaces.dll \ -a -f $NUNIT/lib/nunit.util.dll ]; then true; else curl -L -O https://github.com/nunit/nunitv2/releases/download/2.6.4/NUnit-2.6.4.zip - unzip NUnit-2.6.4.zip + unzip -qq NUnit-2.6.4.zip rm NUnit-2.6.4.zip fi -cd "$( dirname "$0" )" clang -g -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs -MONO_PATH=$NUNIT mono64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll +MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll From b4d0e1a17c1222d6f32c544fba79b00855717622 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Fri, 11 Nov 2016 15:01:16 -0800 Subject: [PATCH 037/108] Add some more compiler flags to CSSLayoutKit. Summary: Just firming up some stuff with more compiler flags. Reviewed By: rnystrom Differential Revision: D4168081 fbshipit-source-id: fced407f03944081bdd70cc28c57e3dc842ff7f0 --- CSSLayoutKit/BUCK | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CSSLayoutKit/BUCK b/CSSLayoutKit/BUCK index 089d6f09..2f9f570c 100644 --- a/CSSLayoutKit/BUCK +++ b/CSSLayoutKit/BUCK @@ -7,7 +7,25 @@ include_defs('//CSSLAYOUT_DEFS') -UIKIT_CSSLAYOUT_COMPILER_FLAGS = ['-fobjc-arc'] +UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ + '-fobjc-arc', + '-Wconditional-uninitialized', + '-Wdangling-else', + '-Wdeprecated-declarations', + '-Wimplicit-retain-self', + '-Wincomplete-implementation', + '-Wobjc-method-access', + '-Wobjc-missing-super-calls', + '-Wmismatched-return-types', + '-Wreturn-type', + '-Wno-global-constructors', + '-Wno-shadow', + '-Wunused-const-variable', + '-Wunused-function', + '-Wunused-property-ivar', + '-Wunused-result', + '-Wunused-value', +] apple_library( name = 'CSSLayoutKit', From e0e88f97b6e0a2d97356909c9baa3beb0d2eb14e Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Fri, 11 Nov 2016 16:38:13 -0800 Subject: [PATCH 038/108] Cleanup documentation, add pragma marks, and rename static functions in UIView+CSSLayout Summary: There is a little bit of tidying that was needed for this class. The documentation was inconsistent in the header, the static functions were prefixed with underscores (discouraged by apple). Cleaned it all up. Reviewed By: rnystrom Differential Revision: D4167936 fbshipit-source-id: 6e9a6e7fb78e3cff290b867a1ac0d5dd5cc9de5b --- CSSLayoutKit/UIView+CSSLayout.h | 18 ++++++--- CSSLayoutKit/UIView+CSSLayout.m | 66 +++++++++++++++++---------------- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index f08daa94..b7951b83 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -12,8 +12,10 @@ @interface UIView (CSSLayout) -- (void)css_setUsesFlexbox:(BOOL)enabled; -- (BOOL)css_usesFlexbox; +/** + The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO. + */ +@property (nonatomic, readwrite, assign, setter=css_setUsesFlexbox:) BOOL css_usesFlexbox; - (void)css_setDirection:(CSSDirection)direction; - (void)css_setFlexDirection:(CSSFlexDirection)flexDirection; @@ -39,13 +41,19 @@ - (void)css_setMaxWidth:(CGFloat)maxWidth; - (void)css_setMaxHeight:(CGFloat)maxHeight; -// Get the resolved direction of this node. This won't be CSSDirectionInherit +/** + Get the resolved direction of this node. This won't be CSSDirectionInherit + */ - (CSSDirection)css_resolvedDirection; -//! @abstract Perform a layout calculation and update the frames of the views in the hierarchy with th results +/** + Perform a layout calculation and update the frames of the views in the hierarchy with th results + */ - (void)css_applyLayout; -//! @abstract Compute the size of a layout with a constrained size. +/** + Compute the size of a layout with a constrained size. + */ - (CGSize)css_sizeThatFits:(CGSize)constrainedSize; @end diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 31cfbf1b..645cdd30 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -33,18 +33,14 @@ @implementation UIView (CSSLayout) -- (CSSNodeRef)cssNode +- (BOOL)css_usesFlexbox { - CSSNodeBridge *node = objc_getAssociatedObject(self, @selector(cssNode)); - if (!node) { - node = [CSSNodeBridge new]; - CSSNodeSetContext(node.cnode, (__bridge void *) self); - objc_setAssociatedObject(self, @selector(cssNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - - return node.cnode; + NSNumber *usesFlexbox = objc_getAssociatedObject(self, @selector(css_usesFlexbox)); + return [usesFlexbox boolValue]; } +#pragma mark - Setters + - (void)css_setUsesFlexbox:(BOOL)enabled { objc_setAssociatedObject( @@ -54,12 +50,6 @@ OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (BOOL)css_usesFlexbox -{ - NSNumber *usesFlexbox = objc_getAssociatedObject(self, @selector(css_usesFlexbox)); - return [usesFlexbox boolValue]; -} - - (void)css_setDirection:(CSSDirection)direction { CSSNodeStyleSetDirection([self cssNode], direction); @@ -160,6 +150,8 @@ CSSNodeStyleSetMaxHeight([self cssNode], maxHeight); } +#pragma mark - Layout and Sizing + - (CSSDirection)css_resolvedDirection { return CSSNodeLayoutGetDirection([self cssNode]); @@ -170,7 +162,7 @@ NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); - _attachNodesRecursive(self); + CLKAttachNodesFromViewHierachy(self); const CSSNodeRef node = [self cssNode]; CSSNodeCalculateLayout( @@ -188,12 +180,24 @@ - (void)css_applyLayout { [self css_sizeThatFits:self.bounds.size]; - _updateFrameRecursive(self); + CLKApplyLayoutToViewHierarchy(self); } #pragma mark - Private -static CSSSize _measure( +- (CSSNodeRef)cssNode +{ + CSSNodeBridge *node = objc_getAssociatedObject(self, @selector(cssNode)); + if (!node) { + node = [CSSNodeBridge new]; + CSSNodeSetContext(node.cnode, (__bridge void *) self); + objc_setAssociatedObject(self, @selector(cssNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + + return node.cnode; +} + +static CSSSize CLKMeasureView( CSSNodeRef node, float width, CSSMeasureMode widthMode, @@ -210,12 +214,12 @@ static CSSSize _measure( }]; return (CSSSize) { - .width = _sanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), - .height = _sanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), + .width = CLKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), + .height = CLKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), }; } -static CGFloat _sanitizeMeasurement( +static CGFloat CLKSanitizeMeasurement( CGFloat constrainedSize, CGFloat measuredSize, CSSMeasureMode measureMode) @@ -232,14 +236,14 @@ static CGFloat _sanitizeMeasurement( return result; } -static void _attachNodesRecursive(UIView *view) { +static void CLKAttachNodesFromViewHierachy(UIView *view) { CSSNodeRef node = [view cssNode]; const BOOL usesFlexbox = [view css_usesFlexbox]; const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0; // Only leaf nodes should have a measure function if (isLeaf) { - CSSNodeSetMeasureFunc(node, _measure); + CSSNodeSetMeasureFunc(node, CLKMeasureView); // Clear any children while (CSSNodeChildCount(node) > 0) { @@ -254,7 +258,7 @@ static void _attachNodesRecursive(UIView *view) { if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) { CSSNodeInsertChild(node, childNode, i); } - _attachNodesRecursive(view.subviews[i]); + CLKAttachNodesFromViewHierachy(view.subviews[i]); } // Remove any children which were removed since the last call to css_applyLayout @@ -264,7 +268,7 @@ static void _attachNodesRecursive(UIView *view) { } } -static CGFloat _roundPixelValue(CGFloat value) +static CGFloat CLKRoundPixelValue(CGFloat value) { static CGFloat scale; static dispatch_once_t onceToken; @@ -275,7 +279,7 @@ static CGFloat _roundPixelValue(CGFloat value) return round(value * scale) / scale; } -static void _updateFrameRecursive(UIView *view) { +static void CLKApplyLayoutToViewHierarchy(UIView *view) { NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); CSSNodeRef node = [view cssNode]; @@ -291,19 +295,19 @@ static void _updateFrameRecursive(UIView *view) { view.frame = (CGRect) { .origin = { - .x = _roundPixelValue(topLeft.x), - .y = _roundPixelValue(topLeft.y), + .x = CLKRoundPixelValue(topLeft.x), + .y = CLKRoundPixelValue(topLeft.y), }, .size = { - .width = _roundPixelValue(bottomRight.x) - _roundPixelValue(topLeft.x), - .height = _roundPixelValue(bottomRight.y) - _roundPixelValue(topLeft.y), + .width = CLKRoundPixelValue(bottomRight.x) - CLKRoundPixelValue(topLeft.x), + .height = CLKRoundPixelValue(bottomRight.y) - CLKRoundPixelValue(topLeft.y), }, }; const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0; if (!isLeaf) { for (NSUInteger i = 0; i < view.subviews.count; i++) { - _updateFrameRecursive(view.subviews[i]); + CLKApplyLayoutToViewHierarchy(view.subviews[i]); } } } From 7a3df9999bf196406b54b7450e4ac62e3bac58c9 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 14 Nov 2016 02:12:20 -0800 Subject: [PATCH 039/108] BREAKING - Fix sizing of container with child overflowing parent Summary: Fixes issue brought up in https://github.com/facebook/react-native/issues/10603 The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this. Reviewed By: gkassabli Differential Revision: D4157971 fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a --- CSSLayout/CSSLayout.c | 12 +- .../Facebook.CSSLayout/CSSSizeOverflowTest.cs | 140 ++++++++++++++++++ gentest/fixtures/CSSSizeOverflowTest.html | 11 ++ .../csslayout/CSSSizeOverflowTest.java | 136 +++++++++++++++++ tests/CSSSizeOverflowTest.cpp | 128 ++++++++++++++++ 5 files changed, 423 insertions(+), 4 deletions(-) create mode 100644 csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs create mode 100644 gentest/fixtures/CSSSizeOverflowTest.html create mode 100644 java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java create mode 100644 tests/CSSSizeOverflowTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index f2d884b7..5cf642d9 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2092,23 +2092,27 @@ static void layoutNodeImpl(const CSSNodeRef node, // If the user didn't specify a width or height for the node, set the // dimensions based on the children. - if (measureModeMainDim == CSSMeasureModeUndefined) { + if (measureModeMainDim == CSSMeasureModeUndefined || + (node->style.overflow != CSSOverflowScroll && measureModeMainDim == CSSMeasureModeAtMost)) { // 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); - } else if (measureModeMainDim == CSSMeasureModeAtMost) { + } else if (node->style.overflow == CSSOverflowScroll && + measureModeMainDim == CSSMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, boundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), paddingAndBorderAxisMain); } - if (measureModeCrossDim == CSSMeasureModeUndefined) { + if (measureModeCrossDim == CSSMeasureModeUndefined || + (node->style.overflow != CSSOverflowScroll && measureModeCrossDim == CSSMeasureModeAtMost)) { // 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); - } else if (measureModeCrossDim == CSSMeasureModeAtMost) { + } else if (node->style.overflow == CSSOverflowScroll && + measureModeCrossDim == CSSMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, boundAxisWithinMinAndMax(node, diff --git a/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs b/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs new file mode 100644 index 00000000..bee15ef5 --- /dev/null +++ b/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * @Generated by gentest/gentest.sh with the following input + * +
+
+
+
+
+ +
+
+
+
+
+ * + */ + +using System; +using NUnit.Framework; + +namespace Facebook.CSSLayout +{ + [TestFixture] + public class CSSSizeOverflowTest + { + [Test] + public void Test_nested_overflowing_child() + { + CSSNode root = new CSSNode(); + root.StyleWidth = 100; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.StyleWidth = 200; + root_child0_child0.StyleHeight = 200; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(200, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(200, root_child0_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(200, root_child0.LayoutHeight); + + Assert.AreEqual(-100, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(200, root_child0_child0.LayoutHeight); + } + + [Test] + public void Test_nested_overflowing_child_in_constraint_parent() + { + CSSNode root = new CSSNode(); + root.StyleWidth = 100; + root.StyleHeight = 100; + + CSSNode root_child0 = new CSSNode(); + root_child0.StyleWidth = 100; + root_child0.StyleHeight = 100; + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.StyleWidth = 200; + root_child0_child0.StyleHeight = 200; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = CSSDirection.LeftToRight; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(100, root_child0.LayoutHeight); + + Assert.AreEqual(0, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(200, root_child0_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RightToLeft; + root.CalculateLayout(); + + Assert.AreEqual(0, root.LayoutX); + Assert.AreEqual(0, root.LayoutY); + Assert.AreEqual(100, root.LayoutWidth); + Assert.AreEqual(100, root.LayoutHeight); + + Assert.AreEqual(0, root_child0.LayoutX); + Assert.AreEqual(0, root_child0.LayoutY); + Assert.AreEqual(100, root_child0.LayoutWidth); + Assert.AreEqual(100, root_child0.LayoutHeight); + + Assert.AreEqual(-100, root_child0_child0.LayoutX); + Assert.AreEqual(0, root_child0_child0.LayoutY); + Assert.AreEqual(200, root_child0_child0.LayoutWidth); + Assert.AreEqual(200, root_child0_child0.LayoutHeight); + } + + } +} diff --git a/gentest/fixtures/CSSSizeOverflowTest.html b/gentest/fixtures/CSSSizeOverflowTest.html new file mode 100644 index 00000000..fd06adba --- /dev/null +++ b/gentest/fixtures/CSSSizeOverflowTest.html @@ -0,0 +1,11 @@ +
+
+
+
+
+ +
+
+
+
+
diff --git a/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java b/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java new file mode 100644 index 00000000..5394fe75 --- /dev/null +++ b/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java @@ -0,0 +1,136 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * @Generated by gentest/gentest.sh with the following input + * +
+
+
+
+
+ +
+
+
+
+
+ * + */ + +package com.facebook.csslayout; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class CSSSizeOverflowTest { + @Test + public void test_nested_overflowing_child() { + final CSSNode root = new CSSNode(); + root.setStyleWidth(100); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setStyleWidth(200); + root_child0_child0.setStyleHeight(200); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-100, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_nested_overflowing_child_in_constraint_parent() { + final CSSNode root = new CSSNode(); + root.setStyleWidth(100); + root.setStyleHeight(100); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setStyleWidth(100); + root_child0.setStyleHeight(100); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setStyleWidth(200); + root_child0_child0.setStyleHeight(200); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0, root.getLayoutX(), 0.0f); + assertEquals(0, root.getLayoutY(), 0.0f); + assertEquals(100, root.getLayoutWidth(), 0.0f); + assertEquals(100, root.getLayoutHeight(), 0.0f); + + assertEquals(0, root_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0.getLayoutY(), 0.0f); + assertEquals(100, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-100, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); + } + +} diff --git a/tests/CSSSizeOverflowTest.cpp b/tests/CSSSizeOverflowTest.cpp new file mode 100644 index 00000000..14c23ff4 --- /dev/null +++ b/tests/CSSSizeOverflowTest.cpp @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * @Generated by gentest/gentest.sh with the following input + * +
+
+
+
+
+ +
+
+
+
+
+ * + */ + +#include +#include + +TEST(CSSLayoutTest, nested_overflowing_child) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child0_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0_child0, 200); + CSSNodeStyleSetHeight(root_child0_child0, 200); + CSSNodeInsertChild(root_child0, root_child0_child0, 0); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(-100, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, nested_overflowing_child_in_constraint_parent) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 100); + CSSNodeStyleSetHeight(root_child0, 100); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child0_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0_child0, 200); + CSSNodeStyleSetHeight(root_child0_child0, 200); + CSSNodeInsertChild(root_child0, root_child0_child0, 0); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + 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, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + 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(-100, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeFreeRecursive(root); +} From b99172d28b998984ec091b83316128386a87315a Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 14 Nov 2016 03:27:31 -0800 Subject: [PATCH 040/108] rename CSSWrapType to shorter CSSWrap matching java and csharp Summary: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two. Reviewed By: gkassabli Differential Revision: D4174257 fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592 --- CSSLayout/CSSLayout.c | 6 +++--- CSSLayout/CSSLayout.h | 10 +++++----- CSSLayoutKit/UIView+CSSLayout.h | 2 +- CSSLayoutKit/UIView+CSSLayout.m | 2 +- gentest/gentest-cpp.js | 4 ++-- gentest/gentest-cs.js | 4 ++-- gentest/gentest-java.js | 4 ++-- gentest/gentest.js | 4 ++-- java/jni/CSSJNI.cpp | 2 +- tests/CSSLayoutAlignContentTest.cpp | 8 ++++---- tests/CSSLayoutDefaultValuesTest.cpp | 2 +- tests/CSSLayoutFlexWrapTest.cpp | 8 ++++---- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 5cf642d9..eba66a5b 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -69,7 +69,7 @@ typedef struct CSSStyle { CSSAlign alignItems; CSSAlign alignSelf; CSSPositionType positionType; - CSSWrapType flexWrap; + CSSWrap flexWrap; CSSOverflow overflow; float flex; float flexGrow; @@ -423,7 +423,7 @@ CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignContent, alignContent, alignContent) CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignItems, alignItems, alignItems); CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignSelf, alignSelf, alignSelf); CSS_NODE_STYLE_PROPERTY_IMPL(CSSPositionType, PositionType, positionType, positionType); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrapType, FlexWrap, flexWrap, flexWrap); +CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrap, FlexWrap, flexWrap, flexWrap); CSS_NODE_STYLE_PROPERTY_IMPL(CSSOverflow, Overflow, overflow, overflow); CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); @@ -1395,7 +1395,7 @@ static void layoutNodeImpl(const CSSNodeRef node, const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); const bool isMainAxisRow = isRowDirection(mainAxis); const CSSJustify justifyContent = node->style.justifyContent; - const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapTypeWrap; + const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapWrap; CSSNodeRef firstAbsoluteChild = NULL; CSSNodeRef currentAbsoluteChild = NULL; diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index fb06d6d4..b860b9c3 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -74,10 +74,10 @@ typedef enum CSSPositionType { CSSPositionTypeAbsolute, } CSSPositionType; -typedef enum CSSWrapType { - CSSWrapTypeNoWrap, - CSSWrapTypeWrap, -} CSSWrapType; +typedef enum CSSWrap { + CSSWrapNoWrap, + CSSWrapWrap, +} CSSWrap; typedef enum CSSMeasureMode { CSSMeasureModeUndefined, @@ -207,7 +207,7 @@ CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignContent, alignContent); CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems); CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf); CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType); -CSS_NODE_STYLE_PROPERTY(CSSWrapType, FlexWrap, flexWrap); +CSS_NODE_STYLE_PROPERTY(CSSWrap, FlexWrap, flexWrap); CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow); WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex); diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index b7951b83..394c58c1 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -24,7 +24,7 @@ - (void)css_setAlignItems:(CSSAlign)alignItems; - (void)css_setAlignSelf:(CSSAlign)alignSelf; - (void)css_setPositionType:(CSSPositionType)positionType; -- (void)css_setFlexWrap:(CSSWrapType)flexWrap; +- (void)css_setFlexWrap:(CSSWrap)flexWrap; - (void)css_setFlexGrow:(CGFloat)flexGrow; - (void)css_setFlexShrink:(CGFloat)flexShrink; diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 645cdd30..faf3242f 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -85,7 +85,7 @@ CSSNodeStyleSetPositionType([self cssNode], positionType); } -- (void)css_setFlexWrap:(CSSWrapType)flexWrap +- (void)css_setFlexWrap:(CSSWrap)flexWrap { CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); } diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index dc0427b9..9e378816 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -84,8 +84,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { CSSPositionTypeAbsolute:{value:'CSSPositionTypeAbsolute'}, CSSPositionTypeRelative:{value:'CSSPositionTypeRelative'}, - CSSWrapTypeNoWrap:{value:'CSSWrapTypeNoWrap'}, - CSSWrapTypeWrap:{value:'CSSWrapTypeWrap'}, + CSSWrapNoWrap:{value:'CSSWrapNoWrap'}, + CSSWrapWrap:{value:'CSSWrapWrap'}, CSSUndefined:{value:'CSSUndefined'}, diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index c2046ef0..194b845a 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -100,8 +100,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { CSSUndefined:{value:'CSSConstants.Undefined'}, - CSSWrapTypeNoWrap:{value:'CSSWrap.NoWrap'}, - CSSWrapTypeWrap:{value:'CSSWrap.Wrap'}, + CSSWrapNoWrap:{value:'CSSWrap.NoWrap'}, + CSSWrapWrap:{value:'CSSWrap.Wrap'}, CSSNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.StyleDirection = ' + dir + ';'); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index f1dbb06b..853bf658 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -93,8 +93,8 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { CSSUndefined:{value:'CSSConstants.UNDEFINED'}, - CSSWrapTypeNoWrap:{value:'CSSWrap.NO_WRAP'}, - CSSWrapTypeWrap:{value:'CSSWrap.WRAP'}, + CSSWrapNoWrap:{value:'CSSWrap.NO_WRAP'}, + CSSWrapWrap:{value:'CSSWrap.WRAP'}, CSSNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.setDirection(' + dir + ');'); diff --git a/gentest/gentest.js b/gentest/gentest.js index 07fef381..26204c35 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -354,8 +354,8 @@ function overflowValue(e, value) { function wrapValue(e, value) { switch (value) { - case 'wrap': return e.CSSWrapTypeWrap; - case 'nowrap': return e.CSSWrapTypeNoWrap; + case 'wrap': return e.CSSWrapWrap; + case 'nowrap': return e.CSSWrapNoWrap; } } diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 1b5d1de9..8460e86a 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -203,7 +203,7 @@ CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems); CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf); CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent); CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType); -CSS_NODE_JNI_STYLE_PROP(jint, CSSWrapType, FlexWrap); +CSS_NODE_JNI_STYLE_PROP(jint, CSSWrap, FlexWrap); CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow); void jni_CSSNodeStyleSetFlex(alias_ref, jlong nativePointer, jfloat value) { diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index 7176801b..9fe462a4 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -49,7 +49,7 @@ TEST(CSSLayoutTest, align_content_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -147,7 +147,7 @@ TEST(CSSLayoutTest, align_content_flex_start) { TEST(CSSLayoutTest, align_content_flex_end) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -245,7 +245,7 @@ TEST(CSSLayoutTest, align_content_flex_end) { TEST(CSSLayoutTest, align_content_center) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetAlignContent(root, CSSAlignCenter); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -343,7 +343,7 @@ TEST(CSSLayoutTest, align_content_center) { TEST(CSSLayoutTest, align_content_stretch) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetAlignContent(root, CSSAlignStretch); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); diff --git a/tests/CSSLayoutDefaultValuesTest.cpp b/tests/CSSLayoutDefaultValuesTest.cpp index 7c647f61..f9e1766e 100644 --- a/tests/CSSLayoutDefaultValuesTest.cpp +++ b/tests/CSSLayoutDefaultValuesTest.cpp @@ -23,7 +23,7 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_EQ(CSSAlignStretch, CSSNodeStyleGetAlignItems(root)); ASSERT_EQ(CSSAlignAuto, CSSNodeStyleGetAlignSelf(root)); ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root)); - ASSERT_EQ(CSSWrapTypeNoWrap, CSSNodeStyleGetFlexWrap(root)); + ASSERT_EQ(CSSWrapNoWrap, CSSNodeStyleGetFlexWrap(root)); ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root)); ASSERT_EQ(0, CSSNodeStyleGetFlexGrow(root)); ASSERT_EQ(0, CSSNodeStyleGetFlexShrink(root)); diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index 49dcab93..74b23657 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -45,7 +45,7 @@ TEST(CSSLayoutTest, wrap_column) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -127,7 +127,7 @@ TEST(CSSLayoutTest, wrap_column) { TEST(CSSLayoutTest, wrap_row) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -210,7 +210,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -293,7 +293,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); + CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); From e6702e1168f7878a30a056548bc754ce1d61074f Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 14 Nov 2016 03:27:33 -0800 Subject: [PATCH 041/108] Implement standard interface for toggling experimental features Summary: We want to start experimenting with changes to the library in a more controlled and easier to measure manner. This diff adds the basics of an experiment layer to csslayout. Reviewed By: gkassabli Differential Revision: D4174260 fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd --- CSSLayout/CSSLayout.c | 10 ++++++++++ CSSLayout/CSSLayout.h | 7 +++++++ .../Facebook.CSSLayout/CSSExperimentalFeature.cs | 15 +++++++++++++++ csharp/Facebook.CSSLayout/CSSNode.cs | 12 ++++++++++++ csharp/Facebook.CSSLayout/Native.cs | 8 +++++++- .../csslayout/CSSExperimentalFeature.java | 13 +++++++++++++ java/com/facebook/csslayout/CSSNode.java | 14 ++++++++++++++ java/jni/CSSJNI.cpp | 10 ++++++++++ 8 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs create mode 100644 java/com/facebook/csslayout/CSSExperimentalFeature.java diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index eba66a5b..94e34421 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2512,3 +2512,13 @@ void CSSLog(CSSLogLevel level, const char *format, ...) { gLogger(level, format, args); va_end(args); } + +static bool experimentalFeatures[CSSExperimentalFeatureCount]; + +void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) { + experimentalFeatures[feature] = enabled; +} + +bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) { + return experimentalFeatures[feature]; +} diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index b860b9c3..7fdde1a8 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -123,6 +123,10 @@ typedef enum CSSLogLevel { CSSLogLevelVerbose, } CSSLogLevel; +typedef enum CSSExperimentalFeature { + CSSExperimentalFeatureCount, +} CSSExperimentalFeature; + typedef struct CSSNode *CSSNodeRef; typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float width, @@ -238,4 +242,7 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); +WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled); +WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature); + CSS_EXTERN_C_END diff --git a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs new file mode 100644 index 00000000..bd080932 --- /dev/null +++ b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.CSSLayout +{ + public enum CSSExperimentalFeature + { + } +} diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 1fea4c8a..95547abf 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -550,5 +550,17 @@ namespace Facebook.CSSLayout { return Native.CSSNodeGetInstanceCount(); } + + public static void setExperimentalFeatureEnabled( + CSSExperimentalFeature feature, + bool enabled) + { + return Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); + } + + public static bool isExperimentalFeatureEnabled(CSSExperimentalFeature feature) + { + return Native.CSSLayoutIsExperimentalFeatureEnabled(feature); + } } } diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index 105652aa..c734e1f6 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -37,7 +37,13 @@ namespace Facebook.CSSLayout public static extern void CSSNodeReset(IntPtr cssNode); [DllImport(DllName)] - public static extern int CSSNodeGetInstanceCount(); + public static extern void CSSLayoutSetExperimentalFeatureEnabled( + CSSExperimentalFeature feature, + bool enabled); + + [DllImport(DllName)] + public static extern bool CSSLayoutIsExperimentalFeatureEnabled( + CSSExperimentalFeature feature); [DllImport(DllName)] public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index); diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/CSSExperimentalFeature.java new file mode 100644 index 00000000..a92d522d --- /dev/null +++ b/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -0,0 +1,13 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +public enum CSSExperimentalFeature { +} diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 9cc47686..6c3419bc 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -40,6 +40,20 @@ public class CSSNode implements CSSNodeAPI { jni_CSSLayoutSetLogger(logger); } + private static native void jni_CSSLayoutSetExperimentalFeatureEnabled( + int feature, + boolean enabled); + public static void setExperimentalFeatureEnabled( + CSSExperimentalFeature feature, + boolean enabled) { + jni_CSSLayoutSetExperimentalFeatureEnabled(feature.ordinal(), enabled); + } + + private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature); + public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) { + return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.ordinal()); + } + private CSSNode mParent; private List mChildren; private MeasureFunction mMeasureFunction; diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 8460e86a..65a994c1 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -105,6 +105,14 @@ void jni_CSSLog(alias_ref clazz, jint level, jstring message) { 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(); } @@ -291,6 +299,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) { CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount), CSSMakeNativeMethod(jni_CSSLayoutSetLogger), CSSMakeNativeMethod(jni_CSSLog), + CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled), + CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled), }); }); } From 204aba80b9818db0e9b6f6f74d9a2fd2580ede1c Mon Sep 17 00:00:00 2001 From: Fred Liu Date: Mon, 14 Nov 2016 12:19:26 -0800 Subject: [PATCH 042/108] Revert D4157971: [csslayout] BREAKING - Fix sizing of container with child overflowing parent Summary: This reverts commit 3cfae15ac8b65b70f01789444099ee684e1b099a Differential Revision: D4157971 fbshipit-source-id: be055cf018fd39b3cee9af0bc777831fcf757190 --- CSSLayout/CSSLayout.c | 12 +- .../Facebook.CSSLayout/CSSSizeOverflowTest.cs | 140 ------------------ gentest/fixtures/CSSSizeOverflowTest.html | 11 -- .../csslayout/CSSSizeOverflowTest.java | 136 ----------------- tests/CSSSizeOverflowTest.cpp | 128 ---------------- 5 files changed, 4 insertions(+), 423 deletions(-) delete mode 100644 csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs delete mode 100644 gentest/fixtures/CSSSizeOverflowTest.html delete mode 100644 java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java delete mode 100644 tests/CSSSizeOverflowTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 94e34421..8ba14c0a 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2092,27 +2092,23 @@ static void layoutNodeImpl(const CSSNodeRef node, // If the user didn't specify a width or height for the node, set the // dimensions based on the children. - if (measureModeMainDim == CSSMeasureModeUndefined || - (node->style.overflow != CSSOverflowScroll && measureModeMainDim == CSSMeasureModeAtMost)) { + if (measureModeMainDim == CSSMeasureModeUndefined) { // 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); - } else if (node->style.overflow == CSSOverflowScroll && - measureModeMainDim == CSSMeasureModeAtMost) { + } else if (measureModeMainDim == CSSMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, boundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), paddingAndBorderAxisMain); } - if (measureModeCrossDim == CSSMeasureModeUndefined || - (node->style.overflow != CSSOverflowScroll && measureModeCrossDim == CSSMeasureModeAtMost)) { + if (measureModeCrossDim == CSSMeasureModeUndefined) { // 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); - } else if (node->style.overflow == CSSOverflowScroll && - measureModeCrossDim == CSSMeasureModeAtMost) { + } else if (measureModeCrossDim == CSSMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, boundAxisWithinMinAndMax(node, diff --git a/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs b/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs deleted file mode 100644 index bee15ef5..00000000 --- a/csharp/tests/Facebook.CSSLayout/CSSSizeOverflowTest.cs +++ /dev/null @@ -1,140 +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. - */ - -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- * - */ - -using System; -using NUnit.Framework; - -namespace Facebook.CSSLayout -{ - [TestFixture] - public class CSSSizeOverflowTest - { - [Test] - public void Test_nested_overflowing_child() - { - CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; - - CSSNode root_child0 = new CSSNode(); - root.Insert(0, root_child0); - - CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.StyleWidth = 200; - root_child0_child0.StyleHeight = 200; - root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; - root.CalculateLayout(); - - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); - - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(200, root_child0.LayoutHeight); - - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(200, root_child0_child0.LayoutHeight); - - root.StyleDirection = CSSDirection.RightToLeft; - root.CalculateLayout(); - - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); - - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(200, root_child0.LayoutHeight); - - Assert.AreEqual(-100, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(200, root_child0_child0.LayoutHeight); - } - - [Test] - public void Test_nested_overflowing_child_in_constraint_parent() - { - CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; - - CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 100; - root_child0.StyleHeight = 100; - root.Insert(0, root_child0); - - CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.StyleWidth = 200; - root_child0_child0.StyleHeight = 200; - root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; - root.CalculateLayout(); - - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); - - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); - - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(200, root_child0_child0.LayoutHeight); - - root.StyleDirection = CSSDirection.RightToLeft; - root.CalculateLayout(); - - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); - - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); - - Assert.AreEqual(-100, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(200, root_child0_child0.LayoutHeight); - } - - } -} diff --git a/gentest/fixtures/CSSSizeOverflowTest.html b/gentest/fixtures/CSSSizeOverflowTest.html deleted file mode 100644 index fd06adba..00000000 --- a/gentest/fixtures/CSSSizeOverflowTest.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
-
- -
-
-
-
-
diff --git a/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java b/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java deleted file mode 100644 index 5394fe75..00000000 --- a/java/tests/com/facebook/csslayout/CSSSizeOverflowTest.java +++ /dev/null @@ -1,136 +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. - */ - -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- * - */ - -package com.facebook.csslayout; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class CSSSizeOverflowTest { - @Test - public void test_nested_overflowing_child() { - final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); - - final CSSNode root_child0 = new CSSNode(); - root.addChildAt(root_child0, 0); - - final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setStyleWidth(200); - root_child0_child0.setStyleHeight(200); - root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); - - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); - - root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); - - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(-100, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); - } - - @Test - public void test_nested_overflowing_child_in_constraint_parent() { - final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); - - final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(100); - root_child0.setStyleHeight(100); - root.addChildAt(root_child0, 0); - - final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setStyleWidth(200); - root_child0_child0.setStyleHeight(200); - root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); - - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); - - root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); - - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); - - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(-100, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutHeight(), 0.0f); - } - -} diff --git a/tests/CSSSizeOverflowTest.cpp b/tests/CSSSizeOverflowTest.cpp deleted file mode 100644 index 14c23ff4..00000000 --- a/tests/CSSSizeOverflowTest.cpp +++ /dev/null @@ -1,128 +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. - */ - -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- * - */ - -#include -#include - -TEST(CSSLayoutTest, nested_overflowing_child) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeInsertChild(root, root_child0, 0); - - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0_child0, 200); - CSSNodeStyleSetHeight(root_child0_child0, 200); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0)); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0)); - - ASSERT_EQ(-100, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); - - CSSNodeFreeRecursive(root); -} - -TEST(CSSLayoutTest, nested_overflowing_child_in_constraint_parent) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0, 100); - CSSNodeStyleSetHeight(root_child0, 100); - CSSNodeInsertChild(root, root_child0, 0); - - const CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetWidth(root_child0_child0, 200); - CSSNodeStyleSetHeight(root_child0_child0, 200); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); - - 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, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); - - 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(-100, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetHeight(root_child0_child0)); - - CSSNodeFreeRecursive(root); -} From 129437f49e520c38e11952b663983da11a86f680 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 14 Nov 2016 13:21:29 -0800 Subject: [PATCH 043/108] Change CLK prefix on static functions to CSS. Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS. Reviewed By: emilsjolander Differential Revision: D4175634 fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937 --- CSSLayoutKit/UIView+CSSLayout.m | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index faf3242f..1c0530df 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -162,7 +162,7 @@ NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); - CLKAttachNodesFromViewHierachy(self); + CSSAttachNodesFromViewHierachy(self); const CSSNodeRef node = [self cssNode]; CSSNodeCalculateLayout( @@ -180,7 +180,7 @@ - (void)css_applyLayout { [self css_sizeThatFits:self.bounds.size]; - CLKApplyLayoutToViewHierarchy(self); + CSSApplyLayoutToViewHierarchy(self); } #pragma mark - Private @@ -197,7 +197,7 @@ return node.cnode; } -static CSSSize CLKMeasureView( +static CSSSize CSSMeasureView( CSSNodeRef node, float width, CSSMeasureMode widthMode, @@ -214,12 +214,12 @@ static CSSSize CLKMeasureView( }]; return (CSSSize) { - .width = CLKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), - .height = CLKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), + .width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), + .height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), }; } -static CGFloat CLKSanitizeMeasurement( +static CGFloat CSSSanitizeMeasurement( CGFloat constrainedSize, CGFloat measuredSize, CSSMeasureMode measureMode) @@ -236,14 +236,14 @@ static CGFloat CLKSanitizeMeasurement( return result; } -static void CLKAttachNodesFromViewHierachy(UIView *view) { +static void CSSAttachNodesFromViewHierachy(UIView *view) { CSSNodeRef node = [view cssNode]; const BOOL usesFlexbox = [view css_usesFlexbox]; const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0; // Only leaf nodes should have a measure function if (isLeaf) { - CSSNodeSetMeasureFunc(node, CLKMeasureView); + CSSNodeSetMeasureFunc(node, CSSMeasureView); // Clear any children while (CSSNodeChildCount(node) > 0) { @@ -258,7 +258,7 @@ static void CLKAttachNodesFromViewHierachy(UIView *view) { if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) { CSSNodeInsertChild(node, childNode, i); } - CLKAttachNodesFromViewHierachy(view.subviews[i]); + CSSAttachNodesFromViewHierachy(view.subviews[i]); } // Remove any children which were removed since the last call to css_applyLayout @@ -268,7 +268,7 @@ static void CLKAttachNodesFromViewHierachy(UIView *view) { } } -static CGFloat CLKRoundPixelValue(CGFloat value) +static CGFloat CSSRoundPixelValue(CGFloat value) { static CGFloat scale; static dispatch_once_t onceToken; @@ -279,7 +279,7 @@ static CGFloat CLKRoundPixelValue(CGFloat value) return round(value * scale) / scale; } -static void CLKApplyLayoutToViewHierarchy(UIView *view) { +static void CSSApplyLayoutToViewHierarchy(UIView *view) { NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); CSSNodeRef node = [view cssNode]; @@ -295,19 +295,19 @@ static void CLKApplyLayoutToViewHierarchy(UIView *view) { view.frame = (CGRect) { .origin = { - .x = CLKRoundPixelValue(topLeft.x), - .y = CLKRoundPixelValue(topLeft.y), + .x = CSSRoundPixelValue(topLeft.x), + .y = CSSRoundPixelValue(topLeft.y), }, .size = { - .width = CLKRoundPixelValue(bottomRight.x) - CLKRoundPixelValue(topLeft.x), - .height = CLKRoundPixelValue(bottomRight.y) - CLKRoundPixelValue(topLeft.y), + .width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x), + .height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y), }, }; const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0; if (!isLeaf) { for (NSUInteger i = 0; i < view.subviews.count; i++) { - CLKApplyLayoutToViewHierarchy(view.subviews[i]); + CSSApplyLayoutToViewHierarchy(view.subviews[i]); } } } From 603321e1ab1a576d9b71608a5407beb176696b56 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 15 Nov 2016 06:24:51 -0800 Subject: [PATCH 044/108] Install and use java 8 on travis Summary: Java tests need to run with java 8, ensure travis runs java 8 Reviewed By: gkassabli Differential Revision: D4182384 fbshipit-source-id: 61ba77d3e0f008f50912d088d3e504cb96e46bdc --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8c126cdb..8b2a31f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,11 @@ before_install: - brew update - brew tap facebook/fb - brew install buck + - brew cask install java - brew outdated xctool || brew upgrade xctool - brew install mono + - export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) + - export PATH=$JAVA_HOME/bin:$PATH script: - buck test //:CSSLayout From ac4d0ab2a13c605952f26a97333e93f45a734843 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 15 Nov 2016 07:20:17 -0800 Subject: [PATCH 045/108] Count allocations relative to start of test Summary: If some test previous to this test fails to de-allocate a node we don't want this test to fail. Reviewed By: dshahidehpour Differential Revision: D4182179 fbshipit-source-id: 229dd5736d6d7b9c1b22b181e022c788584b9c17 --- CSSLayoutKit/Tests/CSSLayoutTests.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CSSLayoutKit/Tests/CSSLayoutTests.m b/CSSLayoutKit/Tests/CSSLayoutTests.m index 4eb54b19..49dea67d 100644 --- a/CSSLayoutKit/Tests/CSSLayoutTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutTests.m @@ -30,7 +30,7 @@ - (void)testNodesAreDeallocedCascade { - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + const int32_t instanceCount = CSSNodeGetInstanceCount(); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; [view css_setFlexBasis:1]; @@ -40,10 +40,10 @@ [subview css_setFlexBasis:1]; [view addSubview:subview]; } - XCTAssertEqual(11, CSSNodeGetInstanceCount()); + XCTAssertEqual(instanceCount + 11, CSSNodeGetInstanceCount()); view = nil; - XCTAssertEqual(0, CSSNodeGetInstanceCount()); + XCTAssertEqual(instanceCount, CSSNodeGetInstanceCount()); } - (void)testUsesFlexbox From d1c555fede4d0b18822926a5013bf192f4be112f Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 15 Nov 2016 08:42:33 -0800 Subject: [PATCH 046/108] Autogenerate enum defenitions for all languages Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future Reviewed By: gkassabli Differential Revision: D4174263 fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10 --- CSSLayout/CSSEnums.h | 106 ++++++++++ CSSLayout/CSSLayout.c | 5 + CSSLayout/CSSLayout.h | 91 +-------- csharp/Facebook.CSSLayout/CSSAlign.cs | 4 +- csharp/Facebook.CSSLayout/CSSDIrection.cs | 10 +- csharp/Facebook.CSSLayout/CSSDimension.cs | 4 +- csharp/Facebook.CSSLayout/CSSEdge.cs | 3 +- csharp/Facebook.CSSLayout/CSSFlexDirection.cs | 2 +- csharp/Facebook.CSSLayout/CSSJustify.cs | 2 +- csharp/Facebook.CSSLayout/CSSLogLevel.cs | 2 +- csharp/Facebook.CSSLayout/CSSMeasureMode.cs | 3 +- csharp/Facebook.CSSLayout/CSSOverflow.cs | 3 +- csharp/Facebook.CSSLayout/CSSPositionType.cs | 4 +- csharp/Facebook.CSSLayout/CSSPrintOptions.cs | 2 +- csharp/Facebook.CSSLayout/CSSWrap.cs | 2 +- enums.py | 182 ++++++++++++++++++ java/com/facebook/csslayout/CSSAlign.java | 31 ++- java/com/facebook/csslayout/CSSDimension.java | 33 ++++ java/com/facebook/csslayout/CSSDirection.java | 25 ++- java/com/facebook/csslayout/CSSEdge.java | 47 +++++ .../csslayout/CSSExperimentalFeature.java | 16 ++ .../facebook/csslayout/CSSFlexDirection.java | 28 ++- java/com/facebook/csslayout/CSSJustify.java | 31 ++- java/com/facebook/csslayout/CSSLogLevel.java | 39 ++++ java/com/facebook/csslayout/CSSLogger.java | 10 +- .../facebook/csslayout/CSSMeasureMode.java | 25 ++- java/com/facebook/csslayout/CSSNode.java | 22 +-- java/com/facebook/csslayout/CSSOverflow.java | 25 ++- .../facebook/csslayout/CSSPositionType.java | 22 ++- .../facebook/csslayout/CSSPrintOptions.java | 35 ++++ java/com/facebook/csslayout/CSSStyle.java | 2 +- java/com/facebook/csslayout/CSSWrap.java | 22 ++- java/jni/CSSJNI.cpp | 11 +- .../com/facebook/csslayout/CSSNodeTest.java | 16 +- 34 files changed, 699 insertions(+), 166 deletions(-) create mode 100644 CSSLayout/CSSEnums.h create mode 100644 enums.py create mode 100644 java/com/facebook/csslayout/CSSDimension.java create mode 100644 java/com/facebook/csslayout/CSSEdge.java create mode 100644 java/com/facebook/csslayout/CSSLogLevel.java create mode 100644 java/com/facebook/csslayout/CSSPrintOptions.java diff --git a/CSSLayout/CSSEnums.h b/CSSLayout/CSSEnums.h new file mode 100644 index 00000000..8f9979f5 --- /dev/null +++ b/CSSLayout/CSSEnums.h @@ -0,0 +1,106 @@ +/** + * 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. + */ + +typedef enum CSSOverflow { + CSSOverflowVisible, + CSSOverflowHidden, + CSSOverflowScroll, + CSSOverflowCount, +} CSSOverflow; + +typedef enum CSSJustify { + CSSJustifyFlexStart, + CSSJustifyCenter, + CSSJustifyFlexEnd, + CSSJustifySpaceBetween, + CSSJustifySpaceAround, + CSSJustifyCount, +} CSSJustify; + +typedef enum CSSFlexDirection { + CSSFlexDirectionColumn, + CSSFlexDirectionColumnReverse, + CSSFlexDirectionRow, + CSSFlexDirectionRowReverse, + CSSFlexDirectionCount, +} CSSFlexDirection; + +typedef enum CSSAlign { + CSSAlignAuto, + CSSAlignFlexStart, + CSSAlignCenter, + CSSAlignFlexEnd, + CSSAlignStretch, + CSSAlignCount, +} CSSAlign; + +typedef enum CSSEdge { + CSSEdgeLeft, + CSSEdgeTop, + CSSEdgeRight, + CSSEdgeBottom, + CSSEdgeStart, + CSSEdgeEnd, + CSSEdgeHorizontal, + CSSEdgeVertical, + CSSEdgeAll, + CSSEdgeCount, +} CSSEdge; + +typedef enum CSSWrap { + CSSWrapNoWrap, + CSSWrapWrap, + CSSWrapCount, +} CSSWrap; + +typedef enum CSSDirection { + CSSDirectionInherit, + CSSDirectionLTR, + CSSDirectionRTL, + CSSDirectionCount, +} CSSDirection; + +typedef enum CSSExperimentalFeature { + CSSExperimentalFeatureCount, +} CSSExperimentalFeature; + +typedef enum CSSLogLevel { + CSSLogLevelError, + CSSLogLevelWarn, + CSSLogLevelInfo, + CSSLogLevelDebug, + CSSLogLevelVerbose, + CSSLogLevelCount, +} CSSLogLevel; + +typedef enum CSSDimension { + CSSDimensionWidth, + CSSDimensionHeight, + CSSDimensionCount, +} CSSDimension; + +typedef enum CSSMeasureMode { + CSSMeasureModeUndefined, + CSSMeasureModeExactly, + CSSMeasureModeAtMost, + CSSMeasureModeCount, +} CSSMeasureMode; + +typedef enum CSSPositionType { + CSSPositionTypeRelative, + CSSPositionTypeAbsolute, + CSSPositionTypeCount, +} CSSPositionType; + +typedef enum CSSPrintOptions { + CSSPrintOptionsLayout = 1, + CSSPrintOptionsStyle = 2, + CSSPrintOptionsChildren = 4, + CSSPrintOptionsCount, +} CSSPrintOptions; diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 8ba14c0a..dacaceec 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -122,6 +122,8 @@ static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list a case CSSLogLevelVerbose: androidLevel = ANDROID_LOG_VERBOSE; break; + case CSSLogLevelCount: + break; } const int result = __android_log_vprint(androidLevel, "css-layout", format, args); return result; @@ -1824,6 +1826,7 @@ static void layoutNodeImpl(const CSSNodeRef node, leadingMainDim = betweenMainDim / 2; break; case CSSJustifyFlexStart: + case CSSJustifyCount: break; } @@ -2015,6 +2018,7 @@ static void layoutNodeImpl(const CSSNodeRef node, break; case CSSAlignAuto: case CSSAlignFlexStart: + case CSSAlignCount: break; } @@ -2074,6 +2078,7 @@ static void layoutNodeImpl(const CSSNodeRef node, break; } case CSSAlignAuto: + case CSSAlignCount: break; } } diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 7fdde1a8..391a458f 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -29,104 +29,15 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; #define CSSUndefined NAN #include "CSSMacros.h" +#include "CSSEnums.h" CSS_EXTERN_C_BEGIN -typedef enum CSSDirection { - CSSDirectionInherit, - CSSDirectionLTR, - CSSDirectionRTL, -} CSSDirection; - -typedef enum CSSFlexDirection { - CSSFlexDirectionColumn, - CSSFlexDirectionColumnReverse, - CSSFlexDirectionRow, - CSSFlexDirectionRowReverse, -} CSSFlexDirection; - -typedef enum CSSJustify { - CSSJustifyFlexStart, - CSSJustifyCenter, - CSSJustifyFlexEnd, - CSSJustifySpaceBetween, - CSSJustifySpaceAround, -} CSSJustify; - -typedef enum CSSOverflow { - CSSOverflowVisible, - CSSOverflowHidden, - CSSOverflowScroll, -} CSSOverflow; - -// Note: auto is only a valid value for alignSelf. It is NOT a valid value for -// alignItems. -typedef enum CSSAlign { - CSSAlignAuto, - CSSAlignFlexStart, - CSSAlignCenter, - CSSAlignFlexEnd, - CSSAlignStretch, -} CSSAlign; - -typedef enum CSSPositionType { - CSSPositionTypeRelative, - CSSPositionTypeAbsolute, -} CSSPositionType; - -typedef enum CSSWrap { - CSSWrapNoWrap, - CSSWrapWrap, -} CSSWrap; - -typedef enum CSSMeasureMode { - CSSMeasureModeUndefined, - CSSMeasureModeExactly, - CSSMeasureModeAtMost, - CSSMeasureModeCount, -} CSSMeasureMode; - -typedef enum CSSDimension { - CSSDimensionWidth, - CSSDimensionHeight, -} CSSDimension; - -typedef enum CSSEdge { - CSSEdgeLeft, - CSSEdgeTop, - CSSEdgeRight, - CSSEdgeBottom, - CSSEdgeStart, - CSSEdgeEnd, - CSSEdgeHorizontal, - CSSEdgeVertical, - CSSEdgeAll, - CSSEdgeCount, -} CSSEdge; - -typedef enum CSSPrintOptions { - CSSPrintOptionsLayout = 1, - CSSPrintOptionsStyle = 2, - CSSPrintOptionsChildren = 4, -} CSSPrintOptions; - typedef struct CSSSize { float width; float height; } CSSSize; -typedef enum CSSLogLevel { - CSSLogLevelError, - CSSLogLevelWarn, - CSSLogLevelInfo, - CSSLogLevelDebug, - CSSLogLevelVerbose, -} CSSLogLevel; - -typedef enum CSSExperimentalFeature { - CSSExperimentalFeatureCount, -} CSSExperimentalFeature; - typedef struct CSSNode *CSSNodeRef; typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float width, diff --git a/csharp/Facebook.CSSLayout/CSSAlign.cs b/csharp/Facebook.CSSLayout/CSSAlign.cs index 685fea75..94cbad3b 100644 --- a/csharp/Facebook.CSSLayout/CSSAlign.cs +++ b/csharp/Facebook.CSSLayout/CSSAlign.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -15,6 +15,6 @@ namespace Facebook.CSSLayout FlexStart, Center, FlexEnd, - Stretch + Stretch, } } diff --git a/csharp/Facebook.CSSLayout/CSSDIrection.cs b/csharp/Facebook.CSSLayout/CSSDIrection.cs index 1a455709..f350e288 100644 --- a/csharp/Facebook.CSSLayout/CSSDIrection.cs +++ b/csharp/Facebook.CSSLayout/CSSDIrection.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -12,7 +12,11 @@ namespace Facebook.CSSLayout public enum CSSDirection { Inherit, - LeftToRight, - RightToLeft + LTR, + RTL, + [System.Obsolete("Use LTR instead")] + LeftToRight = LTR, + [System.Obsolete("Use RTL instead")] + RightToLeft = RTL, } } diff --git a/csharp/Facebook.CSSLayout/CSSDimension.cs b/csharp/Facebook.CSSLayout/CSSDimension.cs index a8fd2b26..9ae6512f 100644 --- a/csharp/Facebook.CSSLayout/CSSDimension.cs +++ b/csharp/Facebook.CSSLayout/CSSDimension.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -12,6 +12,6 @@ namespace Facebook.CSSLayout public enum CSSDimension { Width, - Height + Height, } } diff --git a/csharp/Facebook.CSSLayout/CSSEdge.cs b/csharp/Facebook.CSSLayout/CSSEdge.cs index f4877f87..b639eb9e 100644 --- a/csharp/Facebook.CSSLayout/CSSEdge.cs +++ b/csharp/Facebook.CSSLayout/CSSEdge.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -20,6 +20,5 @@ namespace Facebook.CSSLayout Horizontal, Vertical, All, - Count, } } diff --git a/csharp/Facebook.CSSLayout/CSSFlexDirection.cs b/csharp/Facebook.CSSLayout/CSSFlexDirection.cs index a06f7533..24c82392 100644 --- a/csharp/Facebook.CSSLayout/CSSFlexDirection.cs +++ b/csharp/Facebook.CSSLayout/CSSFlexDirection.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * diff --git a/csharp/Facebook.CSSLayout/CSSJustify.cs b/csharp/Facebook.CSSLayout/CSSJustify.cs index 93e1566f..5f97f31b 100644 --- a/csharp/Facebook.CSSLayout/CSSJustify.cs +++ b/csharp/Facebook.CSSLayout/CSSJustify.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * diff --git a/csharp/Facebook.CSSLayout/CSSLogLevel.cs b/csharp/Facebook.CSSLayout/CSSLogLevel.cs index a0316b8d..53a5cbe8 100644 --- a/csharp/Facebook.CSSLayout/CSSLogLevel.cs +++ b/csharp/Facebook.CSSLayout/CSSLogLevel.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * diff --git a/csharp/Facebook.CSSLayout/CSSMeasureMode.cs b/csharp/Facebook.CSSLayout/CSSMeasureMode.cs index ff82545c..4b9cdd9c 100644 --- a/csharp/Facebook.CSSLayout/CSSMeasureMode.cs +++ b/csharp/Facebook.CSSLayout/CSSMeasureMode.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -14,6 +14,5 @@ namespace Facebook.CSSLayout Undefined, Exactly, AtMost, - Count, } } diff --git a/csharp/Facebook.CSSLayout/CSSOverflow.cs b/csharp/Facebook.CSSLayout/CSSOverflow.cs index df1492ec..7207668d 100644 --- a/csharp/Facebook.CSSLayout/CSSOverflow.cs +++ b/csharp/Facebook.CSSLayout/CSSOverflow.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -13,5 +13,6 @@ namespace Facebook.CSSLayout { Visible, Hidden, + Scroll, } } diff --git a/csharp/Facebook.CSSLayout/CSSPositionType.cs b/csharp/Facebook.CSSLayout/CSSPositionType.cs index ac12484d..11b9ebde 100644 --- a/csharp/Facebook.CSSLayout/CSSPositionType.cs +++ b/csharp/Facebook.CSSLayout/CSSPositionType.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * @@ -12,6 +12,6 @@ namespace Facebook.CSSLayout public enum CSSPositionType { Relative, - Absolute + Absolute, } } diff --git a/csharp/Facebook.CSSLayout/CSSPrintOptions.cs b/csharp/Facebook.CSSLayout/CSSPrintOptions.cs index 8d608f4e..1df7d381 100644 --- a/csharp/Facebook.CSSLayout/CSSPrintOptions.cs +++ b/csharp/Facebook.CSSLayout/CSSPrintOptions.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * diff --git a/csharp/Facebook.CSSLayout/CSSWrap.cs b/csharp/Facebook.CSSLayout/CSSWrap.cs index 15425b28..34d2e4c2 100644 --- a/csharp/Facebook.CSSLayout/CSSWrap.cs +++ b/csharp/Facebook.CSSLayout/CSSWrap.cs @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * diff --git a/enums.py b/enums.py new file mode 100644 index 00000000..40f36d5a --- /dev/null +++ b/enums.py @@ -0,0 +1,182 @@ +# 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. + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import os + +ENUMS = { + 'CSSDirection': [ + 'Inherit', + 'LTR', + 'RTL', + ], + 'CSSFlexDirection': [ + 'Column', + 'ColumnReverse', + 'Row', + 'RowReverse', + ], + 'CSSJustify': [ + 'FlexStart', + 'Center', + 'FlexEnd', + 'SpaceBetween', + 'SpaceAround', + ], + 'CSSOverflow': [ + 'Visible', + 'Hidden', + 'Scroll', + ], + 'CSSAlign': [ + 'Auto', + 'FlexStart', + 'Center', + 'FlexEnd', + 'Stretch', + ], + 'CSSPositionType': [ + 'Relative', + 'Absolute', + ], + 'CSSWrap': [ + 'NoWrap', + 'Wrap', + ], + 'CSSMeasureMode': [ + 'Undefined', + 'Exactly', + 'AtMost', + ], + 'CSSDimension': [ + 'Width', + 'Height', + ], + 'CSSEdge': [ + 'Left', + 'Top', + 'Right', + 'Bottom', + 'Start', + 'End', + 'Horizontal', + 'Vertical', + 'All', + ], + 'CSSLogLevel': [ + 'Error', + 'Warn', + 'Info', + 'Debug', + 'Verbose', + ], + 'CSSExperimentalFeature': [], + 'CSSPrintOptions': [ + ('Layout', 1), + ('Style', 2), + ('Children', 4), + ], +} + +LICENSE = """/** + * 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. + */ + +""" + +def to_java_upper(symbol): + symbol = str(symbol) + out = '' + for i in range(0, len(symbol)): + c = symbol[i] + if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]): + out += '_' + out += c.upper() + return out + + +root = os.path.dirname(__file__) + +# write out C header +with open(root + '/CSSLayout/CSSEnums.h', 'w') as f: + f.write(LICENSE) + remaining = len(ENUMS) + for name, values in ENUMS.items(): + f.write('typedef enum %s {\n' % name) + for value in values: + if isinstance(value, tuple): + f.write(' %s%s = %d,\n' % (name, value[0], value[1])) + else: + f.write(' %s%s,\n' % (name, value)) + f.write(' %sCount,\n' % name) + f.write('} %s;\n' % name) + if remaining > 1: + f.write('\n') + remaining = remaining - 1 + +# write out java files +for name, values in ENUMS.items(): + with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f: + f.write(LICENSE) + f.write('package com.facebook.csslayout;\n\n') + f.write('public enum %s {\n' % name) + if len(values) > 0: + for value in values: + if isinstance(value, tuple): + f.write(' %s(%d)' % (to_java_upper(value[0]), value[1])) + else: + f.write(' %s(%d)' % (to_java_upper(value), values.index(value))) + if values.index(value) is len(values) - 1: + f.write(';\n') + else: + f.write(',\n') + else: + f.write('__EMPTY(-1);') + f.write('\n') + f.write(' private int mIntValue;\n') + f.write('\n') + f.write(' %s(int intValue) {\n' % name) + f.write(' mIntValue = intValue;\n') + f.write(' }\n') + f.write('\n') + f.write(' public int intValue() {\n') + f.write(' return mIntValue;\n') + f.write(' }\n') + f.write('\n') + f.write(' public static %s fromInt(int value) {\n' % name) + f.write(' switch (value) {\n') + for value in values: + if isinstance(value, tuple): + f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0]))) + else: + f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value))) + f.write(' default: throw new IllegalArgumentException("Unkown enum value: " + value);\n') + f.write(' }\n') + f.write(' }\n') + f.write('}\n') + +# write out csharp files +for name, values in ENUMS.items(): + with open(root + '/csharp/Facebook.CSSLayout/%s.cs' % name, 'w') as f: + f.write(LICENSE) + f.write('namespace Facebook.CSSLayout\n{\n') + f.write(' public enum %s\n {\n' % name) + for value in values: + if isinstance(value, tuple): + f.write(' %s = %d,\n' % (value[0], value[1])) + else: + f.write(' %s,\n' % value) + f.write(' }\n') + f.write('}\n') diff --git a/java/com/facebook/csslayout/CSSAlign.java b/java/com/facebook/csslayout/CSSAlign.java index 3e3cb0e9..2dedee0b 100644 --- a/java/com/facebook/csslayout/CSSAlign.java +++ b/java/com/facebook/csslayout/CSSAlign.java @@ -10,9 +10,30 @@ package com.facebook.csslayout; public enum CSSAlign { - AUTO, - FLEX_START, - CENTER, - FLEX_END, - STRETCH, + AUTO(0), + FLEX_START(1), + CENTER(2), + FLEX_END(3), + STRETCH(4); + + private int mIntValue; + + CSSAlign(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSAlign fromInt(int value) { + switch (value) { + case 0: return AUTO; + case 1: return FLEX_START; + case 2: return CENTER; + case 3: return FLEX_END; + case 4: return STRETCH; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSDimension.java b/java/com/facebook/csslayout/CSSDimension.java new file mode 100644 index 00000000..e3fde021 --- /dev/null +++ b/java/com/facebook/csslayout/CSSDimension.java @@ -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. + */ + +package com.facebook.csslayout; + +public enum CSSDimension { + WIDTH(0), + HEIGHT(1); + + private int mIntValue; + + CSSDimension(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSDimension fromInt(int value) { + switch (value) { + case 0: return WIDTH; + case 1: return HEIGHT; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } +} diff --git a/java/com/facebook/csslayout/CSSDirection.java b/java/com/facebook/csslayout/CSSDirection.java index 0c27a929..c0e84f1a 100644 --- a/java/com/facebook/csslayout/CSSDirection.java +++ b/java/com/facebook/csslayout/CSSDirection.java @@ -10,7 +10,26 @@ package com.facebook.csslayout; public enum CSSDirection { - INHERIT, - LTR, - RTL, + INHERIT(0), + LTR(1), + RTL(2); + + private int mIntValue; + + CSSDirection(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSDirection fromInt(int value) { + switch (value) { + case 0: return INHERIT; + case 1: return LTR; + case 2: return RTL; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSEdge.java b/java/com/facebook/csslayout/CSSEdge.java new file mode 100644 index 00000000..50d184e3 --- /dev/null +++ b/java/com/facebook/csslayout/CSSEdge.java @@ -0,0 +1,47 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +public enum CSSEdge { + LEFT(0), + TOP(1), + RIGHT(2), + BOTTOM(3), + START(4), + END(5), + HORIZONTAL(6), + VERTICAL(7), + ALL(8); + + private int mIntValue; + + CSSEdge(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSEdge fromInt(int value) { + switch (value) { + case 0: return LEFT; + case 1: return TOP; + case 2: return RIGHT; + case 3: return BOTTOM; + case 4: return START; + case 5: return END; + case 6: return HORIZONTAL; + case 7: return VERTICAL; + case 8: return ALL; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } +} diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/CSSExperimentalFeature.java index a92d522d..e0b269f9 100644 --- a/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -10,4 +10,20 @@ package com.facebook.csslayout; public enum CSSExperimentalFeature { +__EMPTY(-1); + private int mIntValue; + + CSSExperimentalFeature(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSExperimentalFeature fromInt(int value) { + switch (value) { + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSFlexDirection.java b/java/com/facebook/csslayout/CSSFlexDirection.java index 30f92bd0..10e5cd6a 100644 --- a/java/com/facebook/csslayout/CSSFlexDirection.java +++ b/java/com/facebook/csslayout/CSSFlexDirection.java @@ -10,8 +10,28 @@ package com.facebook.csslayout; public enum CSSFlexDirection { - COLUMN, - COLUMN_REVERSE, - ROW, - ROW_REVERSE + COLUMN(0), + COLUMN_REVERSE(1), + ROW(2), + ROW_REVERSE(3); + + private int mIntValue; + + CSSFlexDirection(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSFlexDirection fromInt(int value) { + switch (value) { + case 0: return COLUMN; + case 1: return COLUMN_REVERSE; + case 2: return ROW; + case 3: return ROW_REVERSE; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSJustify.java b/java/com/facebook/csslayout/CSSJustify.java index dfcc1cd2..2d36a85f 100644 --- a/java/com/facebook/csslayout/CSSJustify.java +++ b/java/com/facebook/csslayout/CSSJustify.java @@ -10,9 +10,30 @@ package com.facebook.csslayout; public enum CSSJustify { - FLEX_START, - CENTER, - FLEX_END, - SPACE_BETWEEN, - SPACE_AROUND, + FLEX_START(0), + CENTER(1), + FLEX_END(2), + SPACE_BETWEEN(3), + SPACE_AROUND(4); + + private int mIntValue; + + CSSJustify(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSJustify fromInt(int value) { + switch (value) { + case 0: return FLEX_START; + case 1: return CENTER; + case 2: return FLEX_END; + case 3: return SPACE_BETWEEN; + case 4: return SPACE_AROUND; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSLogLevel.java b/java/com/facebook/csslayout/CSSLogLevel.java new file mode 100644 index 00000000..94551bc0 --- /dev/null +++ b/java/com/facebook/csslayout/CSSLogLevel.java @@ -0,0 +1,39 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +public enum CSSLogLevel { + ERROR(0), + WARN(1), + INFO(2), + DEBUG(3), + VERBOSE(4); + + private int mIntValue; + + CSSLogLevel(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSLogLevel fromInt(int value) { + switch (value) { + case 0: return ERROR; + case 1: return WARN; + case 2: return INFO; + case 3: return DEBUG; + case 4: return VERBOSE; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } +} diff --git a/java/com/facebook/csslayout/CSSLogger.java b/java/com/facebook/csslayout/CSSLogger.java index 44536c46..f1f28fe2 100644 --- a/java/com/facebook/csslayout/CSSLogger.java +++ b/java/com/facebook/csslayout/CSSLogger.java @@ -13,15 +13,9 @@ import com.facebook.proguard.annotations.DoNotStrip; /** * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); - * LOG_LEVEL_ERROR indicated a fatal error. + * See CSSLogLevel for the different log levels. */ public interface CSSLogger { - public final int LOG_LEVEL_ERROR = 0; - public final int LOG_LEVEL_WARN = 1; - public final int LOG_LEVEL_INFO = 2; - public final int LOG_LEVEL_DEBUG = 3; - public final int LOG_LEVEL_VERBOSE = 4; - @DoNotStrip - void log(int level, String message); + void log(CSSLogLevel level, String message); } diff --git a/java/com/facebook/csslayout/CSSMeasureMode.java b/java/com/facebook/csslayout/CSSMeasureMode.java index e8ebb34f..d2c69e6f 100644 --- a/java/com/facebook/csslayout/CSSMeasureMode.java +++ b/java/com/facebook/csslayout/CSSMeasureMode.java @@ -10,7 +10,26 @@ package com.facebook.csslayout; public enum CSSMeasureMode { - UNDEFINED, - EXACTLY, - AT_MOST, + UNDEFINED(0), + EXACTLY(1), + AT_MOST(2); + + private int mIntValue; + + CSSMeasureMode(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSMeasureMode fromInt(int value) { + switch (value) { + case 0: return UNDEFINED; + case 1: return EXACTLY; + case 2: return AT_MOST; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 6c3419bc..e92f9267 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -46,12 +46,12 @@ public class CSSNode implements CSSNodeAPI { public static void setExperimentalFeatureEnabled( CSSExperimentalFeature feature, boolean enabled) { - jni_CSSLayoutSetExperimentalFeatureEnabled(feature.ordinal(), enabled); + jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled); } private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature); public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) { - return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.ordinal()); + return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue()); } private CSSNode mParent; @@ -199,7 +199,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction); @Override public void setDirection(CSSDirection direction) { - jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal()); + jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue()); } private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer); @@ -211,7 +211,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection); @Override public void setFlexDirection(CSSFlexDirection flexDirection) { - jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.ordinal()); + jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue()); } private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer); @@ -223,7 +223,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent); @Override public void setJustifyContent(CSSJustify justifyContent) { - jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.ordinal()); + jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue()); } private native int jni_CSSNodeStyleGetAlignItems(long nativePointer); @@ -235,7 +235,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems); @Override public void setAlignItems(CSSAlign alignItems) { - jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.ordinal()); + jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue()); } private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer); @@ -247,7 +247,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf); @Override public void setAlignSelf(CSSAlign alignSelf) { - jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.ordinal()); + jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue()); } private native int jni_CSSNodeStyleGetAlignContent(long nativePointer); @@ -259,7 +259,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent); @Override public void setAlignContent(CSSAlign alignContent) { - jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.ordinal()); + jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue()); } private native int jni_CSSNodeStyleGetPositionType(long nativePointer); @@ -271,13 +271,13 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType); @Override public void setPositionType(CSSPositionType positionType) { - jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.ordinal()); + jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue()); } private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType); @Override public void setWrap(CSSWrap flexWrap) { - jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.ordinal()); + jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue()); } private native int jni_CSSNodeStyleGetOverflow(long nativePointer); @@ -289,7 +289,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow); @Override public void setOverflow(CSSOverflow overflow) { - jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.ordinal()); + jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue()); } private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex); diff --git a/java/com/facebook/csslayout/CSSOverflow.java b/java/com/facebook/csslayout/CSSOverflow.java index 9aae8225..8ba708ae 100644 --- a/java/com/facebook/csslayout/CSSOverflow.java +++ b/java/com/facebook/csslayout/CSSOverflow.java @@ -10,7 +10,26 @@ package com.facebook.csslayout; public enum CSSOverflow { - VISIBLE, - HIDDEN, - SCROLL, + VISIBLE(0), + HIDDEN(1), + SCROLL(2); + + private int mIntValue; + + CSSOverflow(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSOverflow fromInt(int value) { + switch (value) { + case 0: return VISIBLE; + case 1: return HIDDEN; + case 2: return SCROLL; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSPositionType.java b/java/com/facebook/csslayout/CSSPositionType.java index 19e27dd4..4dcaa0df 100644 --- a/java/com/facebook/csslayout/CSSPositionType.java +++ b/java/com/facebook/csslayout/CSSPositionType.java @@ -10,6 +10,24 @@ package com.facebook.csslayout; public enum CSSPositionType { - RELATIVE, - ABSOLUTE, + RELATIVE(0), + ABSOLUTE(1); + + private int mIntValue; + + CSSPositionType(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSPositionType fromInt(int value) { + switch (value) { + case 0: return RELATIVE; + case 1: return ABSOLUTE; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/com/facebook/csslayout/CSSPrintOptions.java b/java/com/facebook/csslayout/CSSPrintOptions.java new file mode 100644 index 00000000..ec83ab47 --- /dev/null +++ b/java/com/facebook/csslayout/CSSPrintOptions.java @@ -0,0 +1,35 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +public enum CSSPrintOptions { + LAYOUT(1), + STYLE(2), + CHILDREN(4); + + private int mIntValue; + + CSSPrintOptions(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSPrintOptions fromInt(int value) { + switch (value) { + case 1: return LAYOUT; + case 2: return STYLE; + case 4: return CHILDREN; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } +} diff --git a/java/com/facebook/csslayout/CSSStyle.java b/java/com/facebook/csslayout/CSSStyle.java index c17ce527..916e54e2 100644 --- a/java/com/facebook/csslayout/CSSStyle.java +++ b/java/com/facebook/csslayout/CSSStyle.java @@ -54,7 +54,7 @@ public class CSSStyle { alignItems = CSSAlign.STRETCH; alignSelf = CSSAlign.AUTO; positionType = CSSPositionType.RELATIVE; - flexWrap = CSSWrap.NOWRAP; + flexWrap = CSSWrap.NO_WRAP; overflow = CSSOverflow.VISIBLE; flexGrow = 0; flexShrink = 0; diff --git a/java/com/facebook/csslayout/CSSWrap.java b/java/com/facebook/csslayout/CSSWrap.java index 895bb5d5..69a59056 100644 --- a/java/com/facebook/csslayout/CSSWrap.java +++ b/java/com/facebook/csslayout/CSSWrap.java @@ -10,6 +10,24 @@ package com.facebook.csslayout; public enum CSSWrap { - NOWRAP, - WRAP, + NO_WRAP(0), + WRAP(1); + + private int mIntValue; + + CSSWrap(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static CSSWrap fromInt(int value) { + switch (value) { + case 0: return NO_WRAP; + case 1: return WRAP; + default: throw new IllegalArgumentException("Unkown enum value: " + value); + } + } } diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 65a994c1..f3bad806 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -68,14 +68,21 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, return CSSSize{measuredWidth, measuredHeight}; } +struct JCSSLogLevel : public JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/CSSLogLevel;"; +}; + static global_ref *jLogger; static int _jniLog(CSSLogLevel 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("log"); - logFunc(jLogger->get(), static_cast(level), Environment::current()->NewStringUTF(buffer)); + findClassLocal("com/facebook/csslayout/CSSLogger")->getMethod, jstring)>("log"); + + static auto logLevelFromInt = JCSSLogLevel::javaClassStatic()->getStaticMethod("fromInt"); + + logFunc(jLogger->get(), logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast(level)), Environment::current()->NewStringUTF(buffer)); return result; } diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index 5f2d3ae2..3b857279 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -40,35 +40,35 @@ public class CSSNodeTest { assertEquals(100, (int) node.getLayoutHeight()); } - private int mLogLevel; + private CSSLogLevel mLogLevel; private String mLogMessage; @Test public void testLogger() { CSSNode.setLogger(new CSSLogger() { - public void log(int level, String message) { + public void log(CSSLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_DEBUG, "Hello"); - assertEquals(CSSLogger.LOG_LEVEL_DEBUG, mLogLevel); + CSSNode.jni_CSSLog(CSSLogLevel.DEBUG.intValue(), "Hello"); + assertEquals(CSSLogLevel.DEBUG, mLogLevel); assertEquals("Hello", mLogMessage); } @Test public void testUpdateLogger() { CSSNode.setLogger(new CSSLogger() { - public void log(int level, String message) {} + public void log(CSSLogLevel level, String message) {} }); CSSNode.setLogger(new CSSLogger() { - public void log(int level, String message) { + public void log(CSSLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_VERBOSE, "Flexbox"); - assertEquals(CSSLogger.LOG_LEVEL_VERBOSE, mLogLevel); + CSSNode.jni_CSSLog(CSSLogLevel.VERBOSE.intValue(), "Flexbox"); + assertEquals(CSSLogLevel.VERBOSE, mLogLevel); assertEquals("Flexbox", mLogMessage); } } From d80bac4234700407f2247715ec16275b08d8416b Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Tue, 15 Nov 2016 09:08:51 -0800 Subject: [PATCH 047/108] Use LTR and RTL instead obsolete enums Summary: Use LTR and RTL instead obsolete LeftToRight and RightToLeft enums Reviewed By: emilsjolander Differential Revision: D4175897 fbshipit-source-id: d22af46d3292f9ad1754f571e95cb64b11722f7b --- .../CSSLayoutAbsolutePositionTest.cs | 24 +++++------ .../CSSLayoutAlignContentTest.cs | 16 ++++---- .../CSSLayoutAlignItemsTest.cs | 16 ++++---- .../CSSLayoutAlignSelfTest.cs | 16 ++++---- .../Facebook.CSSLayout/CSSLayoutBorderTest.cs | 20 +++++----- .../CSSLayoutFlexDirectionTest.cs | 24 +++++------ .../Facebook.CSSLayout/CSSLayoutFlexTest.cs | 28 ++++++------- .../CSSLayoutFlexWrapTest.cs | 16 ++++---- .../CSSLayoutJustifyContentTest.cs | 40 +++++++++---------- .../Facebook.CSSLayout/CSSLayoutMarginTest.cs | 40 +++++++++---------- .../CSSLayoutMinMaxDimensionTest.cs | 36 ++++++++--------- .../CSSLayoutPaddingTest.cs | 20 +++++----- gentest/gentest-cs.js | 4 +- 13 files changed, 150 insertions(+), 150 deletions(-) diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index c1884387..08c75a6b 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -61,7 +61,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -74,7 +74,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -102,7 +102,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -115,7 +115,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -143,7 +143,7 @@ namespace Facebook.CSSLayout root_child0.SetPosition(CSSEdge.End, 10); root_child0.SetPosition(CSSEdge.Bottom, 10); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -156,7 +156,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -186,7 +186,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -199,7 +199,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -232,7 +232,7 @@ namespace Facebook.CSSLayout root_child0_child0.StyleWidth = 100; root_child0_child0.StyleHeight = 100; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -250,7 +250,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -303,7 +303,7 @@ namespace Facebook.CSSLayout root_child1.StyleWidth = 50; root_child1.StyleHeight = 50; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(10, root.LayoutX); @@ -321,7 +321,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(10, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs index 4ceef498..8542ca47 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs @@ -84,7 +84,7 @@ namespace Facebook.CSSLayout root_child4.StyleWidth = 50; root_child4.StyleHeight = 10; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -117,7 +117,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(10, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -184,7 +184,7 @@ namespace Facebook.CSSLayout root_child4.StyleWidth = 50; root_child4.StyleHeight = 10; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -217,7 +217,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(10, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -284,7 +284,7 @@ namespace Facebook.CSSLayout root_child4.StyleWidth = 50; root_child4.StyleHeight = 10; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -317,7 +317,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(10, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -379,7 +379,7 @@ namespace Facebook.CSSLayout CSSNode root_child4 = new CSSNode(); root_child4.StyleWidth = 50; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -412,7 +412,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(0, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs index 17bc2355..852a497d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs @@ -46,7 +46,7 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -59,7 +59,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -98,7 +98,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -124,7 +124,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -137,7 +137,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -163,7 +163,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -176,7 +176,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs index ba34aaa8..6d65e321 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs @@ -48,7 +48,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -61,7 +61,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -87,7 +87,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -100,7 +100,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -126,7 +126,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -139,7 +139,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -166,7 +166,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -179,7 +179,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs index 2fb8edea..e0c6a7f8 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs @@ -47,7 +47,7 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Bottom, 10); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -55,7 +55,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20, root.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -77,7 +77,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -90,7 +90,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -119,7 +119,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.StyleWidth = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -132,7 +132,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(80, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -160,7 +160,7 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -173,7 +173,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -203,7 +203,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -216,7 +216,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs index 6b4a4dc1..024641d6 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs @@ -73,7 +73,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -96,7 +96,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -138,7 +138,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -161,7 +161,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(100, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -203,7 +203,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -226,7 +226,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -269,7 +269,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -292,7 +292,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(100, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -335,7 +335,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -358,7 +358,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -401,7 +401,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -424,7 +424,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(100, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs index 72042ac2..54c3e398 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs @@ -73,7 +73,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -91,7 +91,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(25, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -126,7 +126,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -144,7 +144,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(25, root_child1.LayoutWidth); Assert.AreEqual(100, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -178,7 +178,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexBasis = 50; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -196,7 +196,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(50, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -231,7 +231,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexBasis = 50; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -249,7 +249,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(100, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -289,7 +289,7 @@ namespace Facebook.CSSLayout root_child2.StyleWidth = 50; root_child2.StyleHeight = 50; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -312,7 +312,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -358,7 +358,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1; root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -381,7 +381,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(20, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -419,7 +419,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1; root_child0_child0.FlexShrink = 1; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -437,7 +437,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(0, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs index 2a0b3f8c..a22d2676 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs @@ -74,7 +74,7 @@ namespace Facebook.CSSLayout root_child3.StyleWidth = 30; root_child3.StyleHeight = 30; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -102,7 +102,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -158,7 +158,7 @@ namespace Facebook.CSSLayout root_child3.StyleWidth = 30; root_child3.StyleHeight = 30; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -186,7 +186,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -243,7 +243,7 @@ namespace Facebook.CSSLayout root_child3.StyleWidth = 30; root_child3.StyleHeight = 30; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -271,7 +271,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -328,7 +328,7 @@ namespace Facebook.CSSLayout root_child3.StyleWidth = 30; root_child3.StyleHeight = 30; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -356,7 +356,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs index b1368e8e..7055c3a5 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs @@ -99,7 +99,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -122,7 +122,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(102, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -166,7 +166,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -189,7 +189,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(102, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -233,7 +233,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -256,7 +256,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(102, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -300,7 +300,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -323,7 +323,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(102, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -367,7 +367,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleWidth = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -390,7 +390,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(102, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -431,7 +431,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -454,7 +454,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -497,7 +497,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -520,7 +520,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -563,7 +563,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -586,7 +586,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -629,7 +629,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -652,7 +652,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -695,7 +695,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.StyleHeight = 10; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -718,7 +718,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102, root_child2.LayoutWidth); Assert.AreEqual(10, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs index 7e7955ea..7501c59d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs @@ -74,7 +74,7 @@ namespace Facebook.CSSLayout root_child0.SetMargin(CSSEdge.Start, 10); root_child0.StyleWidth = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -87,7 +87,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(100, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -112,7 +112,7 @@ namespace Facebook.CSSLayout root_child0.SetMargin(CSSEdge.Top, 10); root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -125,7 +125,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -152,7 +152,7 @@ namespace Facebook.CSSLayout root_child0.SetMargin(CSSEdge.End, 10); root_child0.StyleWidth = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -165,7 +165,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(100, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -191,7 +191,7 @@ namespace Facebook.CSSLayout root_child0.SetMargin(CSSEdge.Bottom, 10); root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -204,7 +204,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -230,7 +230,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.SetMargin(CSSEdge.Start, 10); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -243,7 +243,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(100, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -268,7 +268,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.SetMargin(CSSEdge.Top, 10); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -281,7 +281,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(90, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -307,7 +307,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.SetMargin(CSSEdge.Top, 10); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -320,7 +320,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(90, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -345,7 +345,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.SetMargin(CSSEdge.Start, 10); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -358,7 +358,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(100, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -387,7 +387,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -405,7 +405,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(100, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -438,7 +438,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -456,7 +456,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(50, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index 8365a082..69d8996f 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -75,7 +75,7 @@ namespace Facebook.CSSLayout root_child0.StyleMaxWidth = 50; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -88,7 +88,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -114,7 +114,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleMaxHeight = 50; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -127,7 +127,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(50, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -156,7 +156,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -174,7 +174,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(20, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -209,7 +209,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -227,7 +227,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20, root_child1.LayoutWidth); Assert.AreEqual(100, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -259,7 +259,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 60; root_child0.StyleHeight = 60; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -272,7 +272,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -299,7 +299,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 60; root_child0.StyleHeight = 60; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -312,7 +312,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -348,7 +348,7 @@ namespace Facebook.CSSLayout root_child2.StyleWidth = 50; root_child2.StyleHeight = 50; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -371,7 +371,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -411,7 +411,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1; root_child0_child0.StyleHeight = 20; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -429,7 +429,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(20, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -464,7 +464,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1; root_child0_child0.StyleHeight = 20; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -482,7 +482,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(200, root_child0_child0.LayoutWidth); Assert.AreEqual(20, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs index 8ede76d2..576cacec 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs @@ -47,7 +47,7 @@ namespace Facebook.CSSLayout root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Bottom, 10); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -55,7 +55,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20, root.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -77,7 +77,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -90,7 +90,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -119,7 +119,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1; root_child0.StyleWidth = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -132,7 +132,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(80, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -160,7 +160,7 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -173,7 +173,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -203,7 +203,7 @@ namespace Facebook.CSSLayout root_child0.StyleWidth = 10; root_child0.StyleHeight = 10; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LeftToRight; + root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); @@ -216,7 +216,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RightToLeft; + root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0, root.LayoutX); diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 194b845a..f96d557f 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -71,8 +71,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { CSSAlignStretch:{value:'CSSAlign.Stretch'}, CSSDirectionInherit:{value:'CSSDirection.Inherit'}, - CSSDirectionLTR:{value:'CSSDirection.LeftToRight'}, - CSSDirectionRTL:{value:'CSSDirection.RightToLeft'}, + CSSDirectionLTR:{value:'CSSDirection.LTR'}, + CSSDirectionRTL:{value:'CSSDirection.RTL'}, CSSEdgeBottom:{value:'CSSEdge.Bottom'}, CSSEdgeEnd:{value:'CSSEdge.End'}, From 667858990c0ce953d42eb3bf01822f3295023dce Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Tue, 15 Nov 2016 17:36:23 -0800 Subject: [PATCH 048/108] Fix build Summary: Fix C# build Reviewed By: emilsjolander Differential Revision: D4183287 fbshipit-source-id: 7dda449a940589de1d37f4024964a6512ab123e3 --- csharp/Facebook.CSSLayout/CSSNode.cs | 2 +- csharp/Facebook.CSSLayout/Native.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 95547abf..985aa650 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -555,7 +555,7 @@ namespace Facebook.CSSLayout CSSExperimentalFeature feature, bool enabled) { - return Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); + Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); } public static bool isExperimentalFeatureEnabled(CSSExperimentalFeature feature) diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index c734e1f6..fa3a8654 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -36,6 +36,9 @@ namespace Facebook.CSSLayout [DllImport(DllName)] public static extern void CSSNodeReset(IntPtr cssNode); + [DllImport(DllName)] + public static extern int CSSNodeGetInstanceCount(); + [DllImport(DllName)] public static extern void CSSLayoutSetExperimentalFeatureEnabled( CSSExperimentalFeature feature, From ef81d4b0c757ad2e4942a7edcc16c28817faf152 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Tue, 15 Nov 2016 20:20:09 -0800 Subject: [PATCH 049/108] Introduce CSSLayoutSetMemoryFuncs Summary: - Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib. - Fixed memory leaks in tests. - Close #247 For example, to use dlmalloc with USE_DL_PREFIX CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree); Reviewed By: emilsjolander Differential Revision: D4178386 fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b --- CSSLayout/CSSLayout.c | 32 ++++++++++++- CSSLayout/CSSLayout.h | 10 ++++ CSSLayout/CSSNodeList.c | 14 ++++-- tests/CSSLayoutDirtyMarkingTest.cpp | 5 +- tests/CSSLayoutMeasureTest.cpp | 3 ++ tests/CSSLayoutMemoryFuncTest.cpp | 71 +++++++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 tests/CSSLayoutMemoryFuncTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index dacaceec..6dc0f7bc 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -102,6 +102,11 @@ typedef struct CSSNode { static void _CSSNodeMarkDirty(const CSSNodeRef node); +CSSMalloc gCSSMalloc = &malloc; +CSSCalloc gCSSCalloc = &calloc; +CSSRealloc gCSSRealloc = &realloc; +CSSFree gCSSFree = &free; + #ifdef ANDROID #include static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) { @@ -178,7 +183,7 @@ static inline float computedEdgeValue(const float edges[CSSEdgeCount], static int32_t gNodeInstanceCount = 0; CSSNodeRef CSSNodeNew(void) { - const CSSNodeRef node = calloc(1, sizeof(CSSNode)); + const CSSNodeRef node = gCSSCalloc(1, sizeof(CSSNode)); CSS_ASSERT(node, "Could not allocate memory for node"); gNodeInstanceCount++; @@ -199,7 +204,7 @@ void CSSNodeFree(const CSSNodeRef node) { } CSSNodeListFree(node->children); - free(node); + gCSSFree(node); gNodeInstanceCount--; } @@ -2523,3 +2528,26 @@ void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature 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"); + + if (cssMalloc == NULL || cssCalloc == NULL || cssRealloc == NULL || cssFree == NULL) { + gCSSMalloc = &malloc; + gCSSCalloc = &calloc; + gCSSRealloc = &realloc; + gCSSFree = &free; + } else { + gCSSMalloc = cssMalloc; + gCSSCalloc = cssCalloc; + gCSSRealloc = cssRealloc; + gCSSFree = cssFree; + } +} diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 391a458f..07a8f6ec 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -47,6 +47,11 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, typedef void (*CSSPrintFunc)(CSSNodeRef node); typedef int (*CSSLogger)(CSSLogLevel 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); @@ -156,4 +161,9 @@ WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled); WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature 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 index d48cf4b3..886f78cb 100644 --- a/CSSLayout/CSSNodeList.c +++ b/CSSLayout/CSSNodeList.c @@ -9,6 +9,10 @@ #include "CSSNodeList.h" +extern CSSMalloc gCSSMalloc; +extern CSSRealloc gCSSRealloc; +extern CSSFree gCSSFree; + struct CSSNodeList { uint32_t capacity; uint32_t count; @@ -16,12 +20,12 @@ struct CSSNodeList { }; CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) { - const CSSNodeListRef list = malloc(sizeof(struct CSSNodeList)); + 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 = malloc(sizeof(CSSNodeRef) * list->capacity); + list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity); CSS_ASSERT(list->items != NULL, "Could not allocate memory for items"); return list; @@ -29,8 +33,8 @@ CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) { void CSSNodeListFree(const CSSNodeListRef list) { if (list) { - free(list->items); - free(list); + gCSSFree(list->items); + gCSSFree(list); } } @@ -56,7 +60,7 @@ void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint3 if (list->count == list->capacity) { list->capacity *= 2; - list->items = realloc(list->items, sizeof(CSSNodeRef) * list->capacity); + list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity); CSS_ASSERT(list->items != NULL, "Could not extend allocation for items"); } diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/CSSLayoutDirtyMarkingTest.cpp index 7bafe352..fed544f3 100644 --- a/tests/CSSLayoutDirtyMarkingTest.cpp +++ b/tests/CSSLayoutDirtyMarkingTest.cpp @@ -83,11 +83,14 @@ TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) { CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - CSSNodeRemoveChild(root, CSSNodeNew()); + const CSSNodeRef child1 = CSSNodeNew(); + CSSNodeRemoveChild(root, child1); EXPECT_FALSE(CSSNodeIsDirty(root)); + CSSNodeFree(child1); CSSNodeRemoveChild(root, child0); EXPECT_TRUE(CSSNodeIsDirty(root)); + CSSNodeFree(child0); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index e31063c2..23ff7da3 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -43,6 +43,8 @@ TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); ASSERT_EQ(0, measureCount); + + CSSNodeFreeRecursive(root); } #if GTEST_HAS_DEATH_TEST @@ -52,6 +54,7 @@ TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) { const CSSNodeRef root_child0 = CSSNodeNew(); ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*"); + CSSNodeFree(root_child0); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMemoryFuncTest.cpp b/tests/CSSLayoutMemoryFuncTest.cpp new file mode 100644 index 00000000..ade4b6f7 --- /dev/null +++ b/tests/CSSLayoutMemoryFuncTest.cpp @@ -0,0 +1,71 @@ +/** + * 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 + +static int testMallocCount; +static int testCallocCount; +static int testReallocCount; +static int testFreeCount; + +static void *testMalloc(size_t size) { + testMallocCount++; + return malloc(size); +} + +static void *testCalloc(size_t count, size_t size) { + testCallocCount++; + return calloc(count, size); +} + +static void *testRealloc(void *ptr, size_t size) { + testReallocCount++; + return realloc(ptr, size); +} + +static void testFree(void *ptr) { + testFreeCount++; + free(ptr); +} + +TEST(CSSLayoutTest, memory_func_default) { + CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL); + const CSSNodeRef root = CSSNodeNew(); + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeInsertChild(root, root_child0, 0); + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, memory_func_test_funcs) { + CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree); + const CSSNodeRef root = CSSNodeNew(); + for (int i = 0; i < 10; i++) { + const CSSNodeRef child = CSSNodeNew(); + CSSNodeInsertChild(root, child, 0); + } + CSSNodeFreeRecursive(root); + ASSERT_NE(testMallocCount, 0); + ASSERT_NE(testCallocCount, 0); + ASSERT_NE(testReallocCount, 0); + ASSERT_NE(testFreeCount, 0); + CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL); +} + +#if GTEST_HAS_DEATH_TEST +TEST(CSSLayoutTest, memory_func_assert_zero_nodes) { + const CSSNodeRef root = CSSNodeNew(); + ASSERT_DEATH(CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first"); + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, memory_func_assert_all_non_null) { + ASSERT_DEATH(CSSLayoutSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL"); +} +#endif From c2aac9f46e50e5386cebe618595ab8f37adaf990 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 16 Nov 2016 16:36:36 +0100 Subject: [PATCH 050/108] Add googletest submodule --- .gitmodules | 3 +++ lib/gtest/googletest | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/gtest/googletest diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..16b40a6e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/gtest/googletest"] + path = lib/gtest/googletest + url = https://github.com/google/googletest.git diff --git a/lib/gtest/googletest b/lib/gtest/googletest new file mode 160000 index 00000000..a2b8a8e0 --- /dev/null +++ b/lib/gtest/googletest @@ -0,0 +1 @@ +Subproject commit a2b8a8e07628e5fd60644b6dd99c1b5e7d7f1f47 From 2fa6f5087dcc758a8966ee588a3e3c9755d5b1b0 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 17 Nov 2016 04:32:45 -0800 Subject: [PATCH 051/108] Disable UIKit memory tests on travis Summary: For some reason these tests don't pass when running in travis. They are still running internally so we should catch any regressions. We can remove this if we figure out what is causing travis to fail here but until now I would rather get travis to pass. Reviewed By: dshahidehpour Differential Revision: D4189251 fbshipit-source-id: a27d3390f6b6fdcac6a3312d02581bb64969fd4b --- .travis.yml | 6 +++--- CSSLayoutKit/Tests/CSSLayoutTests.m | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8b2a31f0..f74b3aaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,8 @@ before_install: script: - buck test //:CSSLayout - buck test //java:java - - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 + - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI - sh csharp/tests/Facebook.CSSLayout/test_macos.sh - - buck run //benchmark:benchmark + - buck run //benchmark:benchmark - git checkout HEAD^ - - buck run //benchmark:benchmark + - buck run //benchmark:benchmark diff --git a/CSSLayoutKit/Tests/CSSLayoutTests.m b/CSSLayoutKit/Tests/CSSLayoutTests.m index 49dea67d..076161af 100644 --- a/CSSLayoutKit/Tests/CSSLayoutTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutTests.m @@ -16,6 +16,8 @@ @implementation CSSLayoutTests +#ifndef TRAVIS_CI + - (void)testNodesAreDeallocedWithSingleView { XCTAssertEqual(0, CSSNodeGetInstanceCount()); @@ -30,7 +32,7 @@ - (void)testNodesAreDeallocedCascade { - const int32_t instanceCount = CSSNodeGetInstanceCount(); + XCTAssertEqual(0, CSSNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; [view css_setFlexBasis:1]; @@ -40,12 +42,14 @@ [subview css_setFlexBasis:1]; [view addSubview:subview]; } - XCTAssertEqual(instanceCount + 11, CSSNodeGetInstanceCount()); + XCTAssertEqual(11, CSSNodeGetInstanceCount()); view = nil; - XCTAssertEqual(instanceCount, CSSNodeGetInstanceCount()); + XCTAssertEqual(0, CSSNodeGetInstanceCount()); } +#endif + - (void)testUsesFlexbox { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; From 32ba5ae647e85e3a8ad39793df02585024ff4db3 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 17 Nov 2016 04:46:31 -0800 Subject: [PATCH 052/108] Make gtest a submodule in open source Summary: Remove infra for dynamically downloading gtest as this fails like 50% of the time on travis. I'll manually push gtest as a submodule instead. Reviewed By: gkassabli Differential Revision: D4183033 fbshipit-source-id: 09a121b8ede7a5974a29b6692edc63bff79aece7 --- .gitignore | 1 - .hgignore | 3 +-- CSSLAYOUT_DEFS | 2 -- lib/gtest/BUCK | 24 ++++-------------------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 2a22d83c..5b346768 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ /buck-out/ /.buckconfig.local /.buckd -/lib/gtest/googletest-*/ /gentest/test.html # Visual studio code diff --git a/.hgignore b/.hgignore index 875f1d7d..5b346768 100644 --- a/.hgignore +++ b/.hgignore @@ -4,8 +4,7 @@ /buck-out/ /.buckconfig.local /.buckd -/lib/gtest/googletest-*/ /gentest/test.html # Visual studio code -.vscode \ No newline at end of file +.vscode diff --git a/CSSLAYOUT_DEFS b/CSSLAYOUT_DEFS index 5937d48a..91d372ab 100644 --- a/CSSLAYOUT_DEFS +++ b/CSSLAYOUT_DEFS @@ -6,8 +6,6 @@ JUNIT_TARGET = '//lib/junit:junit' PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations' SOLOADER_TARGET = '//lib/soloader:soloader' GTEST_TARGET = '//lib/gtest:gtest' -GTEST_DL_URL = 'https://github.com/google/googletest/archive/release-1.7.0.zip' - JNI_TARGET = '//lib/jni:jni' FBJNI_TARGET = '//lib/fb:fbjni' diff --git a/lib/gtest/BUCK b/lib/gtest/BUCK index d1a01d56..d2e136b9 100644 --- a/lib/gtest/BUCK +++ b/lib/gtest/BUCK @@ -7,22 +7,6 @@ include_defs('//CSSLAYOUT_DEFS') -with allow_unsafe_import(): - import os - import urllib2 - import zipfile - -# Download gtest dep if it does not exists in path -current_dir = os.path.dirname(os.path.realpath(__file__)) -gtest_folder = 'googletest-release-1.7.0' -if GTEST_DL_URL != None and not os.path.isdir(current_dir + gtest_folder): - gtest = urllib2.urlopen('https://github.com/google/googletest/archive/release-1.7.0.zip').read() - with open("gtest.zip", 'w') as f: - f.write(gtest) - with zipfile.ZipFile('gtest.zip',"r") as zip: - zip.extractall(os.path.dirname(os.path.realpath(__file__))) - os.remove('gtest.zip') - COMPILER_FLAGS = [ '-std=c++11', '-Wno-missing-prototypes', @@ -30,11 +14,11 @@ COMPILER_FLAGS = [ cxx_library( name = 'gtest', - srcs = glob([gtest_folder + '/src/*.cc']), + srcs = glob(['googletest/googletest/src/*.cc']), exported_headers = subdir_glob([ - (gtest_folder + '/include', '**/*.h'), - (gtest_folder, 'src/*.h'), - (gtest_folder, 'src/*.cc'), + ('googletest/googletest/include', '**/*.h'), + ('googletest/googletest', 'src/*.h'), + ('googletest/googletest', 'src/*.cc'), ]), header_namespace = '', compiler_flags = COMPILER_FLAGS, From 7e4bb732ffa067d97a19b45a551e4cf0143a248f Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 17 Nov 2016 07:03:30 -0800 Subject: [PATCH 053/108] Introduce CSSNode.Create API Summary: Add a convenience construction method for CSSNode. CSSNode node = CSSNode.Create( positionType: CSSPositionType.Absolute, wrap: CSSWrap.Wrap, position: new Spacing(top:6, right:4), margin: new Spacing(bottom:5, left:3)); Reviewed By: emilsjolander Differential Revision: D4193380 fbshipit-source-id: 30b917f64e92997355a76e3b11799883b86fb9de --- csharp/Facebook.CSSLayout/CSSNode.Create.cs | 234 ++++++++++++++++++ csharp/Facebook.CSSLayout/CSSNode.cs | 2 +- csharp/Facebook.CSSLayout/Spacing.cs | 31 +++ .../Facebook.CSSLayout/CSSNodeCreateTest.cs | 143 +++++++++++ 4 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 csharp/Facebook.CSSLayout/CSSNode.Create.cs create mode 100644 csharp/Facebook.CSSLayout/Spacing.cs create mode 100644 csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs diff --git a/csharp/Facebook.CSSLayout/CSSNode.Create.cs b/csharp/Facebook.CSSLayout/CSSNode.Create.cs new file mode 100644 index 00000000..1b5bb207 --- /dev/null +++ b/csharp/Facebook.CSSLayout/CSSNode.Create.cs @@ -0,0 +1,234 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +using System; + +namespace Facebook.CSSLayout +{ + public partial class CSSNode + { + public static CSSNode Create( + CSSDirection? styleDirection = null, + CSSFlexDirection? flexDirection = null, + CSSJustify? justifyContent = null, + CSSAlign? alignContent = null, + CSSAlign? alignItems = null, + CSSAlign? alignSelf = null, + CSSPositionType? positionType = null, + CSSWrap? wrap = null, + CSSOverflow? overflow = null, + float? flex = null, + float? flexGrow = null, + float? flexShrink = null, + float? flexBasis = null, + Spacing position = null, + Spacing margin = null, + Spacing padding = null, + Spacing border = null, + float? styleWidth = null, + float? styleHeight = null, + float? styleMaxWidth = null, + float? styleMaxHeight = null, + float? styleMinWidth = null, + float? styleMinHeight = null) + { + CSSNode node = new CSSNode(); + + if (styleDirection.HasValue) + { + node.StyleDirection = styleDirection.Value; + } + + if (flexDirection.HasValue) + { + node.FlexDirection = flexDirection.Value; + } + + if (justifyContent.HasValue) + { + node.JustifyContent = justifyContent.Value; + } + + if (alignContent.HasValue) + { + node.AlignContent = alignContent.Value; + } + + if (alignItems.HasValue) + { + node.AlignItems = alignItems.Value; + } + + if (alignSelf.HasValue) + { + node.AlignSelf = alignSelf.Value; + } + + if (positionType.HasValue) + { + node.PositionType = positionType.Value; + } + + if (wrap.HasValue) + { + node.Wrap = wrap.Value; + } + + if (overflow.HasValue) + { + node.Overflow = overflow.Value; + } + + if (flex.HasValue) + { + node.Flex = flex.Value; + } + + if (flexGrow.HasValue) + { + node.FlexGrow = flexGrow.Value; + } + + if (flexShrink.HasValue) + { + node.FlexShrink = flexShrink.Value; + } + + if (flexBasis.HasValue) + { + node.FlexBasis = flexBasis.Value; + } + + if (position != null) + { + if (position.Top.HasValue) + { + node.SetPosition(CSSEdge.Top, position.Top.Value); + } + + if (position.Bottom.HasValue) + { + node.SetPosition(CSSEdge.Bottom, position.Bottom.Value); + } + + if (position.Left.HasValue) + { + node.SetPosition(CSSEdge.Left, position.Left.Value); + } + + if (position.Right.HasValue) + { + node.SetPosition(CSSEdge.Right, position.Right.Value); + } + } + + if (margin != null) + { + if (margin.Top.HasValue) + { + node.SetMargin(CSSEdge.Top, margin.Top.Value); + } + + if (margin.Bottom.HasValue) + { + node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value); + } + + if (margin.Left.HasValue) + { + node.SetMargin(CSSEdge.Left, margin.Left.Value); + } + + if (margin.Right.HasValue) + { + node.SetMargin(CSSEdge.Right, margin.Right.Value); + } + } + + if (padding != null) + { + if (padding.Top.HasValue) + { + node.SetPadding(CSSEdge.Top, padding.Top.Value); + } + + if (padding.Bottom.HasValue) + { + node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value); + } + + if (padding.Left.HasValue) + { + node.SetPadding(CSSEdge.Left, padding.Left.Value); + } + + if (padding.Right.HasValue) + { + node.SetPadding(CSSEdge.Right, padding.Right.Value); + } + } + + if (border != null) + { + if (border.Top.HasValue) + { + node.SetBorder(CSSEdge.Top, border.Top.Value); + } + + if (border.Bottom.HasValue) + { + node.SetBorder(CSSEdge.Bottom, border.Bottom.Value); + } + + if (border.Left.HasValue) + { + node.SetBorder(CSSEdge.Left, border.Left.Value); + } + + if (border.Right.HasValue) + { + node.SetBorder(CSSEdge.Right, border.Right.Value); + } + } + + if (styleWidth.HasValue) + { + node.StyleWidth = styleWidth.Value; + } + + if (styleHeight.HasValue) + { + node.StyleHeight = styleHeight.Value; + } + + if (styleMinWidth.HasValue) + { + node.StyleMinWidth = styleMinWidth.Value; + } + + if (styleMinHeight.HasValue) + { + node.StyleMinHeight = styleMinHeight.Value; + } + + if (styleMaxWidth.HasValue) + { + node.StyleMaxWidth = styleMaxWidth.Value; + } + + if (styleMaxHeight.HasValue) + { + node.StyleMaxHeight = styleMaxHeight.Value; + } + + return node; + } + } +} + diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 985aa650..f2ba1810 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -15,7 +15,7 @@ using System.Text; namespace Facebook.CSSLayout { - public class CSSNode : IEnumerable + public partial class CSSNode : IEnumerable { private IntPtr _cssNode; private WeakReference _parent; diff --git a/csharp/Facebook.CSSLayout/Spacing.cs b/csharp/Facebook.CSSLayout/Spacing.cs new file mode 100644 index 00000000..b3cee58c --- /dev/null +++ b/csharp/Facebook.CSSLayout/Spacing.cs @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.CSSLayout +{ + public class Spacing + { + public float? Top; + public float? Bottom; + public float? Left; + public float? Right; + + public Spacing( + float? top = null, + float? bottom = null, + float? left = null, + float? right = null) + { + Top = top; + Bottom = bottom; + Left = left; + Right = right; + } + } +} diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs new file mode 100644 index 00000000..84f064f0 --- /dev/null +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +using NUnit.Framework; +using System; + +/** + * Tests for {@link CSSNode}. + */ +namespace Facebook.CSSLayout +{ + [TestFixture] + public class CSSNodeCreateTest + { + [Test] + public void TestSimple() + { + CSSNode nodeDefault = new CSSNode(); + CSSNode nodeCreated = CSSNode.Create(flexDirection: CSSFlexDirection.Row); + Assert.AreEqual(CSSFlexDirection.Row, nodeCreated.FlexDirection); + Assert.IsFalse(nodeDefault.IsDirty); + nodeDefault.CopyStyle(nodeCreated); + Assert.IsTrue(nodeDefault.IsDirty); + } + + [Test] + public void TestSame() + { + CSSNode nodeDefault = new CSSNode(); + CSSNode nodeCreated = CSSNode.Create(); + Assert.IsFalse(nodeDefault.IsDirty); + nodeDefault.CopyStyle(nodeCreated); + Assert.IsFalse(nodeDefault.IsDirty); + } + + [Test] + public void TestMultiple() + { + CSSNode node = CSSNode.Create( + positionType: CSSPositionType.Absolute, + wrap: CSSWrap.Wrap, + position: new Spacing(top:6, right:4), + margin: new Spacing(bottom:5, left:3)); + + Assert.AreEqual(CSSFlexDirection.Column, node.FlexDirection); + Assert.AreEqual(CSSPositionType.Absolute, node.PositionType); + Assert.AreEqual(CSSWrap.Wrap, node.Wrap); + Assert.AreEqual(6, node.GetPosition(CSSEdge.Top)); + Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Bottom))); + Assert.AreEqual(4, node.GetPosition(CSSEdge.Right)); + Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Left))); + Assert.AreEqual(0, node.GetMargin(CSSEdge.Top)); + Assert.AreEqual(5, node.GetMargin(CSSEdge.Bottom)); + Assert.AreEqual(3, node.GetMargin(CSSEdge.Left)); + Assert.AreEqual(0, node.GetMargin(CSSEdge.Right)); + } + + [Test] + public void TestFull() + { + CSSNode node = CSSNode.Create( + styleDirection: CSSDirection.RTL, + flexDirection: CSSFlexDirection.RowReverse, + + justifyContent: CSSJustify.SpaceAround, + alignContent: CSSAlign.Center, + alignItems: CSSAlign.FlexEnd, + alignSelf: CSSAlign.Stretch, + + positionType: CSSPositionType.Absolute, + wrap: CSSWrap.Wrap, + overflow: CSSOverflow.Scroll, + + flex: 1, + flexGrow: 2, + flexShrink: 3, + flexBasis: 4, + + position: new Spacing(top: 5, bottom: 6, left: 7, right: 8), + margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12), + padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), + border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), + + styleWidth: 21, + styleHeight: 22, + styleMinWidth: 23, + styleMinHeight: 24, + styleMaxWidth: 25, + styleMaxHeight: 26); + + Assert.AreEqual(CSSDirection.RTL, node.StyleDirection); + Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection); + + Assert.AreEqual(CSSJustify.SpaceAround, node.JustifyContent); + Assert.AreEqual(CSSAlign.Center, node.AlignContent); + Assert.AreEqual(CSSAlign.FlexEnd, node.AlignItems); + Assert.AreEqual(CSSAlign.Stretch, node.AlignSelf); + + Assert.AreEqual(CSSPositionType.Absolute, node.PositionType); + Assert.AreEqual(CSSWrap.Wrap, node.Wrap); + Assert.AreEqual(CSSOverflow.Scroll, node.Overflow); + + Assert.AreEqual(2, node.FlexGrow); + Assert.AreEqual(3, node.FlexShrink); + Assert.AreEqual(4, node.FlexBasis); + node.FlexGrow = CSSConstants.Undefined; + Assert.AreEqual(1, node.FlexGrow); + + Assert.AreEqual(5, node.GetPosition(CSSEdge.Top)); + Assert.AreEqual(6, node.GetPosition(CSSEdge.Bottom)); + Assert.AreEqual(7, node.GetPosition(CSSEdge.Left)); + Assert.AreEqual(8, node.GetPosition(CSSEdge.Right)); + + Assert.AreEqual(9, node.GetMargin(CSSEdge.Top)); + Assert.AreEqual(10, node.GetMargin(CSSEdge.Bottom)); + Assert.AreEqual(11, node.GetMargin(CSSEdge.Left)); + Assert.AreEqual(12, node.GetMargin(CSSEdge.Right)); + + Assert.AreEqual(13, node.GetPadding(CSSEdge.Top)); + Assert.AreEqual(14, node.GetPadding(CSSEdge.Bottom)); + Assert.AreEqual(15, node.GetPadding(CSSEdge.Left)); + Assert.AreEqual(16, node.GetPadding(CSSEdge.Right)); + + Assert.AreEqual(17, node.GetBorder(CSSEdge.Top)); + Assert.AreEqual(18, node.GetBorder(CSSEdge.Bottom)); + Assert.AreEqual(19, node.GetBorder(CSSEdge.Left)); + Assert.AreEqual(20, node.GetBorder(CSSEdge.Right)); + + Assert.AreEqual(21, node.StyleWidth); + Assert.AreEqual(22, node.StyleHeight); + Assert.AreEqual(23, node.StyleMinWidth); + Assert.AreEqual(24, node.StyleMinHeight); + Assert.AreEqual(25, node.StyleMaxWidth); + Assert.AreEqual(26, node.StyleMaxHeight); + } + } +} From 56aa279fef232ec91becaf6427580902058a9c3d Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Thu, 17 Nov 2016 07:29:33 -0800 Subject: [PATCH 054/108] BREAKING: remove css_sizeThatFits:, replace with new API. Summary: When I try to use this in practice, I have come to realize that css_sizeThatFits will 99% return to you the constrainedSize that you pass it, thus making it useless. Instead, we replace it with a new API that will tell you the optimal size of the resolved layout. From this we can choose to use that size, or scale it down. Reviewed By: emilsjolander Differential Revision: D4191873 fbshipit-source-id: d36a2850448d9d82f97e5ef4c7397778c2a14094 --- .../{CSSLayoutTests.m => CSSLayoutKitTests.m} | 34 +++++++++---- CSSLayoutKit/UIView+CSSLayout.h | 4 +- CSSLayoutKit/UIView+CSSLayout.m | 51 +++++++++++-------- 3 files changed, 56 insertions(+), 33 deletions(-) rename CSSLayoutKit/Tests/{CSSLayoutTests.m => CSSLayoutKitTests.m} (70%) diff --git a/CSSLayoutKit/Tests/CSSLayoutTests.m b/CSSLayoutKit/Tests/CSSLayoutKitTests.m similarity index 70% rename from CSSLayoutKit/Tests/CSSLayoutTests.m rename to CSSLayoutKit/Tests/CSSLayoutKitTests.m index 076161af..29071e77 100644 --- a/CSSLayoutKit/Tests/CSSLayoutTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutKitTests.m @@ -11,10 +11,10 @@ #import "UIView+CSSLayout.h" -@interface CSSLayoutTests : XCTestCase +@interface CSSLayoutKitTests : XCTestCase @end -@implementation CSSLayoutTests +@implementation CSSLayoutKitTests #ifndef TRAVIS_CI @@ -65,21 +65,35 @@ - (void)testSizeThatFitsAsserts { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - XCTAssertThrows([view css_sizeThatFits:CGSizeZero]); - dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){ - XCTAssertThrows([view css_sizeThatFits:CGSizeZero]); + XCTAssertThrows([view css_intrinsicSize]); }); } - (void)testSizeThatFitsSmoke { - UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - [view css_setUsesFlexbox:YES]; + UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setAlignItems:CSSAlignFlexStart]; - const CGSize constrainedSize = CGSizeMake(50, 50); - const CGSize actualSize = [view css_sizeThatFits:constrainedSize]; - XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize)); + UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + longTextLabel.text = @"This is a very very very very very very very very long piece of text."; + longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail; + longTextLabel.numberOfLines = 1; + [longTextLabel css_setUsesFlexbox:YES]; + [longTextLabel css_setFlexShrink:1]; + [container addSubview:longTextLabel]; + + UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero]; + [textBadgeView css_setUsesFlexbox:YES]; + [textBadgeView css_setMargin:3.0 forEdge:CSSEdgeLeft]; + [textBadgeView css_setWidth:10]; + [textBadgeView css_setHeight:10]; + [container addSubview:textBadgeView]; + + const CGSize containerSize = [container css_intrinsicSize]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize)); } - (void)testFrameAndOriginPlacement diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index 394c58c1..5f875687 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -52,8 +52,8 @@ - (void)css_applyLayout; /** - Compute the size of a layout with a constrained size. + Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; */ -- (CGSize)css_sizeThatFits:(CGSize)constrainedSize; +- (CGSize)css_intrinsicSize; @end diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 1c0530df..c5934840 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -157,32 +157,21 @@ return CSSNodeLayoutGetDirection([self cssNode]); } -- (CGSize)css_sizeThatFits:(CGSize)constrainedSize -{ - NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); - NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); - - CSSAttachNodesFromViewHierachy(self); - - const CSSNodeRef node = [self cssNode]; - CSSNodeCalculateLayout( - node, - constrainedSize.width, - constrainedSize.height, - CSSNodeStyleGetDirection(node)); - - return (CGSize) { - .width = CSSNodeLayoutGetWidth(node), - .height = CSSNodeLayoutGetHeight(node), - }; -} - - (void)css_applyLayout { - [self css_sizeThatFits:self.bounds.size]; + [self calculateLayoutWithSize:self.bounds.size]; CSSApplyLayoutToViewHierarchy(self); } +- (CGSize)css_intrinsicSize +{ + const CGSize constrainedSize = { + .width = CSSUndefined, + .height = CSSUndefined, + }; + return [self calculateLayoutWithSize:constrainedSize]; +} + #pragma mark - Private - (CSSNodeRef)cssNode @@ -197,6 +186,26 @@ return node.cnode; } +- (CGSize)calculateLayoutWithSize:(CGSize)size +{ + NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); + NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); + + CSSAttachNodesFromViewHierachy(self); + + const CSSNodeRef node = [self cssNode]; + CSSNodeCalculateLayout( + node, + size.width, + size.height, + CSSNodeStyleGetDirection(node)); + + return (CGSize) { + .width = CSSNodeLayoutGetWidth(node), + .height = CSSNodeLayoutGetHeight(node), + }; +} + static CSSSize CSSMeasureView( CSSNodeRef node, float width, From b9c4c403a9e6754d442429711d0a3b33cec4b349 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 17 Nov 2016 07:38:39 -0800 Subject: [PATCH 055/108] Fix memory func test Summary: Reset gNodeInstanceCount before memory func test. Reviewed By: emilsjolander Differential Revision: D4193712 fbshipit-source-id: a4aba84d054d98a7baf438e213a90bd7ef34e979 --- CSSLayout/CSSLayout.c | 2 +- tests/CSSLayoutMemoryFuncTest.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 6dc0f7bc..51d18593 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -180,7 +180,7 @@ static inline float computedEdgeValue(const float edges[CSSEdgeCount], return defaultValue; } -static int32_t gNodeInstanceCount = 0; +int32_t gNodeInstanceCount = 0; CSSNodeRef CSSNodeNew(void) { const CSSNodeRef node = gCSSCalloc(1, sizeof(CSSNode)); diff --git a/tests/CSSLayoutMemoryFuncTest.cpp b/tests/CSSLayoutMemoryFuncTest.cpp index ade4b6f7..fa1e3901 100644 --- a/tests/CSSLayoutMemoryFuncTest.cpp +++ b/tests/CSSLayoutMemoryFuncTest.cpp @@ -10,6 +10,8 @@ #include #include +extern int32_t gNodeInstanceCount; + static int testMallocCount; static int testCallocCount; static int testReallocCount; @@ -36,6 +38,7 @@ static void testFree(void *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(); @@ -44,6 +47,7 @@ TEST(CSSLayoutTest, memory_func_default) { } 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(); for (int i = 0; i < 10; i++) { @@ -60,12 +64,14 @@ TEST(CSSLayoutTest, memory_func_test_funcs) { #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(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"); } #endif From 4b61cdccea7fd1d7a5a3c55722d561a74a196cb4 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Thu, 17 Nov 2016 08:32:37 -0800 Subject: [PATCH 056/108] Add flag to not include view in layout. Summary: When dealing with manual sizing in UIView's (or UIKit in general) we see a common pattern like so: Below we have an example implementation of a view with two Labels that want to be stacked horizontally. If we don't pass a second string, we hide the second label and give up the available space to the first label. See below: ``` interface TitleSubtitleView : UIView - (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle; end implementation { UILabel *_titleLabel; UILabel *_subtitleLabel; } .... - (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle { _titleLabel.text = title; if (subtitle.length > 0) { _subtitleLabel.hidden = NO; _subtitleLabel.text = subtitle; } else { _subtitleLabel.hidden = YES; } } - (CGSize)sizeThatFits:(CGSize)size { const CGSize titleSize = [_titleLabel sizeThatFits:size]; CGSize subtitleSize = CGSizeZero; if (!_subtitleLabel.isHidden) { subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)]; } } - (void)layoutSubviews { [super layoutSubviews]; const CGSize titleSize = [_titleLabel sizeThatFits:size]; _titleLabel.frame = CGRectMake(0, 0, titleSize.width, titleSize.height); if (!_subtitleLabel.isHidden) { subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)]; _subtitleLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, subtitleSize.width, subtitleSize.height); } } ``` The problem is with the CSSLayout framework, as long as your view is in hierarchy, it's going to be allocated space during layout calculation. The only way to fix the view above would be to completely remove it from view hierarchy if it isn't being used. The problem is that adding/removing views from hierarchy is much less performant than hiding. As a result, we need a way to tell the CSSLayoutKit library that even though a view is in hierarchy, we don't want to include it in layout. With this diff, we could change the class to look like this: ``` interface TitleSubtitleView : UIView - (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle; end implementation { UILabel *_titleLabel; UILabel *_subtitleLabel; } .... - (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle { _titleLabel.text = title; _subtitleLabel.text = subtitle; const BOOL subtitleHasText = subtitle.length > 0; _subtitleLabel.hidden = !subtitleHasText; [_subtitleLabel css_includeInLayout:!subtitleHasText]; } - (CGSize)sizeThatFits:(CGSize)size { const intrinsicSize = [self css_intrinsicSize]; return CGSizeMake(MIN(size.width, intrinsicSize.width), MIN(size.height, intrinsicSize.height))); } - (void)layoutSubviews { [super layoutSubviews]; [self css_applyLayout]; } ``` Reviewed By: emilsjolander Differential Revision: D4189897 fbshipit-source-id: 403d11d84d47691e3ce0b5ac18a180b0e4c104c4 --- CSSLayoutKit/Tests/CSSLayoutKitTests.m | 74 ++++++++++++++++++++++++++ CSSLayoutKit/UIView+CSSLayout.h | 5 ++ CSSLayoutKit/UIView+CSSLayout.m | 33 ++++++++++-- 3 files changed, 108 insertions(+), 4 deletions(-) diff --git a/CSSLayoutKit/Tests/CSSLayoutKitTests.m b/CSSLayoutKit/Tests/CSSLayoutKitTests.m index 29071e77..720e0cb2 100644 --- a/CSSLayoutKit/Tests/CSSLayoutKitTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutKitTests.m @@ -125,4 +125,78 @@ XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth); } +- (void)testThatWeRespectIncludeInLayoutFlag +{ + const CGSize containerSize = CGSizeMake(300, 50); + + UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + + UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview1 css_setUsesFlexbox:YES]; + [subview1 css_setFlexGrow:1]; + [container addSubview:subview1]; + + UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview2 css_setUsesFlexbox:YES]; + [subview2 css_setFlexGrow:1]; + [container addSubview:subview2]; + + UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview3 css_setUsesFlexbox:YES]; + [subview3 css_setFlexGrow:1]; + [container addSubview:subview3]; + + [container css_applyLayout]; + + for (UIView *view in container.subviews) { + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size)); + } + + [subview3 css_setIncludeInLayout:NO]; + [container css_applyLayout]; + + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size)); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size)); + + // We don't set the frame to zero, so, it should be set to what it was previously at. + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size)); +} + +- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond +{ + UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + + UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview1 css_setUsesFlexbox:YES]; + [subview1 css_setFlexGrow:1]; + [container addSubview:subview1]; + + UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview2 css_setUsesFlexbox:YES]; + [subview2 css_setFlexGrow:1]; + [container addSubview:subview2]; + + UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview3 css_setUsesFlexbox:YES]; + [subview3 css_setFlexGrow:1]; + [subview3 css_setIncludeInLayout:NO]; + [container addSubview:subview3]; + + [container css_applyLayout]; + + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size)); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size)); + XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size)); + + [subview3 css_setIncludeInLayout:YES]; + [container css_applyLayout]; + for (UIView *view in container.subviews) { + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size)); + } +} + @end diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index 5f875687..d7702d09 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -12,6 +12,11 @@ @interface UIView (CSSLayout) +/** + The property that decides if we should include this view when calculating layout. Defaults to YES. + */ +@property (nonatomic, readwrite, assign, setter=css_setIncludeInLayout:) BOOL css_includeInLayout; + /** The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO. */ diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index c5934840..f166b5ff 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -39,8 +39,23 @@ return [usesFlexbox boolValue]; } +- (BOOL)css_includeInLayout +{ + NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(css_includeInLayout)); + return (includeInLayout != nil) ? [includeInLayout boolValue] : YES; +} + #pragma mark - Setters +- (void)css_setIncludeInLayout:(BOOL)includeInLayout +{ + objc_setAssociatedObject( + self, + @selector(css_includeInLayout), + @(includeInLayout), + OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + - (void)css_setUsesFlexbox:(BOOL)enabled { objc_setAssociatedObject( @@ -261,17 +276,24 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { } else { CSSNodeSetMeasureFunc(node, NULL); + NSUInteger numSubviewsInLayout = 0; // Add any children which were added since the last call to css_applyLayout for (NSUInteger i = 0; i < view.subviews.count; i++) { - CSSNodeRef childNode = [view.subviews[i] cssNode]; + UIView *const subview = view.subviews[i]; + if (![subview css_includeInLayout]) { + continue; + } + numSubviewsInLayout++; + + CSSNodeRef childNode = [subview cssNode]; if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) { CSSNodeInsertChild(node, childNode, i); } - CSSAttachNodesFromViewHierachy(view.subviews[i]); + CSSAttachNodesFromViewHierachy(subview); } // Remove any children which were removed since the last call to css_applyLayout - while (view.subviews.count < CSSNodeChildCount(node)) { + while (numSubviewsInLayout < CSSNodeChildCount(node)) { CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); } } @@ -290,8 +312,11 @@ static CGFloat CSSRoundPixelValue(CGFloat value) static void CSSApplyLayoutToViewHierarchy(UIView *view) { NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); - CSSNodeRef node = [view cssNode]; + if (![view css_includeInLayout]) { + return; + } + CSSNodeRef node = [view cssNode]; const CGPoint topLeft = { CSSNodeLayoutGetLeft(node), CSSNodeLayoutGetTop(node), From 32c175ac5595207b710411892a563b3bf73b39fc Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 17 Nov 2016 08:56:18 -0800 Subject: [PATCH 057/108] Workaround fix for Visual Studio Summary: - Problem: Build error in Visual Studio since an array cannot have zero size. - https://github.com/facebook/css-layout/commit/e6702e1168f7878a30a056548bc754ce1d61074f#commitcomment-19839659 - Solution: Add 1 until we'll have actual CSSExperimentalFeature value. Reviewed By: emilsjolander Differential Revision: D4191268 fbshipit-source-id: 53fdcc388292e76c2b97ad071f0d7c27d0613ecf --- CSSLayout/CSSLayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 51d18593..dd38a20c 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2519,7 +2519,7 @@ void CSSLog(CSSLogLevel level, const char *format, ...) { va_end(args); } -static bool experimentalFeatures[CSSExperimentalFeatureCount]; +static bool experimentalFeatures[CSSExperimentalFeatureCount + 1]; void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) { experimentalFeatures[feature] = enabled; From 191ac98b891d1369fba33611d14f2706f40ff996 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 17 Nov 2016 09:10:45 -0800 Subject: [PATCH 058/108] Introduce CSSNodeCopyStyle Summary: - Add a convenience function to copy all style from one node to another. - CSSNodeIsDirty will return true after this function if any style was changed in the destination node. Reviewed By: emilsjolander Differential Revision: D4188514 fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441 --- CSSLayout/CSSLayout.c | 7 +++++ CSSLayout/CSSLayout.h | 2 ++ tests/CSSLayoutStyleTest.cpp | 60 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 tests/CSSLayoutStyleTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index dd38a20c..461bb78b 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -341,6 +341,13 @@ bool CSSNodeIsDirty(const CSSNodeRef 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); + } +} + inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { if (!CSSValueIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 07a8f6ec..8e28e4f7 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -98,6 +98,8 @@ WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, 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); diff --git a/tests/CSSLayoutStyleTest.cpp b/tests/CSSLayoutStyleTest.cpp new file mode 100644 index 00000000..6b7579af --- /dev/null +++ b/tests/CSSLayoutStyleTest.cpp @@ -0,0 +1,60 @@ +/** + * 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 + +TEST(CSSLayoutTest, copy_style_same) { + const CSSNodeRef node0 = CSSNodeNew(); + const CSSNodeRef node1 = CSSNodeNew(); + ASSERT_FALSE(CSSNodeIsDirty(node0)); + + CSSNodeCopyStyle(node0, node1); + ASSERT_FALSE(CSSNodeIsDirty(node0)); + + CSSNodeFree(node0); + CSSNodeFree(node1); +} + +TEST(CSSLayoutTest, copy_style_modified) { + const CSSNodeRef node0 = CSSNodeNew(); + ASSERT_FALSE(CSSNodeIsDirty(node0)); + ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0)); + ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0))); + + const CSSNodeRef node1 = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow); + CSSNodeStyleSetMaxHeight(node1, 10); + + CSSNodeCopyStyle(node0, node1); + ASSERT_TRUE(CSSNodeIsDirty(node0)); + ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0)); + ASSERT_EQ(10, CSSNodeStyleGetMaxHeight(node0)); + + CSSNodeFree(node0); + CSSNodeFree(node1); +} + +TEST(CSSLayoutTest, copy_style_modified_same) { + const CSSNodeRef node0 = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(node0, CSSFlexDirectionRow); + CSSNodeStyleSetMaxHeight(node0, 10); + CSSNodeCalculateLayout(node0, CSSUndefined, CSSUndefined, CSSDirectionLTR); + ASSERT_FALSE(CSSNodeIsDirty(node0)); + + const CSSNodeRef node1 = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow); + CSSNodeStyleSetMaxHeight(node1, 10); + + CSSNodeCopyStyle(node0, node1); + ASSERT_FALSE(CSSNodeIsDirty(node0)); + + CSSNodeFree(node0); + CSSNodeFree(node1); +} From 0bb2955c5c182d57ca7e221f7709de713f088607 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 17 Nov 2016 09:10:47 -0800 Subject: [PATCH 059/108] CSSNodeCopyStyle API for Java and C# Summary: Add CopyStyle API for Java and C# Reviewed By: emilsjolander Differential Revision: D4189954 fbshipit-source-id: 10759fdb27bf67350d3151614f7815aa09bf7e04 --- csharp/Facebook.CSSLayout/CSSNode.cs | 5 +++++ csharp/Facebook.CSSLayout/Native.cs | 3 +++ csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs | 15 ++++++++++++++- java/com/facebook/csslayout/CSSNode.java | 6 ++++++ java/com/facebook/csslayout/CSSNodeAPI.java | 1 + .../com/facebook/csslayout/CSSNodeDEPRECATED.java | 5 +++++ java/jni/CSSJNI.cpp | 5 +++++ .../tests/com/facebook/csslayout/CSSNodeTest.java | 13 +++++++++++++ 8 files changed, 52 insertions(+), 1 deletion(-) diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index f2ba1810..6d44995d 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -90,6 +90,11 @@ namespace Facebook.CSSLayout } } + public void CopyStyle(CSSNode srcNode) + { + Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode); + } + public CSSDirection StyleDirection { get diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index fa3a8654..d7c36449 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -80,6 +80,9 @@ namespace Facebook.CSSLayout [return: MarshalAs(UnmanagedType.I1)] public static extern bool CSSValueIsUndefined(float value); + [DllImport(DllName)] + public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode); + #region CSS_NODE_PROPERTY [DllImport(DllName)] diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index 5677da91..2e40f5e9 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -215,13 +215,26 @@ namespace Facebook.CSSLayout Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); } + [Test] + public void TestCopyStyle() + { + CSSNode node0 = new CSSNode(); + Assert.IsTrue(CSSConstants.IsUndefined(node0.StyleMaxHeight)); + + CSSNode node1 = new CSSNode(); + node1.StyleMaxHeight = 100; + + node0.CopyStyle(node1); + Assert.AreEqual(100, node0.StyleMaxHeight); + } + +#if !UNITY_EDITOR private void ForceGC() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); } -#if !UNITY_EDITOR [Test] public void TestDestructor() { diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index e92f9267..95a5319e 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -190,6 +190,12 @@ public class CSSNode implements CSSNodeAPI { jni_CSSNodeMarkLayoutSeen(mNativePointer); } + private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer); + @Override + public void copyStyle(CSSNode srcNode) { + jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer); + } + private native int jni_CSSNodeStyleGetDirection(long nativePointer); @Override public CSSDirection getStyleDirection() { diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/CSSNodeAPI.java index dd18a54b..d35d8b48 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/CSSNodeAPI.java @@ -37,6 +37,7 @@ public interface CSSNodeAPI { void dirty(); void markLayoutSeen(); boolean valuesEqual(float f1, float f2); + void copyStyle(CSSNodeType srcNode); CSSDirection getStyleDirection(); void setDirection(CSSDirection direction); CSSFlexDirection getFlexDirection(); diff --git a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java index dc31cc04..0031ee69 100644 --- a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java +++ b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java @@ -222,6 +222,11 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { return FloatUtil.floatsEqual(f1, f2); } + @Override + public void copyStyle(CSSNodeDEPRECATED srcNode) { + throw new UnsupportedOperationException("copyStyle is not implemented"); + } + /** * Get this node's direction, as defined in the style. */ diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index f3bad806..9c3e3959 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -187,6 +187,10 @@ 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)); \ @@ -257,6 +261,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) { CSSMakeNativeMethod(jni_CSSNodeIsDirty), CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen), CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc), + CSSMakeNativeMethod(jni_CSSNodeCopyStyle), CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection), CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection), diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index 3b857279..f269a91c 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -12,6 +12,7 @@ package com.facebook.csslayout; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class CSSNodeTest { @@ -71,4 +72,16 @@ public class CSSNodeTest { assertEquals(CSSLogLevel.VERBOSE, mLogLevel); assertEquals("Flexbox", mLogMessage); } + + @Test + public void testCopyStyle() { + final CSSNode node0 = new CSSNode(); + assertTrue(CSSConstants.isUndefined(node0.getStyleMaxHeight())); + + final CSSNode node1 = new CSSNode(); + node1.setStyleMaxHeight(100); + + node0.copyStyle(node1); + assertEquals(100, (int) node0.getStyleMaxHeight()); + } } From 4f192481eebcfb0c96285c9643fce31bde4a8c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Thu, 17 Nov 2016 20:41:44 -0800 Subject: [PATCH 060/108] use size_t instead of unsigned long Summary: Use ```size_t```instead of ```unsinged long``` as this is the "offical" return type of ```strlen```. Is VS13 ```size_t``` is defined as ```unsigned long long``` which leads to a compiler warning. Closes https://github.com/facebook/css-layout/pull/254 Reviewed By: emilsjolander Differential Revision: D4199327 Pulled By: splhack fbshipit-source-id: 5e1a91f282bf776e4d9f5806e6467dfe36c7a633 --- CSSLayout/CSSLayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 461bb78b..e656eeb7 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2173,7 +2173,7 @@ bool gPrintSkips = false; static const char *spacer = " "; static const char *getSpacer(const unsigned long level) { - const unsigned long spacerLen = strlen(spacer); + const size_t spacerLen = strlen(spacer); if (level > spacerLen) { return &spacer[0]; } else { From 542fc504091107dbc65e75497fa4070bc91c6c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Thu, 17 Nov 2016 20:41:46 -0800 Subject: [PATCH 061/108] do not redefine isnan if already defined via math.h Summary: ```isnan``` is already defined in ```math.h``` (at least when using VS13) so there is no need to redefine it. it also is a nan for float and not for double opposed to ```_isnan``` Closes https://github.com/facebook/css-layout/pull/253 Reviewed By: emilsjolander Differential Revision: D4199331 Pulled By: splhack fbshipit-source-id: 139fb0efd68dd5df79bbaef863a8e8b9246c795d --- CSSLayout/CSSLayout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index e656eeb7..958af3e2 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -14,7 +14,9 @@ #ifdef _MSC_VER #include +#ifndef isnan #define isnan _isnan +#endif #ifndef __cplusplus #define inline __inline From 653150a7c40233073b59dec184fe02d8ea96f9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Thu, 17 Nov 2016 20:41:47 -0800 Subject: [PATCH 062/108] Change more method arguments to const Summary: Change more method arguments to ```const``` Closes https://github.com/facebook/css-layout/pull/252 Reviewed By: emilsjolander Differential Revision: D4199335 Pulled By: splhack fbshipit-source-id: f54fccaea8051a49c6cdf0fcaf1a68c025ba26da --- CSSLayout/CSSLayout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 958af3e2..df4f24f9 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -350,7 +350,7 @@ void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode) { } } -inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { +inline float CSSNodeStyleGetFlexGrow(const CSSNodeRef node) { if (!CSSValueIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; } @@ -360,7 +360,7 @@ inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { return 0; } -inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) { +inline float CSSNodeStyleGetFlexShrink(const CSSNodeRef node) { if (!CSSValueIsUndefined(node->style.flexShrink)) { return node->style.flexShrink; } @@ -370,7 +370,7 @@ inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) { return 0; } -inline float CSSNodeStyleGetFlexBasis(CSSNodeRef node) { +inline float CSSNodeStyleGetFlexBasis(const CSSNodeRef node) { if (!CSSValueIsUndefined(node->style.flexBasis)) { return node->style.flexBasis; } From 367c3a28bee7ecd689d2d30390e1ee2be3740a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Thu, 17 Nov 2016 20:41:48 -0800 Subject: [PATCH 063/108] use fmaxf to prevent casting from and to double Summary: Use ```fmaxf``` to prevent double casting. Closes https://github.com/facebook/css-layout/pull/251 Reviewed By: emilsjolander Differential Revision: D4199342 Pulled By: splhack fbshipit-source-id: c04bc68a3c9c97b92e910e885457cf2fe00da28b --- CSSLayout/CSSLayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index df4f24f9..81795b72 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1812,7 +1812,7 @@ static void layoutNodeImpl(const CSSNodeRef node, if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) { if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && node->style.minDimensions[dim[mainAxis]] >= 0) { - remainingFreeSpace = fmax(0, + remainingFreeSpace = fmaxf(0, node->style.minDimensions[dim[mainAxis]] - (availableInnerMainDim - remainingFreeSpace)); } else { From 56ec33a463fa7426ef18ab6eda0fc0ba00d6cac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Fri, 18 Nov 2016 09:22:27 -0800 Subject: [PATCH 064/108] Fix CS0675 warning in c# Summary: Fix CS0675 warning in c#. Closes https://github.com/facebook/css-layout/pull/255 Reviewed By: emilsjolander Differential Revision: D4204765 Pulled By: splhack fbshipit-source-id: bcf71796e1bf585a94b3549905cb6d6bc78a34b8 --- csharp/Facebook.CSSLayout/MeasureOutput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/Facebook.CSSLayout/MeasureOutput.cs b/csharp/Facebook.CSSLayout/MeasureOutput.cs index 5ae6b9b0..10d93a33 100644 --- a/csharp/Facebook.CSSLayout/MeasureOutput.cs +++ b/csharp/Facebook.CSSLayout/MeasureOutput.cs @@ -18,7 +18,7 @@ namespace Facebook.CSSLayout public static long Make(int width, int height) { - return (long)(((ulong) width) << 32 | ((ulong) height)); + return (long)(((ulong) width) << 32 | ((uint) height)); } public static int GetWidth(long measureOutput) From b16c22a8f38e77f969fffcc5901e004e341d8eca Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Sun, 20 Nov 2016 04:59:55 -0800 Subject: [PATCH 065/108] Only skip updating computed flex basis within the same generation Summary: computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout also run format script. Reviewed By: dshahidehpour Differential Revision: D4207106 fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d --- CSSLayout/CSSLayout.c | 16 ++++++++++------ CSSLayout/CSSLayout.h | 5 +++-- java/jni/CSSJNI.cpp | 15 ++++++++++----- tests/CSSLayoutRelayoutTest.cpp | 27 +++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 tests/CSSLayoutRelayoutTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 81795b72..9fa990b4 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -49,6 +49,7 @@ typedef struct CSSLayout { float dimensions[2]; CSSDirection direction; + uint32_t computedFlexBasisGeneration; float computedFlexBasis; // Instead of recomputing the entire layout every single time, we @@ -967,7 +968,8 @@ static void computeChildFlexBasis(const CSSNodeRef node, if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && !CSSValueIsUndefined(isMainAxisRow ? width : height)) { - if (CSSValueIsUndefined(child->layout.computedFlexBasis)) { + if (CSSValueIsUndefined(child->layout.computedFlexBasis) || + child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { child->layout.computedFlexBasis = fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); } @@ -1052,6 +1054,8 @@ static void computeChildFlexBasis(const CSSNodeRef node, : child->layout.measuredDimensions[CSSDimensionHeight], getPaddingAndBorderAxis(child, mainAxis)); } + + child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; } static void absoluteLayoutChild(const CSSNodeRef node, @@ -1477,6 +1481,7 @@ static void layoutNodeImpl(const CSSNodeRef node, child->nextChild = NULL; } else { if (child == singleFlexChild) { + child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; child->layout.computedFlexBasis = 0; } else { computeChildFlexBasis(node, @@ -1813,8 +1818,8 @@ static void layoutNodeImpl(const CSSNodeRef node, if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && node->style.minDimensions[dim[mainAxis]] >= 0) { remainingFreeSpace = fmaxf(0, - node->style.minDimensions[dim[mainAxis]] - - (availableInnerMainDim - remainingFreeSpace)); + node->style.minDimensions[dim[mainAxis]] - + (availableInnerMainDim - remainingFreeSpace)); } else { remainingFreeSpace = 0; } @@ -2542,10 +2547,9 @@ 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(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), + (cssMalloc != NULL && cssCalloc != NULL && cssRealloc != NULL && cssFree != NULL), "Cannot set memory functions: functions must be all NULL or Non-NULL"); if (cssMalloc == NULL || cssCalloc == NULL || cssRealloc == NULL || cssFree == NULL) { diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 8e28e4f7..e052b07e 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -28,8 +28,8 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; #define CSSUndefined NAN -#include "CSSMacros.h" #include "CSSEnums.h" +#include "CSSMacros.h" CSS_EXTERN_C_BEGIN @@ -160,7 +160,8 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); -WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled); +WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, + bool enabled); WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature); WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc, diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 9c3e3959..2c6ef3af 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -77,12 +77,15 @@ static int _jniLog(CSSLogLevel 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 logFunc = findClassLocal("com/facebook/csslayout/CSSLogger") + ->getMethod, jstring)>("log"); - static auto logLevelFromInt = JCSSLogLevel::javaClassStatic()->getStaticMethod("fromInt"); + static auto logLevelFromInt = + JCSSLogLevel::javaClassStatic()->getStaticMethod("fromInt"); - logFunc(jLogger->get(), logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast(level)), Environment::current()->NewStringUTF(buffer)); + logFunc(jLogger->get(), + logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast(level)), + Environment::current()->NewStringUTF(buffer)); return result; } @@ -112,7 +115,9 @@ void jni_CSSLog(alias_ref clazz, jint level, jstring message) { Environment::current()->ReleaseStringUTFChars(message, nMessage); } -void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref clazz, jint feature, jboolean enabled) { +void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref clazz, + jint feature, + jboolean enabled) { CSSLayoutSetExperimentalFeatureEnabled(static_cast(feature), enabled); } diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp new file mode 100644 index 00000000..e30965db --- /dev/null +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -0,0 +1,27 @@ +/** + * 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 + +TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { + const CSSNodeRef root = CSSNodeNew(); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 10); + CSSNodeStyleSetFlexBasis(root_child0, 20); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, 100, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); + + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} From 55fc795686a7b5c4297cf7245de709f6c6d41741 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 21 Nov 2016 10:12:26 -0800 Subject: [PATCH 066/108] Add aspectRatio style property Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples. Reviewed By: gkassabli Differential Revision: D4211458 fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d --- CSSLayout/CSSLayout.c | 49 +++ CSSLayout/CSSLayout.h | 9 + CSSLayoutKit/UIView+CSSLayout.h | 3 + CSSLayoutKit/UIView+CSSLayout.m | 5 + csharp/Facebook.CSSLayout/CSSNode.cs | 13 + csharp/Facebook.CSSLayout/Native.cs | 6 + java/com/facebook/csslayout/CSSNode.java | 10 + java/jni/CSSJNI.cpp | 5 + tests/CSSLayoutAspectRatioTest.cpp | 407 +++++++++++++++++++++++ 9 files changed, 507 insertions(+) create mode 100644 tests/CSSLayoutAspectRatioTest.cpp diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 9fa990b4..a43019c4 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -85,6 +85,9 @@ typedef struct CSSStyle { float dimensions[2]; float minDimensions[2]; float maxDimensions[2]; + + // Yoga specific properties, not compatible with flexbox specification + float aspectRatio; } CSSStyle; typedef struct CSSNode { @@ -269,6 +272,8 @@ void CSSNodeInit(const CSSNodeRef node) { node->style.border[edge] = CSSUndefined; } + node->style.aspectRatio = CSSUndefined; + node->layout.dimensions[CSSDimensionWidth] = CSSUndefined; node->layout.dimensions[CSSDimensionHeight] = CSSUndefined; @@ -459,6 +464,9 @@ CSS_NODE_STYLE_PROPERTY_IMPL(float, MinHeight, minHeight, minDimensions[CSSDimen CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[CSSDimensionWidth]); CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[CSSDimensionHeight]); +// Yoga specific properties, not compatible with flexbox specification +CSS_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio); + CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[CSSEdgeLeft]); CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[CSSEdgeTop]); CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[CSSEdgeRight]); @@ -1032,6 +1040,20 @@ static void computeChildFlexBasis(const CSSNodeRef node, childHeightMeasureMode = CSSMeasureModeExactly; } + if (!CSSValueIsUndefined(child->style.aspectRatio)) { + if (!isMainAxisRow && childWidthMeasureMode == CSSMeasureModeExactly) { + child->layout.computedFlexBasis = + fmaxf(childWidth * child->style.aspectRatio, + getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); + return; + } else if (isMainAxisRow && childHeightMeasureMode == CSSMeasureModeExactly) { + child->layout.computedFlexBasis = + fmaxf(childHeight * child->style.aspectRatio, + getPaddingAndBorderAxis(child, CSSFlexDirectionRow)); + return; + } + } + constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], &childWidthMeasureMode, &childWidth); @@ -1108,6 +1130,20 @@ static void absoluteLayoutChild(const CSSNodeRef node, } } + // Exactly one dimension needs to be defined for us to be able to do aspect ratio + // calculation. One dimension being the anchor and the other being flexible. + if (CSSValueIsUndefined(childWidth) ^ CSSValueIsUndefined(childHeight)) { + if (!CSSValueIsUndefined(child->style.aspectRatio)) { + if (CSSValueIsUndefined(childWidth)) { + childWidth = fmaxf(childHeight * child->style.aspectRatio, + getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); + } else if (CSSValueIsUndefined(childHeight)) { + childHeight = fmaxf(childWidth * child->style.aspectRatio, + getPaddingAndBorderAxis(child, CSSFlexDirectionRow)); + } + } + } + // If we're still missing one or the other dimension, measure the content. if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) { childWidthMeasureMode = @@ -1774,6 +1810,19 @@ static void layoutNodeImpl(const CSSNodeRef node, } } + if (!CSSValueIsUndefined(currentRelativeChild->style.aspectRatio)) { + if (isMainAxisRow && childHeightMeasureMode != CSSMeasureModeExactly) { + childHeight = + fmaxf(childWidth * currentRelativeChild->style.aspectRatio, + getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionColumn)); + childHeightMeasureMode = CSSMeasureModeExactly; + } else if (!isMainAxisRow && childWidthMeasureMode != CSSMeasureModeExactly) { + childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, + getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionRow)); + childWidthMeasureMode = CSSMeasureModeExactly; + } + } + constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionWidth], &childWidthMeasureMode, &childWidth); diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index e052b07e..7bcc244e 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -149,6 +149,15 @@ 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); diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index d7702d09..d8d5ef77 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -46,6 +46,9 @@ - (void)css_setMaxWidth:(CGFloat)maxWidth; - (void)css_setMaxHeight:(CGFloat)maxHeight; +// Yoga specific properties, not compatible with flexbox specification +- (void)css_setAspectRatio:(CGFloat)aspectRatio; + /** Get the resolved direction of this node. This won't be CSSDirectionInherit */ diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index f166b5ff..db5e1b98 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -165,6 +165,11 @@ CSSNodeStyleSetMaxHeight([self cssNode], maxHeight); } +- (void)css_setAspectRatio:(CGFloat)aspectRatio +{ + CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio); +} + #pragma mark - Layout and Sizing - (CSSDirection)css_resolvedDirection diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 6d44995d..32fcc4a9 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -364,6 +364,19 @@ namespace Facebook.CSSLayout } } + public float StyleAspectRatio + { + get + { + return Native.CSSNodeStyleGetAspectRatio(_cssNode); + } + + set + { + Native.CSSNodeStyleSetAspectRatio(_cssNode, value); + } + } + public float LayoutX { get diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index d7c36449..682b8fdd 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -222,6 +222,12 @@ namespace Facebook.CSSLayout [DllImport(DllName)] public static extern float CSSNodeStyleGetMaxHeight(IntPtr node); + [DllImport(DllName)] + public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio); + + [DllImport(DllName)] + public static extern float CSSNodeStyleGetAspectRatio(IntPtr node); + #endregion #region CSS_NODE_STYLE_EDGE_PROPERTY diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 95a5319e..d1943e9c 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -476,6 +476,16 @@ public class CSSNode implements CSSNodeAPI { jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); } + private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer); + public float getStyleAspectRatio() { + return jni_CSSNodeStyleGetAspectRatio(mNativePointer); + } + + private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio); + public void setStyleAspectRatio(float aspectRatio) { + jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio); + } + @Override public float getLayoutX() { return mLeft; diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 2c6ef3af..b5543390 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -249,6 +249,9 @@ 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 *) { @@ -312,6 +315,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) { CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth), CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight), CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight), + CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio), + CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio), CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount), CSSMakeNativeMethod(jni_CSSLayoutSetLogger), diff --git a/tests/CSSLayoutAspectRatioTest.cpp b/tests/CSSLayoutAspectRatioTest.cpp new file mode 100644 index 00000000..e43a7707 --- /dev/null +++ b/tests/CSSLayoutAspectRatioTest.cpp @@ -0,0 +1,407 @@ +/** + * 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 + +static CSSSize _measure(CSSNodeRef node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + return CSSSize { + .width = widthMode == CSSMeasureModeExactly ? width : 50, + .height = heightMode == CSSMeasureModeExactly ? height : 50, + }; +} + +TEST(CSSLayoutTest, aspect_ratio_cross_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_main_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_both_dimensions_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_align_stretch) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_flex_grow) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetFlexGrow(root_child0, 1); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_flex_shrink) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 150); + CSSNodeStyleSetFlexShrink(root_child0, 1); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_basis) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexBasis(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_absolute_layout_width_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); + CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + CSSNodeStyleSetWidth(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); + CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetMaxWidth(root_child0, 40); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 50); + CSSNodeStyleSetMaxHeight(root_child0, 40); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 30); + CSSNodeStyleSetMinWidth(root_child0, 40); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 30); + CSSNodeStyleSetMinHeight(root_child0, 40); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_double_cross) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 2); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_half_cross) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetHeight(root_child0, 100); + CSSNodeStyleSetAspectRatio(root_child0, 0.5); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_double_main) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 50); + CSSNodeStyleSetAspectRatio(root_child0, 2); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_half_main) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 100); + CSSNodeStyleSetAspectRatio(root_child0, 0.5); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST(CSSLayoutTest, aspect_ratio_with_measure_func) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeSetMeasureFunc(root_child0, _measure); + CSSNodeStyleSetAspectRatio(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} From e78cf02a3022d45b03e5a0ac582fa2c367c2490b Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 21 Nov 2016 11:03:53 -0800 Subject: [PATCH 067/108] Move custom measure code out of main layout function Summary: Try to move more code out of the main measure function Reviewed By: gkassabli Differential Revision: D4213302 fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6 --- CSSLayout/CSSLayout.c | 89 +++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index a43019c4..00b03ef6 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1198,6 +1198,55 @@ static void absoluteLayoutChild(const CSSNodeRef node, } } +static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, + const float availableWidth, + const float availableHeight, + const CSSMeasureMode widthMeasureMode, + const CSSMeasureMode heightMeasureMode) { + CSS_ASSERT(node->measure, "Expected node to have custom measure function"); + + const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); + const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + + const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; + const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; + + if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) { + // Don't bother sizing the text if both dimensions are already defined. + node->layout.measuredDimensions[CSSDimensionWidth] = + boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow); + node->layout.measuredDimensions[CSSDimensionHeight] = + boundAxis(node, CSSFlexDirectionColumn, 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[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); + node->layout.measuredDimensions[CSSDimensionHeight] = + boundAxis(node, CSSFlexDirectionColumn, 0); + } else { + // Measure the text under the current constraints. + const CSSSize measuredSize = + node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); + + node->layout.measuredDimensions[CSSDimensionWidth] = + boundAxis(node, + CSSFlexDirectionRow, + (widthMeasureMode == CSSMeasureModeUndefined || + widthMeasureMode == CSSMeasureModeAtMost) + ? measuredSize.width + paddingAndBorderAxisRow + : availableWidth - marginAxisRow); + node->layout.measuredDimensions[CSSDimensionHeight] = + boundAxis(node, + CSSFlexDirectionColumn, + (heightMeasureMode == CSSMeasureModeUndefined || + heightMeasureMode == CSSMeasureModeAtMost) + ? measuredSize.height + paddingAndBorderAxisColumn + : availableHeight - marginAxisColumn); + } +} + // // This is the main routine that implements a subset of the flexbox layout // algorithm @@ -1335,45 +1384,9 @@ static void layoutNodeImpl(const CSSNodeRef node, const CSSDirection direction = resolveDirection(node, parentDirection); node->layout.direction = direction; - // For content (text) nodes, determine the dimensions based on the text - // contents. if (node->measure) { - const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - - if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) { - // Don't bother sizing the text if both dimensions are already defined. - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, 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[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, 0); - } else { - // Measure the text under the current constraints. - const CSSSize measuredSize = - node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); - - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, - CSSFlexDirectionRow, - (widthMeasureMode == CSSMeasureModeUndefined || - widthMeasureMode == CSSMeasureModeAtMost) - ? measuredSize.width + paddingAndBorderAxisRow - : availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, - CSSFlexDirectionColumn, - (heightMeasureMode == CSSMeasureModeUndefined || - heightMeasureMode == CSSMeasureModeAtMost) - ? measuredSize.height + paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); - } - + setMeasuredDimensionsForNodeWithMeasureFunc( + node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode); return; } From f56e8a5163739004de47488597c15a9618d7e6ee Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 21 Nov 2016 11:03:56 -0800 Subject: [PATCH 068/108] Move measure code for empty containers out of main layout function Summary: Try to move more code out of the main measure function Reviewed By: gkassabli Differential Revision: D4213313 fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223 --- CSSLayout/CSSLayout.c | 57 ++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 00b03ef6..2b8e2d61 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1247,6 +1247,34 @@ static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, } } +// 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 CSSMeasureMode widthMeasureMode, + const CSSMeasureMode heightMeasureMode) { + const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); + const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + + node->layout.measuredDimensions[CSSDimensionWidth] = + boundAxis(node, + CSSFlexDirectionRow, + (widthMeasureMode == CSSMeasureModeUndefined || + widthMeasureMode == CSSMeasureModeAtMost) + ? paddingAndBorderAxisRow + : availableWidth - marginAxisRow); + node->layout.measuredDimensions[CSSDimensionHeight] = + boundAxis(node, + CSSFlexDirectionColumn, + (heightMeasureMode == CSSMeasureModeUndefined || + heightMeasureMode == CSSMeasureModeAtMost) + ? paddingAndBorderAxisColumn + : availableHeight - marginAxisColumn); +} + // // This is the main routine that implements a subset of the flexbox layout // algorithm @@ -1375,11 +1403,6 @@ static void layoutNodeImpl(const CSSNodeRef node, "availableHeight is indefinite so heightMeasureMode must be " "CSSMeasureModeUndefined"); - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); - // Set the resolved resolution in the node's layout. const CSSDirection direction = resolveDirection(node, parentDirection); node->layout.direction = direction; @@ -1390,28 +1413,18 @@ static void layoutNodeImpl(const CSSNodeRef node, return; } - // 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. const uint32_t childCount = CSSNodeListCount(node->children); if (childCount == 0) { - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, - CSSFlexDirectionRow, - (widthMeasureMode == CSSMeasureModeUndefined || - widthMeasureMode == CSSMeasureModeAtMost) - ? paddingAndBorderAxisRow - : availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, - CSSFlexDirectionColumn, - (heightMeasureMode == CSSMeasureModeUndefined || - heightMeasureMode == CSSMeasureModeAtMost) - ? paddingAndBorderAxisColumn - : availableHeight - marginAxisColumn); + setMeasuredDimensionsForEmptyContainer( + node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode); return; } + const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); + const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + // If we're not being asked to perform a full layout, we can handle a number // of common // cases here without incurring the cost of the remaining function. From 2d58a36619fef1ad98231c68fac3d9f14e64b753 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 21 Nov 2016 11:03:57 -0800 Subject: [PATCH 069/108] Move measure code for known dimensions out of main layout function Summary: Try to move more code out of the main measure function Reviewed By: gkassabli Differential Revision: D4213339 fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f --- CSSLayout/CSSLayout.c | 92 ++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 2b8e2d61..8c073337 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1275,6 +1275,37 @@ static void setMeasuredDimensionsForEmptyContainer(const CSSNodeRef node, : availableHeight - marginAxisColumn); } +static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, + const float availableWidth, + const float availableHeight, + const CSSMeasureMode widthMeasureMode, + const CSSMeasureMode heightMeasureMode) { + if ((widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) || + (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) || + (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly)) { + const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + + node->layout.measuredDimensions[CSSDimensionWidth] = + boundAxis(node, + CSSFlexDirectionRow, + CSSValueIsUndefined(availableWidth) || availableWidth < 0 + ? 0 + : availableWidth - marginAxisRow); + + node->layout.measuredDimensions[CSSDimensionHeight] = + boundAxis(node, + CSSFlexDirectionColumn, + CSSValueIsUndefined(availableHeight) || availableHeight < 0 + ? 0 + : availableHeight - marginAxisColumn); + + return true; + } + + return false; +} + // // This is the main routine that implements a subset of the flexbox layout // algorithm @@ -1420,56 +1451,12 @@ static void layoutNodeImpl(const CSSNodeRef node, return; } - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); - - // If we're not being asked to perform a full layout, we can handle a number - // of common - // cases here without incurring the cost of the remaining function. - if (!performLayout) { - // If we're being asked to size the content with an at most constraint but - // there is no available - // width, - // the measurement will always be zero. - if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0 && - heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) { - node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, 0); - return; - } - - if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) { - node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, - CSSFlexDirectionColumn, - CSSValueIsUndefined(availableHeight) ? 0 - : (availableHeight - marginAxisColumn)); - return; - } - - if (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) { - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, - CSSFlexDirectionRow, - CSSValueIsUndefined(availableWidth) ? 0 : (availableWidth - marginAxisRow)); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, 0); - return; - } - - // If we're being asked to use an exact width/height, there's no need to - // measure the children. - if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) { - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn); - return; - } + // 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( + node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode)) { + return; } // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM @@ -1491,6 +1478,11 @@ static void layoutNodeImpl(const CSSNodeRef node, const CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; + const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); + const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float availableInnerHeight = From 49a21e657bfb4a99a5f73e9426930dd68024bcae Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 21 Nov 2016 18:06:37 -0800 Subject: [PATCH 070/108] Fix bug where we insert nodes at wrong index in view hierarchy. Summary: We currently have a bug in `UIView+CSSLayout.m` that you can repro in a scenario like this: ``` UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; [container css_setUsesFlexbox:YES]; [container css_setFlexDirection:CSSFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; [subview1 css_setUsesFlexbox:YES]; [subview1 css_setIncludeInLayout:NO]; [container addSubview:subview1]; UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; [subview2 css_setUsesFlexbox:YES]; [subview2 css_setIncludeInLayout:NO]; [container addSubview:subview2]; UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; [subview3 css_setUsesFlexbox:YES]; [subview3 css_setIncludeInLayout:YES]; [container addSubview:subview3]; [container css_applyLayout]; ``` `subview3` (which is the only view whose is going to be included in layout calculation) is inserted at child index 2, instead of 0. This eventually can cause crash in CSSLayout.c because it will attempt access a child in the list which is null. Reviewed By: emilsjolander Differential Revision: D4215659 fbshipit-source-id: a615f50e51f85b15d3bdb437e55958865898b183 --- CSSLayoutKit/Tests/CSSLayoutKitTests.m | 29 ++++++++++++++++++++++++++ CSSLayoutKit/UIView+CSSLayout.h | 5 +++++ CSSLayoutKit/UIView+CSSLayout.m | 19 ++++++++++------- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/CSSLayoutKit/Tests/CSSLayoutKitTests.m b/CSSLayoutKit/Tests/CSSLayoutKitTests.m index 720e0cb2..c6773895 100644 --- a/CSSLayoutKit/Tests/CSSLayoutKitTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutKitTests.m @@ -164,6 +164,35 @@ XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size)); } +- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews +{ + UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + + UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview1 css_setUsesFlexbox:YES]; + [subview1 css_setIncludeInLayout:NO]; + [container addSubview:subview1]; + + UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview2 css_setUsesFlexbox:YES]; + [subview2 css_setIncludeInLayout:NO]; + [container addSubview:subview2]; + + UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview3 css_setUsesFlexbox:YES]; + [subview3 css_setIncludeInLayout:YES]; + [container addSubview:subview3]; + + [container css_applyLayout]; + XCTAssertEqual(1, [container css_numberOfChildren]); + + [subview2 css_setIncludeInLayout:YES]; + [container css_applyLayout]; + XCTAssertEqual(2, [container css_numberOfChildren]); +} + - (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond { UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)]; diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index d8d5ef77..6938fd95 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -64,4 +64,9 @@ */ - (CGSize)css_intrinsicSize; +/** + Returns the number of children that are using Flexbox. + */ +- (NSUInteger)css_numberOfChildren; + @end diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index db5e1b98..57c9e305 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -45,6 +45,11 @@ return (includeInLayout != nil) ? [includeInLayout boolValue] : YES; } +- (NSUInteger)css_numberOfChildren +{ + return CSSNodeChildCount([self cssNode]); +} + #pragma mark - Setters - (void)css_setIncludeInLayout:(BOOL)includeInLayout @@ -281,24 +286,24 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { } else { CSSNodeSetMeasureFunc(node, NULL); - NSUInteger numSubviewsInLayout = 0; + NSUInteger subviewIndex = 0; // Add any children which were added since the last call to css_applyLayout - for (NSUInteger i = 0; i < view.subviews.count; i++) { - UIView *const subview = view.subviews[i]; + for (UIView *subview in view.subviews) { if (![subview css_includeInLayout]) { continue; } - numSubviewsInLayout++; CSSNodeRef childNode = [subview cssNode]; - if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) { - CSSNodeInsertChild(node, childNode, i); + if (CSSNodeGetChild(node, subviewIndex) != childNode) { + CSSNodeInsertChild(node, childNode, subviewIndex); } + CSSAttachNodesFromViewHierachy(subview); + subviewIndex++; } // Remove any children which were removed since the last call to css_applyLayout - while (numSubviewsInLayout < CSSNodeChildCount(node)) { + while (subviewIndex < CSSNodeChildCount(node)) { CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); } } From d54f09e32b9469c6015ee8b6d05b2089c16ee2f5 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 22 Nov 2016 02:46:00 -0800 Subject: [PATCH 071/108] Use ASSERT_FLOAT_EQ instead of ASSERT_EQ Summary: Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values. Closes https://github.com/facebook/css-layout/pull/257 Reviewed By: splhack Differential Revision: D4213809 Pulled By: emilsjolander fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2 --- gentest/gentest-cpp.js | 30 +- tests/CSSLayoutAbsolutePositionTest.cpp | 224 ++++----- tests/CSSLayoutAlignContentTest.cpp | 384 +++++++------- tests/CSSLayoutAlignItemsTest.cpp | 128 ++--- tests/CSSLayoutAlignSelfTest.cpp | 128 ++--- tests/CSSLayoutBorderTest.cpp | 144 +++--- tests/CSSLayoutDefaultValuesTest.cpp | 36 +- tests/CSSLayoutEdgeTest.cpp | 48 +- tests/CSSLayoutFlexDirectionTest.cpp | 384 +++++++------- tests/CSSLayoutFlexTest.cpp | 368 +++++++------- tests/CSSLayoutFlexWrapTest.cpp | 320 ++++++------ tests/CSSLayoutJustifyContentTest.cpp | 640 ++++++++++++------------ tests/CSSLayoutMarginTest.cpp | 352 ++++++------- tests/CSSLayoutMeasureModeTest.cpp | 22 +- tests/CSSLayoutMinMaxDimensionTest.cpp | 384 +++++++------- tests/CSSLayoutPaddingTest.cpp | 144 +++--- tests/CSSLayoutRelayoutTest.cpp | 2 +- tests/CSSLayoutStyleTest.cpp | 2 +- 18 files changed, 1872 insertions(+), 1868 deletions(-) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 9e378816..2a5e8d24 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +function toFloatString(n) { + return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); +} + var CPPEmitter = function() { Emitter.call(this, 'cpp', ' '); }; @@ -47,7 +51,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, AssertEQ:{value:function(v0, v1) { - this.push('ASSERT_EQ(' + v0 + ', ' + v1 + ');'); + this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');'); }}, CSSAlignAuto:{value:'CSSAlignAuto'}, @@ -134,7 +138,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -142,11 +146,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { @@ -154,7 +158,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -162,23 +166,23 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + value + ');'); + this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -186,11 +190,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + value + ');'); + this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + value + ');'); + this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -198,6 +202,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + value + ');'); + this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, }); diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index 905cd73b..2692f05e 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -56,27 +56,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -95,27 +95,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -134,27 +134,27 @@ TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -175,27 +175,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -219,37 +219,37 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root)); + 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_EQ(-50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeFreeRecursive(root); } @@ -288,37 +288,37 @@ TEST(CSSLayoutTest, absolute_layout_within_border) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index 9fe462a4..64523b8e 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -79,67 +79,67 @@ TEST(CSSLayoutTest, align_content_flex_start) { CSSNodeInsertChild(root, root_child4, 4); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeFreeRecursive(root); } @@ -177,67 +177,67 @@ TEST(CSSLayoutTest, align_content_flex_end) { CSSNodeInsertChild(root, root_child4, 4); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeFreeRecursive(root); } @@ -275,67 +275,67 @@ TEST(CSSLayoutTest, align_content_center) { CSSNodeInsertChild(root, root_child4, 4); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeFreeRecursive(root); } @@ -368,67 +368,67 @@ TEST(CSSLayoutTest, align_content_stretch) { CSSNodeInsertChild(root, root_child4, 4); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child4)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index 9a9ca6cc..0047dfc5 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -41,27 +41,27 @@ TEST(CSSLayoutTest, align_items_stretch) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -78,27 +78,27 @@ TEST(CSSLayoutTest, align_items_center) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -115,27 +115,27 @@ TEST(CSSLayoutTest, align_items_flex_start) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -152,27 +152,27 @@ TEST(CSSLayoutTest, align_items_flex_end) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index 7392fc8a..28eee5bb 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -43,27 +43,27 @@ TEST(CSSLayoutTest, align_self_center) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(45, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -80,27 +80,27 @@ TEST(CSSLayoutTest, align_self_flex_end) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -117,27 +117,27 @@ TEST(CSSLayoutTest, align_self_flex_start) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -155,27 +155,27 @@ TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index 08f67302..7e818ba9 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -42,17 +42,17 @@ TEST(CSSLayoutTest, border_no_size) { CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); CSSNodeFreeRecursive(root); } @@ -70,27 +70,27 @@ TEST(CSSLayoutTest, border_container_match_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -110,27 +110,27 @@ TEST(CSSLayoutTest, border_flex_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -149,27 +149,27 @@ TEST(CSSLayoutTest, border_stretch_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -190,27 +190,27 @@ TEST(CSSLayoutTest, border_center_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutDefaultValuesTest.cpp b/tests/CSSLayoutDefaultValuesTest.cpp index f9e1766e..727084c4 100644 --- a/tests/CSSLayoutDefaultValuesTest.cpp +++ b/tests/CSSLayoutDefaultValuesTest.cpp @@ -25,8 +25,8 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root)); ASSERT_EQ(CSSWrapNoWrap, CSSNodeStyleGetFlexWrap(root)); ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root)); - ASSERT_EQ(0, CSSNodeStyleGetFlexGrow(root)); - ASSERT_EQ(0, CSSNodeStyleGetFlexShrink(root)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexGrow(root)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexShrink(root)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeLeft))); @@ -36,24 +36,24 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeEnd))); - ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeLeft)); - ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeTop)); - ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeRight)); - ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeBottom)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeLeft)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeTop)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeRight)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeBottom)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeEnd))); - ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeLeft)); - ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeTop)); - ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeRight)); - ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeBottom)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeLeft)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeTop)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeRight)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeBottom)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeEnd))); - ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeLeft)); - ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeTop)); - ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeRight)); - ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeBottom)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeLeft)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeTop)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeRight)); + ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeBottom)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeEnd))); @@ -64,10 +64,10 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxWidth(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(root))); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(0, CSSNodeLayoutGetRight(root)); - ASSERT_EQ(0, CSSNodeLayoutGetBottom(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(CSSDirectionInherit, CSSNodeLayoutGetDirection(root)); diff --git a/tests/CSSLayoutEdgeTest.cpp b/tests/CSSLayoutEdgeTest.cpp index 09c718ed..ea171b59 100644 --- a/tests/CSSLayoutEdgeTest.cpp +++ b/tests/CSSLayoutEdgeTest.cpp @@ -24,12 +24,12 @@ TEST(CSSLayoutTest, start_overrides) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); CSSNodeFreeRecursive(root); } @@ -48,12 +48,12 @@ TEST(CSSLayoutTest, end_overrides) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); CSSNodeFreeRecursive(root); } @@ -71,8 +71,8 @@ TEST(CSSLayoutTest, horizontal_overridden) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); CSSNodeFreeRecursive(root); } @@ -90,8 +90,8 @@ TEST(CSSLayoutTest, vertical_overridden) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); CSSNodeFreeRecursive(root); } @@ -109,10 +109,10 @@ TEST(CSSLayoutTest, horizontal_overrides_all) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetBottom(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -130,10 +130,10 @@ TEST(CSSLayoutTest, vertical_overrides_all) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -154,10 +154,10 @@ TEST(CSSLayoutTest, all_overridden) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index c1226c26..14a1b181 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -68,47 +68,47 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -131,47 +131,47 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -194,47 +194,47 @@ TEST(CSSLayoutTest, flex_direction_column) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -258,47 +258,47 @@ TEST(CSSLayoutTest, flex_direction_row) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -322,47 +322,47 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -386,47 +386,47 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index 65991c06..a769e9e8 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -68,37 +68,37 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -119,37 +119,37 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(75, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(25, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -169,37 +169,37 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -220,37 +220,37 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -276,47 +276,47 @@ TEST(CSSLayoutTest, flex_shrink_to_zero) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(75, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(75, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -343,47 +343,47 @@ TEST(CSSLayoutTest, flex_basis_overrides_main_size) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -402,37 +402,37 @@ TEST(CSSLayoutTest, flex_grow_shrink_at_most) { CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index 74b23657..a3a16d4e 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -69,57 +69,57 @@ TEST(CSSLayoutTest, wrap_column) { CSSNodeInsertChild(root, root_child3, 3); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeFreeRecursive(root); } @@ -151,57 +151,57 @@ TEST(CSSLayoutTest, wrap_row) { CSSNodeInsertChild(root, root_child3, 3); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeFreeRecursive(root); } @@ -234,57 +234,57 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { CSSNodeInsertChild(root, root_child3, 3); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeFreeRecursive(root); } @@ -317,57 +317,57 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) { CSSNodeInsertChild(root, root_child3, 3); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(30, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(5, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(60, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(5, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + 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_EQ(70, CSSNodeLayoutGetLeft(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index dde60e7d..17e5e16a 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -94,47 +94,47 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(92, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(82, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(72, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -159,47 +159,47 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(72, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(82, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(92, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -224,47 +224,47 @@ TEST(CSSLayoutTest, justify_content_row_center) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(36, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(56, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(56, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(36, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -289,47 +289,47 @@ TEST(CSSLayoutTest, justify_content_row_space_between) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(92, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(92, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -354,47 +354,47 @@ TEST(CSSLayoutTest, justify_content_row_space_around) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(12, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(46, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(12, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -416,47 +416,47 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -480,47 +480,47 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(72, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(82, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(72, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(82, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -544,47 +544,47 @@ TEST(CSSLayoutTest, justify_content_column_center) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(36, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(56, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(36, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(56, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -608,47 +608,47 @@ TEST(CSSLayoutTest, justify_content_column_space_between) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -672,47 +672,47 @@ TEST(CSSLayoutTest, justify_content_column_space_around) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(12, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(12, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index 1a504390..75d87d7a 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -69,27 +69,27 @@ TEST(CSSLayoutTest, margin_start) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -105,27 +105,27 @@ TEST(CSSLayoutTest, margin_top) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -143,27 +143,27 @@ TEST(CSSLayoutTest, margin_end) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -180,27 +180,27 @@ TEST(CSSLayoutTest, margin_bottom) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -217,27 +217,27 @@ TEST(CSSLayoutTest, margin_and_flex_row) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -253,27 +253,27 @@ TEST(CSSLayoutTest, margin_and_flex_column) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -290,27 +290,27 @@ TEST(CSSLayoutTest, margin_and_stretch_row) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -326,27 +326,27 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -366,37 +366,37 @@ TEST(CSSLayoutTest, margin_with_sibling_row) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -415,37 +415,37 @@ TEST(CSSLayoutTest, margin_with_sibling_column) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/CSSLayoutMeasureModeTest.cpp index 1f091068..cc946fc1 100644 --- a/tests/CSSLayoutMeasureModeTest.cpp +++ b/tests/CSSLayoutMeasureModeTest.cpp @@ -61,7 +61,7 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_column) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].width); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].widthMode); free(constraintList.constraints); @@ -88,7 +88,7 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); @@ -114,7 +114,7 @@ TEST(CSSLayoutTest, at_most_main_axis_column) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); @@ -141,7 +141,7 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].width); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); @@ -168,7 +168,7 @@ TEST(CSSLayoutTest, at_most_main_axis_row) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].width); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); @@ -196,7 +196,7 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); @@ -222,10 +222,10 @@ TEST(CSSLayoutTest, flex_child) { ASSERT_EQ(2, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); - ASSERT_EQ(100, constraintList.constraints[1].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[1].height); ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[1].heightMode); free(constraintList.constraints); @@ -252,7 +252,7 @@ TEST(CSSLayoutTest, flex_child_with_flex_basis) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); @@ -280,7 +280,7 @@ TEST(CSSLayoutTest, overflow_scroll_column) { ASSERT_EQ(1, constraintList.length); - ASSERT_EQ(100, constraintList.constraints[0].width); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].height)); @@ -315,7 +315,7 @@ TEST(CSSLayoutTest, overflow_scroll_row) { ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].width)); ASSERT_EQ(CSSMeasureModeUndefined, constraintList.constraints[0].widthMode); - ASSERT_EQ(100, constraintList.constraints[0].height); + ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index b9bec882..b5f162a9 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -70,27 +70,27 @@ TEST(CSSLayoutTest, max_width) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -107,27 +107,27 @@ TEST(CSSLayoutTest, max_height) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(90, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -147,37 +147,37 @@ TEST(CSSLayoutTest, min_height) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -198,37 +198,37 @@ TEST(CSSLayoutTest, min_width) { CSSNodeInsertChild(root, root_child1, 1); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + 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)); CSSNodeFreeRecursive(root); } @@ -246,27 +246,27 @@ TEST(CSSLayoutTest, justify_content_min_max) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -284,27 +284,27 @@ TEST(CSSLayoutTest, align_items_min_max) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(20, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -331,47 +331,47 @@ TEST(CSSLayoutTest, justify_content_overflow_min_max) { CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(110, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(-20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(110, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(-20, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); } @@ -392,37 +392,37 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) { CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(100, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeFreeRecursive(root); } @@ -443,37 +443,37 @@ TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 91ed3ddc..e802b890 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -42,17 +42,17 @@ TEST(CSSLayoutTest, padding_no_size) { CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root)); CSSNodeFreeRecursive(root); } @@ -70,27 +70,27 @@ TEST(CSSLayoutTest, padding_container_match_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -110,27 +110,27 @@ TEST(CSSLayoutTest, padding_flex_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(80, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -149,27 +149,27 @@ TEST(CSSLayoutTest, padding_stretch_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(10, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } @@ -190,27 +190,27 @@ TEST(CSSLayoutTest, padding_center_child) { CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(40, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + 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_EQ(50, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + 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)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp index e30965db..e653f049 100644 --- a/tests/CSSLayoutRelayoutTest.cpp +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -21,7 +21,7 @@ TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { CSSNodeCalculateLayout(root, 100, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); - ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); + ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutStyleTest.cpp b/tests/CSSLayoutStyleTest.cpp index 6b7579af..0ff51890 100644 --- a/tests/CSSLayoutStyleTest.cpp +++ b/tests/CSSLayoutStyleTest.cpp @@ -35,7 +35,7 @@ TEST(CSSLayoutTest, copy_style_modified) { CSSNodeCopyStyle(node0, node1); ASSERT_TRUE(CSSNodeIsDirty(node0)); ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0)); - ASSERT_EQ(10, CSSNodeStyleGetMaxHeight(node0)); + ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0)); CSSNodeFree(node0); CSSNodeFree(node1); From b90f6e21bdc64845dc75cfb6662a810547f005e7 Mon Sep 17 00:00:00 2001 From: Lukas Woehrl Date: Tue, 22 Nov 2016 05:33:36 -0800 Subject: [PATCH 072/108] Added feature to use rounded values Summary: Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely can be further improved. I'm looking forward to your ideas. Closes https://github.com/facebook/css-layout/pull/256 Reviewed By: splhack Differential Revision: D4214168 Pulled By: emilsjolander fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236 --- CSSLayout/CSSEnums.h | 1 + CSSLayout/CSSLayout.c | 25 +- CSSLayout/CSSLayout.h | 9 +- .../CSSExperimentalFeature.cs | 1 + enums.py | 4 +- .../csslayout/CSSExperimentalFeature.java | 4 +- tests/CSSLayoutPixelRoundingTest.cpp | 852 ++++++++++++++++++ 7 files changed, 890 insertions(+), 6 deletions(-) create mode 100644 tests/CSSLayoutPixelRoundingTest.cpp diff --git a/CSSLayout/CSSEnums.h b/CSSLayout/CSSEnums.h index 8f9979f5..dbcb58e2 100644 --- a/CSSLayout/CSSEnums.h +++ b/CSSLayout/CSSEnums.h @@ -67,6 +67,7 @@ typedef enum CSSDirection { } CSSDirection; typedef enum CSSExperimentalFeature { + CSSExperimentalFeatureRounding, CSSExperimentalFeatureCount, } CSSExperimentalFeature; diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 8c073337..eeb99195 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -2534,6 +2534,25 @@ bool layoutNodeInternal(const CSSNodeRef node, return (needToVisitNode || cachedResults == NULL); } +static void roundToPixelGrid(const CSSNodeRef node) { + const float fractialLeft = + node->layout.position[CSSEdgeLeft] - floorf(node->layout.position[CSSEdgeLeft]); + const float fractialTop = + node->layout.position[CSSEdgeTop] - floorf(node->layout.position[CSSEdgeTop]); + node->layout.dimensions[CSSDimensionWidth] = + roundf(fractialLeft + node->layout.dimensions[CSSDimensionWidth]) - roundf(fractialLeft); + node->layout.dimensions[CSSDimensionHeight] = + roundf(fractialTop + node->layout.dimensions[CSSDimensionHeight]) - roundf(fractialTop); + + node->layout.position[CSSEdgeLeft] = roundf(node->layout.position[CSSEdgeLeft]); + node->layout.position[CSSEdgeTop] = roundf(node->layout.position[CSSEdgeTop]); + + const uint32_t childCount = CSSNodeListCount(node->children); + for (uint32_t i = 0; i < childCount; i++) { + roundToPixelGrid(CSSNodeGetChild(node, i)); + } +} + void CSSNodeCalculateLayout(const CSSNodeRef node, const float availableWidth, const float availableHeight, @@ -2583,6 +2602,10 @@ void CSSNodeCalculateLayout(const CSSNodeRef node, "l")) { setPosition(node, node->layout.direction); + if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureRounding)) { + roundToPixelGrid(node); + } + if (gPrintTree) { CSSNodePrint(node, CSSPrintOptionsLayout | CSSPrintOptionsChildren | CSSPrintOptionsStyle); } @@ -2606,7 +2629,7 @@ void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool experimentalFeatures[feature] = enabled; } -bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) { +inline bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) { return experimentalFeatures[feature]; } diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 7bcc244e..e2dca0a7 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -152,9 +152,12 @@ 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 +// - 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); diff --git a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs index bd080932..9eb74309 100644 --- a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs +++ b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs @@ -11,5 +11,6 @@ namespace Facebook.CSSLayout { public enum CSSExperimentalFeature { + Rounding, } } diff --git a/enums.py b/enums.py index 40f36d5a..76261b7f 100644 --- a/enums.py +++ b/enums.py @@ -77,7 +77,9 @@ ENUMS = { 'Debug', 'Verbose', ], - 'CSSExperimentalFeature': [], + 'CSSExperimentalFeature': [ + 'Rounding', + ], 'CSSPrintOptions': [ ('Layout', 1), ('Style', 2), diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/CSSExperimentalFeature.java index e0b269f9..c2b8b7af 100644 --- a/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -10,7 +10,8 @@ package com.facebook.csslayout; public enum CSSExperimentalFeature { -__EMPTY(-1); + ROUNDING(0); + private int mIntValue; CSSExperimentalFeature(int intValue) { @@ -23,6 +24,7 @@ __EMPTY(-1); public static CSSExperimentalFeature fromInt(int value) { switch (value) { + case 0: return ROUNDING; default: throw new IllegalArgumentException("Unkown enum value: " + value); } } diff --git a/tests/CSSLayoutPixelRoundingTest.cpp b/tests/CSSLayoutPixelRoundingTest.cpp new file mode 100644 index 00000000..8fb3c73a --- /dev/null +++ b/tests/CSSLayoutPixelRoundingTest.cpp @@ -0,0 +1,852 @@ +/** + * 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 + +class CSSLayoutFeatureRoundingTest : public ::testing::Test { + +protected: + virtual void SetUp() { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + } + + virtual void TearDown() { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + } +}; + +TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_width_of_100) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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(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(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)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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(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(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(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)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_prime_number_width) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetWidth(root, 113); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child0, 1); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeInsertChild(root, root_child2, 2); + + const CSSNodeRef root_child3 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child3, 1); + CSSNodeInsertChild(root, root_child3, 3); + + const CSSNodeRef root_child4 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child4, 1); + CSSNodeInsertChild(root, root_child4, 4); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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(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(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(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(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)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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(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(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(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(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(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)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_shrink_row) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetWidth(root, 101); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexShrink(root_child0, 1); + CSSNodeStyleSetFlexBasis(root_child0, 100); + CSSNodeInsertChild(root, root_child0, 0); + + const CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexBasis(root_child1, 25); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexBasis(root_child2, 25); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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(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(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)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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(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(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(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)); + + CSSNodeFreeRecursive(root); +} + + +TEST_F(CSSLayoutFeatureRoundingTest, pixel_roundingflex_basis_overrides_main_size) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeStyleSetHeight(root_child2, 10); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(113, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(113, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_1) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeStyleSetHeight(root_child2, 10); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_2) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeStyleSetHeight(root_child2, 10); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_3) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.3f); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeStyleSetHeight(root_child2, 10); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_4) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.7f); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(root, root_child1, 1); + + const CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1); + CSSNodeStyleSetHeight(root_child2, 10); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 87.4f); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1.6f); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + + +TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial_nested) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 87.4f); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child0_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child0_child0, 1.2f); + CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f); + CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f); + CSSNodeStyleSetHeight(root_child0_child0, 9.9f); + CSSNodeInsertChild(root_child0, root_child0_child0, 0); + + const CSSNodeRef root_child0_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child0_child1, 4.2f); + CSSNodeStyleSetFlexBasis(root_child0_child1, 0.3f); + CSSNodeStyleSetPosition(root_child0_child1, CSSEdgeTop, 13.3f); + CSSNodeStyleSetHeight(root_child0_child1, 1.1f); + CSSNodeInsertChild(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 CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1.1f); + CSSNodeStyleSetHeight(root_child2, 10.7f); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); +} + + +static CSSSize _measureFloor(CSSNodeRef node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + + return CSSSize{ + width = 10.2, + height = 10.2, + }; +} + +static CSSSize _measureCeil(CSSNodeRef node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + + return CSSSize{ + width = 10.5, + height = 10.5, + }; +} + + +TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_floor) { + const CSSNodeRef root = CSSNodeNew(); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeSetMeasureFunc(root_child0, _measureFloor); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} + +TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_ceil) { + const CSSNodeRef root = CSSNodeNew(); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeSetMeasureFunc(root_child0, _measureCeil); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} From dc10fdd9585e12a172cc14650e002fc6f42140f5 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Tue, 22 Nov 2016 08:27:03 -0800 Subject: [PATCH 073/108] Fix bug where swapping views in hierarchy throws an assert. Summary: I found that if you move a subview to a different index, it would cause a crash in subsequent layout passes because the `CSSNodeRef` representing it was being re-inserted into the list. I spent a lot of time figuring out the best way to "diff" the view hierarchy from before and after, and I found the easiest implementation is also the most reliable. We can continue to optimize, but this is a great start. Reviewed By: emilsjolander Differential Revision: D4218623 fbshipit-source-id: 06253089492ac37ae4b94b7c30140ce6ed680ed2 --- CSSLayoutKit/Tests/CSSLayoutKitTests.m | 40 +++++++++++++++++ CSSLayoutKit/UIView+CSSLayout.m | 60 ++++++++++++++++---------- 2 files changed, 77 insertions(+), 23 deletions(-) diff --git a/CSSLayoutKit/Tests/CSSLayoutKitTests.m b/CSSLayoutKit/Tests/CSSLayoutKitTests.m index c6773895..22b159b2 100644 --- a/CSSLayoutKit/Tests/CSSLayoutKitTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutKitTests.m @@ -125,6 +125,46 @@ XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth); } +- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder +{ + const CGSize containerSize = CGSizeMake(300, 50); + + UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; + [container css_setUsesFlexbox:YES]; + [container css_setFlexDirection:CSSFlexDirectionRow]; + + UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview1 css_setUsesFlexbox:YES]; + [subview1 css_setFlexGrow:1]; + [container addSubview:subview1]; + + UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview2 css_setUsesFlexbox:YES]; + [subview2 css_setFlexGrow:1]; + [container addSubview:subview2]; + + UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview3 css_setUsesFlexbox:YES]; + [subview3 css_setFlexGrow:1]; + [container addSubview:subview3]; + + [container css_applyLayout]; + + XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50))); + XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame)); + XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50))); + + [container exchangeSubviewAtIndex:2 withSubviewAtIndex:0]; + [subview2 css_setIncludeInLayout:NO]; + [container css_applyLayout]; + + XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50))); + XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50))); + + // this frame shouldn't have been modified since last time. + XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50))); +} + - (void)testThatWeRespectIncludeInLayoutFlag { const CGSize containerSize = CGSizeMake(300, 50); diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 57c9e305..56ddfcf7 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -272,40 +272,54 @@ static CGFloat CSSSanitizeMeasurement( static void CSSAttachNodesFromViewHierachy(UIView *view) { CSSNodeRef node = [view cssNode]; - const BOOL usesFlexbox = [view css_usesFlexbox]; - const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0; // Only leaf nodes should have a measure function - if (isLeaf) { + if (![view css_usesFlexbox] || view.subviews.count == 0) { CSSNodeSetMeasureFunc(node, CSSMeasureView); - - // Clear any children - while (CSSNodeChildCount(node) > 0) { - CSSNodeRemoveChild(node, CSSNodeGetChild(node, 0)); - } + CSSRemoveAllChildren(node); } else { CSSNodeSetMeasureFunc(node, NULL); - NSUInteger subviewIndex = 0; - // Add any children which were added since the last call to css_applyLayout + // Create a list of all the subviews that we are going to use for layout. + NSMutableArray *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count]; for (UIView *subview in view.subviews) { - if (![subview css_includeInLayout]) { - continue; + if ([subview css_includeInLayout]) { + [subviewsToInclude addObject:subview]; } - - CSSNodeRef childNode = [subview cssNode]; - if (CSSNodeGetChild(node, subviewIndex) != childNode) { - CSSNodeInsertChild(node, childNode, subviewIndex); - } - - CSSAttachNodesFromViewHierachy(subview); - subviewIndex++; } - // Remove any children which were removed since the last call to css_applyLayout - while (subviewIndex < CSSNodeChildCount(node)) { - CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); + BOOL shouldReconstructChildList = NO; + if (CSSNodeChildCount(node) != subviewsToInclude.count) { + shouldReconstructChildList = YES; + } else { + for (int i = 0; i < subviewsToInclude.count; i++) { + if (CSSNodeGetChild(node, i) != [subviewsToInclude[i] cssNode]) { + shouldReconstructChildList = YES; + break; + } + } } + + if (shouldReconstructChildList) { + CSSRemoveAllChildren(node); + + for (int i = 0 ; i < subviewsToInclude.count; i++) { + UIView *const subview = subviewsToInclude[i]; + CSSNodeInsertChild(node, [subview cssNode], i); + CSSAttachNodesFromViewHierachy(subview); + } + } + } +} + +static void CSSRemoveAllChildren(const CSSNodeRef node) +{ + if (node == NULL) { + return; + } + + while (CSSNodeChildCount(node) > 0) { + CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); } } From a0d560a24bc5d4b895352dcea9a194c68aabe4b2 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 23 Nov 2016 05:25:50 -0800 Subject: [PATCH 074/108] Fixup recent fix to flex basis and put it behind an experimental flag Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag. Reviewed By: gkassabli Differential Revision: D4222910 fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541 --- CSSLayout/CSSEnums.h | 1 + CSSLayout/CSSLayout.c | 3 ++- CSSLayoutKit/UIView+CSSLayout.m | 6 ++++++ .../Facebook.CSSLayout/CSSExperimentalFeature.cs | 1 + enums.py | 2 ++ .../facebook/csslayout/CSSExperimentalFeature.java | 4 +++- tests/CSSLayoutRelayoutTest.cpp | 14 +++++++++++++- 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CSSLayout/CSSEnums.h b/CSSLayout/CSSEnums.h index dbcb58e2..94a6ba1b 100644 --- a/CSSLayout/CSSEnums.h +++ b/CSSLayout/CSSEnums.h @@ -68,6 +68,7 @@ typedef enum CSSDirection { typedef enum CSSExperimentalFeature { CSSExperimentalFeatureRounding, + CSSExperimentalFeatureWebFlexBasis, CSSExperimentalFeatureCount, } CSSExperimentalFeature; diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index eeb99195..5b102509 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -977,7 +977,8 @@ static void computeChildFlexBasis(const CSSNodeRef node, if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && !CSSValueIsUndefined(isMainAxisRow ? width : height)) { if (CSSValueIsUndefined(child->layout.computedFlexBasis) || - child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { + (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) && + child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); } diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 56ddfcf7..664f50fb 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -16,6 +16,12 @@ @end @implementation CSSNodeBridge + ++ (void)initialize +{ + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); +} + - (instancetype)init { if ([super init]) { diff --git a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs index 9eb74309..160fc724 100644 --- a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs +++ b/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs @@ -12,5 +12,6 @@ namespace Facebook.CSSLayout public enum CSSExperimentalFeature { Rounding, + WebFlexBasis, } } diff --git a/enums.py b/enums.py index 76261b7f..5e361b9e 100644 --- a/enums.py +++ b/enums.py @@ -79,6 +79,8 @@ ENUMS = { ], 'CSSExperimentalFeature': [ 'Rounding', + # Mimic web flex-basis behavior. + 'WebFlexBasis', ], 'CSSPrintOptions': [ ('Layout', 1), diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/CSSExperimentalFeature.java index c2b8b7af..d9476e81 100644 --- a/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -10,7 +10,8 @@ package com.facebook.csslayout; public enum CSSExperimentalFeature { - ROUNDING(0); + ROUNDING(0), + WEB_FLEX_BASIS(1); private int mIntValue; @@ -25,6 +26,7 @@ public enum CSSExperimentalFeature { public static CSSExperimentalFeature fromInt(int value) { switch (value) { case 0: return ROUNDING; + case 1: return WEB_FLEX_BASIS; default: throw new IllegalArgumentException("Unkown enum value: " + value); } } diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp index e653f049..fa5226b4 100644 --- a/tests/CSSLayoutRelayoutTest.cpp +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -10,7 +10,19 @@ #include #include -TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { +class CSSLayoutRelayoutTest : public ::testing::Test { + +protected: + virtual void SetUp() { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); + } + + virtual void TearDown() { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false); + } +}; + +TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) { const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew(); From 22b0fdb3e6cce7a76074ebf2f25570252c1ee56a Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 23 Nov 2016 11:12:51 -0800 Subject: [PATCH 075/108] Add experiment support to gentest Summary: This diff does two things - Clean up some of the generated code making the files smaller. - Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior. Reviewed By: gkassabli Differential Revision: D4226734 fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b --- csharp/Facebook.CSSLayout/CSSNode.cs | 4 +- .../CSSLayoutAbsolutePositionTest.cs | 364 ++++---- .../CSSLayoutAlignContentTest.cs | 507 +++++------ .../CSSLayoutAlignItemsTest.cs | 179 ++-- .../CSSLayoutAlignSelfTest.cs | 181 ++-- .../Facebook.CSSLayout/CSSLayoutBorderTest.cs | 232 +++-- .../CSSLayoutFlexDirectionTest.cs | 481 +++++------ .../Facebook.CSSLayout/CSSLayoutFlexTest.cs | 493 +++++------ .../CSSLayoutFlexWrapTest.cs | 425 +++++---- .../CSSLayoutJustifyContentTest.cs | 803 ++++++++--------- .../Facebook.CSSLayout/CSSLayoutMarginTest.cs | 479 +++++------ .../CSSLayoutMinMaxDimensionTest.cs | 525 ++++++------ .../CSSLayoutPaddingTest.cs | 232 +++-- .../CSSLayoutRoundingTest.cs | 807 ++++++++++++++++++ gentest/fixtures/CSSLayoutRoundingTest.html | 64 ++ gentest/gentest-cpp.js | 21 +- gentest/gentest-cs.js | 46 +- gentest/gentest-java.js | 56 +- gentest/gentest.js | 38 +- gentest/gentest.rb | 11 +- gentest/test-template.html | 2 +- .../CSSLayoutAbsolutePositionTest.java | 356 ++++---- .../csslayout/CSSLayoutAlignContentTest.java | 507 +++++------ .../csslayout/CSSLayoutAlignItemsTest.java | 179 ++-- .../csslayout/CSSLayoutAlignSelfTest.java | 181 ++-- .../csslayout/CSSLayoutBorderTest.java | 232 +++-- .../csslayout/CSSLayoutFlexDirectionTest.java | 481 +++++------ .../facebook/csslayout/CSSLayoutFlexTest.java | 493 +++++------ .../csslayout/CSSLayoutFlexWrapTest.java | 425 +++++---- .../CSSLayoutJustifyContentTest.java | 803 ++++++++--------- .../csslayout/CSSLayoutMarginTest.java | 479 +++++------ .../CSSLayoutMinMaxDimensionTest.java | 525 ++++++------ .../csslayout/CSSLayoutPaddingTest.java | 194 ++--- .../csslayout/CSSLayoutRoundingTest.java | 795 +++++++++++++++++ tests/CSSLayoutAbsolutePositionTest.cpp | 32 +- tests/CSSLayoutAlignContentTest.cpp | 37 +- tests/CSSLayoutAlignItemsTest.cpp | 21 +- tests/CSSLayoutAlignSelfTest.cpp | 21 +- tests/CSSLayoutBorderTest.cpp | 24 +- tests/CSSLayoutFlexDirectionTest.cpp | 41 +- tests/CSSLayoutFlexTest.cpp | 43 +- tests/CSSLayoutFlexWrapTest.cpp | 33 +- tests/CSSLayoutJustifyContentTest.cpp | 65 +- tests/CSSLayoutMarginTest.cpp | 47 +- tests/CSSLayoutMinMaxDimensionTest.cpp | 49 +- tests/CSSLayoutPaddingTest.cpp | 24 +- tests/CSSLayoutRelayoutTest.cpp | 16 +- tests/CSSLayoutRoundingMeasureFuncTest.cpp | 73 ++ ...dingTest.cpp => CSSLayoutRoundingTest.cpp} | 567 ++++++------ 49 files changed, 6574 insertions(+), 6119 deletions(-) create mode 100644 csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs create mode 100644 gentest/fixtures/CSSLayoutRoundingTest.html create mode 100644 java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java create mode 100644 tests/CSSLayoutRoundingMeasureFuncTest.cpp rename tests/{CSSLayoutPixelRoundingTest.cpp => CSSLayoutRoundingTest.cpp} (81%) diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 32fcc4a9..4536f83b 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -569,14 +569,14 @@ namespace Facebook.CSSLayout return Native.CSSNodeGetInstanceCount(); } - public static void setExperimentalFeatureEnabled( + public static void SetExperimentalFeatureEnabled( CSSExperimentalFeature feature, bool enabled) { Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); } - public static bool isExperimentalFeatureEnabled(CSSExperimentalFeature feature) + public static bool IsExperimentalFeatureEnabled(CSSExperimentalFeature feature) { return Native.CSSLayoutIsExperimentalFeatureEnabled(feature); } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index 08c75a6b..5458bbb2 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -7,37 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html using System; using NUnit.Framework; @@ -51,166 +21,166 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_width_height_start_top() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10); - root_child0.SetPosition(CSSEdge.Top, 10); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.SetPosition(CSSEdge.Start, 10f); + root_child0.SetPosition(CSSEdge.Top, 10f); + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_absolute_layout_width_height_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.End, 10); - root_child0.SetPosition(CSSEdge.Bottom, 10); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.SetPosition(CSSEdge.End, 10f); + root_child0.SetPosition(CSSEdge.Bottom, 10f); + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(80, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(80, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_absolute_layout_start_top_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10); - root_child0.SetPosition(CSSEdge.Top, 10); - root_child0.SetPosition(CSSEdge.End, 10); - root_child0.SetPosition(CSSEdge.Bottom, 10); + root_child0.SetPosition(CSSEdge.Start, 10f); + root_child0.SetPosition(CSSEdge.Top, 10f); + root_child0.SetPosition(CSSEdge.End, 10f); + root_child0.SetPosition(CSSEdge.Bottom, 10f); root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); } [Test] public void Test_absolute_layout_width_height_start_top_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10); - root_child0.SetPosition(CSSEdge.Top, 10); - root_child0.SetPosition(CSSEdge.End, 10); - root_child0.SetPosition(CSSEdge.Bottom, 10); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.SetPosition(CSSEdge.Start, 10f); + root_child0.SetPosition(CSSEdge.Top, 10f); + root_child0.SetPosition(CSSEdge.End, 10f); + root_child0.SetPosition(CSSEdge.Bottom, 10f); + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -219,125 +189,125 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.Overflow = CSSOverflow.Hidden; - root.StyleWidth = 50; - root.StyleHeight = 50; + root.StyleWidth = 50f; + root.StyleHeight = 50f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 0); - root_child0.SetPosition(CSSEdge.Top, 0); + root_child0.SetPosition(CSSEdge.Start, 0f); + root_child0.SetPosition(CSSEdge.Top, 0f); root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.StyleWidth = 100; - root_child0_child0.StyleHeight = 100; + root_child0_child0.StyleWidth = 100f; + root_child0_child0.StyleHeight = 100f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(50, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(100, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(50, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); - Assert.AreEqual(-50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(-50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(100, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0_child0.LayoutHeight); } [Test] public void Test_absolute_layout_within_border() { CSSNode root = new CSSNode(); - root.SetMargin(CSSEdge.Left, 10); - root.SetMargin(CSSEdge.Top, 10); - root.SetMargin(CSSEdge.Right, 10); - root.SetMargin(CSSEdge.Bottom, 10); - root.SetPadding(CSSEdge.Left, 10); - root.SetPadding(CSSEdge.Top, 10); - root.SetPadding(CSSEdge.Right, 10); - root.SetPadding(CSSEdge.Bottom, 10); - root.SetBorder(CSSEdge.Left, 10); - root.SetBorder(CSSEdge.Top, 10); - root.SetBorder(CSSEdge.Right, 10); - root.SetBorder(CSSEdge.Bottom, 10); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetMargin(CSSEdge.Left, 10f); + root.SetMargin(CSSEdge.Top, 10f); + root.SetMargin(CSSEdge.Right, 10f); + root.SetMargin(CSSEdge.Bottom, 10f); + root.SetPadding(CSSEdge.Left, 10f); + root.SetPadding(CSSEdge.Top, 10f); + root.SetPadding(CSSEdge.Right, 10f); + root.SetPadding(CSSEdge.Bottom, 10f); + root.SetBorder(CSSEdge.Left, 10f); + root.SetBorder(CSSEdge.Top, 10f); + root.SetBorder(CSSEdge.Right, 10f); + root.SetBorder(CSSEdge.Bottom, 10f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Left, 0); - root_child0.SetPosition(CSSEdge.Top, 0); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 50; + root_child0.SetPosition(CSSEdge.Left, 0f); + root_child0.SetPosition(CSSEdge.Top, 0f); + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.PositionType = CSSPositionType.Absolute; - root_child1.SetPosition(CSSEdge.Right, 0); - root_child1.SetPosition(CSSEdge.Bottom, 0); - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 50; + root_child1.SetPosition(CSSEdge.Right, 0f); + root_child1.SetPosition(CSSEdge.Bottom, 0f); + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 50f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(10, root.LayoutX); - Assert.AreEqual(10, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(10f, root.LayoutX); + Assert.AreEqual(10f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(40, root_child1.LayoutX); - Assert.AreEqual(40, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(40f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(10, root.LayoutX); - Assert.AreEqual(10, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(10f, root.LayoutX); + Assert.AreEqual(10f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(40, root_child1.LayoutX); - Assert.AreEqual(40, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(40f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs index 8542ca47..db761e6e 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs @@ -7,42 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html using System; using NUnit.Framework; @@ -57,98 +22,98 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 10; + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; - root_child2.StyleHeight = 10; + root_child2.StyleWidth = 50f; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50; - root_child3.StyleHeight = 10; + root_child3.StyleWidth = 50f; + root_child3.StyleHeight = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50; - root_child4.StyleHeight = 10; + root_child4.StyleWidth = 50f; + root_child4.StyleHeight = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(0, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(0f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(50, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(50f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(50, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(50f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(50, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(50f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); } [Test] @@ -157,98 +122,98 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.FlexEnd; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 10; + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; - root_child2.StyleHeight = 10; + root_child2.StyleWidth = 50f; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50; - root_child3.StyleHeight = 10; + root_child3.StyleWidth = 50f; + root_child3.StyleHeight = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50; - root_child4.StyleHeight = 10; + root_child4.StyleWidth = 50f; + root_child4.StyleHeight = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(0, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(0f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(50, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(50f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(50, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(50f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(50, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(50f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); } [Test] @@ -257,98 +222,98 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.Center; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 10; + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; - root_child2.StyleHeight = 10; + root_child2.StyleWidth = 50f; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50; - root_child3.StyleHeight = 10; + root_child3.StyleWidth = 50f; + root_child3.StyleHeight = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50; - root_child4.StyleHeight = 10; + root_child4.StyleWidth = 50f; + root_child4.StyleHeight = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(0, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(0f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(50, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(50f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); - Assert.AreEqual(50, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(10, root_child3.LayoutHeight); + Assert.AreEqual(50f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(10f, root_child3.LayoutHeight); - Assert.AreEqual(50, root_child4.LayoutX); - Assert.AreEqual(40, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(10, root_child4.LayoutHeight); + Assert.AreEqual(50f, root_child4.LayoutX); + Assert.AreEqual(40f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(10f, root_child4.LayoutHeight); } [Test] @@ -357,93 +322,93 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.Stretch; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; + root_child0.StyleWidth = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50; + root_child1.StyleWidth = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; + root_child2.StyleWidth = 50f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50; + root_child3.StyleWidth = 50f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50; + root_child4.StyleWidth = 50f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(0, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(0, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(0f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(0, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(0, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(0f, root_child3.LayoutHeight); - Assert.AreEqual(0, root_child4.LayoutX); - Assert.AreEqual(0, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(0, root_child4.LayoutHeight); + Assert.AreEqual(0f, root_child4.LayoutX); + Assert.AreEqual(0f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(0f, root_child4.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(0, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(50, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(0, root_child2.LayoutHeight); + Assert.AreEqual(50f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(0f, root_child2.LayoutHeight); - Assert.AreEqual(50, root_child3.LayoutX); - Assert.AreEqual(0, root_child3.LayoutY); - Assert.AreEqual(50, root_child3.LayoutWidth); - Assert.AreEqual(0, root_child3.LayoutHeight); + Assert.AreEqual(50f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(50f, root_child3.LayoutWidth); + Assert.AreEqual(0f, root_child3.LayoutHeight); - Assert.AreEqual(50, root_child4.LayoutX); - Assert.AreEqual(0, root_child4.LayoutY); - Assert.AreEqual(50, root_child4.LayoutWidth); - Assert.AreEqual(0, root_child4.LayoutHeight); + Assert.AreEqual(50f, root_child4.LayoutX); + Assert.AreEqual(0f, root_child4.LayoutY); + Assert.AreEqual(50f, root_child4.LayoutWidth); + Assert.AreEqual(0f, root_child4.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs index 852a497d..b3c9db2d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html using System; using NUnit.Framework; @@ -40,37 +21,37 @@ namespace Facebook.CSSLayout public void Test_align_items_stretch() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -78,38 +59,38 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.Center; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(45, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(45f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(45, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(45f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -117,38 +98,38 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexStart; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -156,38 +137,38 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexEnd; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs index 6d65e321..c84b5213 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html using System; using NUnit.Framework; @@ -40,117 +21,117 @@ namespace Facebook.CSSLayout public void Test_align_self_center() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.Center; - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(45, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(45f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(45, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(45f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_align_self_flex_end() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexEnd; - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_align_self_flex_start() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexStart; - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -158,39 +139,39 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexStart; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexEnd; - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs index e0c6a7f8..756344e0 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html using System; using NUnit.Framework; @@ -43,148 +21,148 @@ namespace Facebook.CSSLayout public void Test_border_no_size() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10); - root.SetBorder(CSSEdge.Top, 10); - root.SetBorder(CSSEdge.Right, 10); - root.SetBorder(CSSEdge.Bottom, 10); + root.SetBorder(CSSEdge.Left, 10f); + root.SetBorder(CSSEdge.Top, 10f); + root.SetBorder(CSSEdge.Right, 10f); + root.SetBorder(CSSEdge.Bottom, 10f); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(20, root.LayoutWidth); - Assert.AreEqual(20, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(20f, root.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(20, root.LayoutWidth); - Assert.AreEqual(20, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(20f, root.LayoutHeight); } [Test] public void Test_border_container_match_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10); - root.SetBorder(CSSEdge.Top, 10); - root.SetBorder(CSSEdge.Right, 10); - root.SetBorder(CSSEdge.Bottom, 10); + root.SetBorder(CSSEdge.Left, 10f); + root.SetBorder(CSSEdge.Top, 10f); + root.SetBorder(CSSEdge.Right, 10f); + root.SetBorder(CSSEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_border_flex_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10); - root.SetBorder(CSSEdge.Top, 10); - root.SetBorder(CSSEdge.Right, 10); - root.SetBorder(CSSEdge.Bottom, 10); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetBorder(CSSEdge.Left, 10f); + root.SetBorder(CSSEdge.Top, 10f); + root.SetBorder(CSSEdge.Right, 10f); + root.SetBorder(CSSEdge.Bottom, 10f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.StyleWidth = 10; + root_child0.FlexGrow = 1f; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); } [Test] public void Test_border_stretch_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10); - root.SetBorder(CSSEdge.Top, 10); - root.SetBorder(CSSEdge.Right, 10); - root.SetBorder(CSSEdge.Bottom, 10); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetBorder(CSSEdge.Left, 10f); + root.SetBorder(CSSEdge.Top, 10f); + root.SetBorder(CSSEdge.Right, 10f); + root.SetBorder(CSSEdge.Bottom, 10f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -193,41 +171,41 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; root.AlignItems = CSSAlign.Center; - root.SetBorder(CSSEdge.Start, 10); - root.SetBorder(CSSEdge.End, 20); - root.SetBorder(CSSEdge.Bottom, 20); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetBorder(CSSEdge.Start, 10f); + root.SetBorder(CSSEdge.End, 20f); + root.SetBorder(CSSEdge.Bottom, 20f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(40, root_child0.LayoutX); - Assert.AreEqual(35, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(35f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(35, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(35f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs index 024641d6..a35c5810 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs @@ -7,46 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html using System; using NUnit.Framework; @@ -60,64 +21,64 @@ namespace Facebook.CSSLayout public void Test_flex_direction_column_no_height() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; + root.StyleWidth = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -125,129 +86,129 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleHeight = 100; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(20, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(20f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(20, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); } [Test] public void Test_flex_direction_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(20, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(20f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -255,65 +216,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(20, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(20f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(80, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(80f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(70, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(70f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); } [Test] @@ -321,65 +282,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.ColumnReverse; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(90, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(80, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(80f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(70, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(70f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(90, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(80, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(80f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(70, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(70f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -387,65 +348,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.RowReverse; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(80, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(80f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(70, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(70f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); - Assert.AreEqual(20, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(100, root_child2.LayoutHeight); + Assert.AreEqual(20f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs index 54c3e398..d6afed25 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs @@ -7,48 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html using System; using NUnit.Framework; @@ -62,52 +21,52 @@ namespace Facebook.CSSLayout public void Test_flex_basis_flex_grow_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50; + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(75, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(75f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(75, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(25, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(75f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(75, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(75f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(75, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(25, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(75f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); } [Test] @@ -115,104 +74,104 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50; + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(75, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(75f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(75, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(25, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(75f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(25f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(25, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(75, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(25f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(75f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(25, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(25f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); } [Test] public void Test_flex_basis_flex_shrink_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100; + root_child0.FlexShrink = 1f; + root_child0.FlexBasis = 100f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexBasis = 50; + root_child1.FlexBasis = 50f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); } [Test] @@ -220,240 +179,240 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexShrink = 1; - root_child0.FlexBasis = 100; + root_child0.FlexShrink = 1f; + root_child0.FlexBasis = 100f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexBasis = 50; + root_child1.FlexBasis = 50f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); } [Test] public void Test_flex_shrink_to_zero() { CSSNode root = new CSSNode(); - root.StyleHeight = 75; + root.StyleHeight = 75f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 50; + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexShrink = 1; - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 50; + root_child1.FlexShrink = 1f; + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; - root_child2.StyleHeight = 50; + root_child2.StyleWidth = 50f; + root_child2.StyleHeight = 50f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(75, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(75f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(50, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(50, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(50f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(50f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(75, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(75f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(50, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(50, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(50f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(50f, root_child2.LayoutHeight); } [Test] public void Test_flex_basis_overrides_main_size() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.FlexBasis = 50; - root_child0.StyleHeight = 20; + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; - root_child1.StyleHeight = 10; + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.FlexGrow = 1; - root_child2.StyleHeight = 10; + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(60, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(60f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(20, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(20f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(60, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(60f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(100, root_child2.LayoutWidth); - Assert.AreEqual(20, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(20f, root_child2.LayoutHeight); } [Test] public void Test_flex_grow_shrink_at_most() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.FlexGrow = 1; - root_child0_child0.FlexShrink = 1; + root_child0_child0.FlexGrow = 1f; + root_child0_child0.FlexShrink = 1f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(0, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(0, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(0, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(0, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs index a22d2676..db476d02 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs @@ -7,38 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html using System; using NUnit.Framework; @@ -53,82 +22,82 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.Wrap = CSSWrap.Wrap; - root.StyleHeight = 100; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30; - root_child0.StyleHeight = 30; + root_child0.StyleWidth = 30f; + root_child0.StyleHeight = 30f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30; - root_child1.StyleHeight = 30; + root_child1.StyleWidth = 30f; + root_child1.StyleHeight = 30f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30; - root_child2.StyleHeight = 30; + root_child2.StyleWidth = 30f; + root_child2.StyleHeight = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30; - root_child3.StyleHeight = 30; + root_child3.StyleWidth = 30f; + root_child3.StyleHeight = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(60, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(60f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(30, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(30f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(30, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(30, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(60, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(60f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(30, root_child3.LayoutX); - Assert.AreEqual(0, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(30f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(60, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(60f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(30, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(30, root_child0.LayoutHeight); + Assert.AreEqual(30f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(30f, root_child0.LayoutHeight); - Assert.AreEqual(30, root_child1.LayoutX); - Assert.AreEqual(30, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(30, root_child1.LayoutHeight); + Assert.AreEqual(30f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); - Assert.AreEqual(30, root_child2.LayoutX); - Assert.AreEqual(60, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(30f, root_child2.LayoutX); + Assert.AreEqual(60f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(0, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); } [Test] @@ -137,82 +106,82 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; + root.StyleWidth = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30; - root_child0.StyleHeight = 30; + root_child0.StyleWidth = 30f; + root_child0.StyleHeight = 30f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30; - root_child1.StyleHeight = 30; + root_child1.StyleWidth = 30f; + root_child1.StyleHeight = 30f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30; - root_child2.StyleHeight = 30; + root_child2.StyleWidth = 30f; + root_child2.StyleHeight = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30; - root_child3.StyleHeight = 30; + root_child3.StyleWidth = 30f; + root_child3.StyleHeight = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(30, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(30f, root_child0.LayoutHeight); - Assert.AreEqual(30, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(30, root_child1.LayoutHeight); + Assert.AreEqual(30f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); - Assert.AreEqual(60, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(60f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(70, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(30, root_child0.LayoutHeight); + Assert.AreEqual(70f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(30f, root_child0.LayoutHeight); - Assert.AreEqual(40, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(30, root_child1.LayoutHeight); + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); - Assert.AreEqual(10, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(10f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(70, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(70f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); } [Test] @@ -222,82 +191,82 @@ namespace Facebook.CSSLayout root.FlexDirection = CSSFlexDirection.Row; root.AlignItems = CSSAlign.FlexEnd; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; + root.StyleWidth = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 30f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30; - root_child1.StyleHeight = 20; + root_child1.StyleWidth = 30f; + root_child1.StyleHeight = 20f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30; - root_child2.StyleHeight = 30; + root_child2.StyleWidth = 30f; + root_child2.StyleHeight = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30; - root_child3.StyleHeight = 30; + root_child3.StyleWidth = 30f; + root_child3.StyleHeight = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(20, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(30, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(30f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(60, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(60f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(70, root_child0.LayoutX); - Assert.AreEqual(20, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(70f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(40, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(10, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(10f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(70, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(70f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); } [Test] @@ -307,82 +276,82 @@ namespace Facebook.CSSLayout root.FlexDirection = CSSFlexDirection.Row; root.AlignItems = CSSAlign.Center; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100; + root.StyleWidth = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 30f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30; - root_child1.StyleHeight = 20; + root_child1.StyleWidth = 30f; + root_child1.StyleHeight = 20f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30; - root_child2.StyleHeight = 30; + root_child2.StyleWidth = 30f; + root_child2.StyleHeight = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30; - root_child3.StyleHeight = 30; + root_child3.StyleWidth = 30f; + root_child3.StyleHeight = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(30, root_child1.LayoutX); - Assert.AreEqual(5, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(30f, root_child1.LayoutX); + Assert.AreEqual(5f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(60, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(60f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(0, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(0f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(60, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(60f, root.LayoutHeight); - Assert.AreEqual(70, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(30, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(70f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(30f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(40, root_child1.LayoutX); - Assert.AreEqual(5, root_child1.LayoutY); - Assert.AreEqual(30, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(40f, root_child1.LayoutX); + Assert.AreEqual(5f, root_child1.LayoutY); + Assert.AreEqual(30f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); - Assert.AreEqual(10, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(30, root_child2.LayoutWidth); - Assert.AreEqual(30, root_child2.LayoutHeight); + Assert.AreEqual(10f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(30f, root_child2.LayoutWidth); + Assert.AreEqual(30f, root_child2.LayoutHeight); - Assert.AreEqual(70, root_child3.LayoutX); - Assert.AreEqual(30, root_child3.LayoutY); - Assert.AreEqual(30, root_child3.LayoutWidth); - Assert.AreEqual(30, root_child3.LayoutHeight); + Assert.AreEqual(70f, root_child3.LayoutX); + Assert.AreEqual(30f, root_child3.LayoutY); + Assert.AreEqual(30f, root_child3.LayoutWidth); + Assert.AreEqual(30f, root_child3.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs index 7055c3a5..87a90240 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs @@ -7,70 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html using System; using NUnit.Framework; @@ -85,65 +22,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(20, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(20f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(92, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(92f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(82, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(82f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(72, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(72f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); } [Test] @@ -152,65 +89,65 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(72, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(72f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(82, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(82f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(92, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(92f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(20, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(10, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); } [Test] @@ -219,65 +156,65 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(36, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(36f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(56, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(56f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(56, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(56f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(36, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(36f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); } [Test] @@ -286,65 +223,65 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.SpaceBetween; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(92, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(92f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(92, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(92f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); } [Test] @@ -353,129 +290,129 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.SpaceAround; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10; + root_child1.StyleWidth = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10; + root_child2.StyleWidth = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(12, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(12f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(80, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(80f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(102, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(102f, root_child0.LayoutHeight); - Assert.AreEqual(46, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(10, root_child1.LayoutWidth); - Assert.AreEqual(102, root_child1.LayoutHeight); + Assert.AreEqual(46f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(10f, root_child1.LayoutWidth); + Assert.AreEqual(102f, root_child1.LayoutHeight); - Assert.AreEqual(12, root_child2.LayoutX); - Assert.AreEqual(0, root_child2.LayoutY); - Assert.AreEqual(10, root_child2.LayoutWidth); - Assert.AreEqual(102, root_child2.LayoutHeight); + Assert.AreEqual(12f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(10f, root_child2.LayoutWidth); + Assert.AreEqual(102f, root_child2.LayoutHeight); } [Test] public void Test_justify_content_column_flex_start() { CSSNode root = new CSSNode(); - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(10, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(10f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(10, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(0, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(10, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(10f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -483,65 +420,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(72, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(72f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(82, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(82f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(92, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(92f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(72, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(72f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(82, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(82f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(92, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(92f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -549,65 +486,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(36, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(36f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(56, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(56f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(36, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(36f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(56, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(56f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -615,65 +552,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.SpaceBetween; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(92, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(92f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(92, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(92f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } [Test] @@ -681,65 +618,65 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.SpaceAround; - root.StyleWidth = 102; - root.StyleHeight = 102; + root.StyleWidth = 102f; + root.StyleHeight = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10; + root_child1.StyleHeight = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10; + root_child2.StyleHeight = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(12, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(12f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(102, root.LayoutWidth); - Assert.AreEqual(102, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(12, root_child0.LayoutY); - Assert.AreEqual(102, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(12f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(46, root_child1.LayoutY); - Assert.AreEqual(102, root_child1.LayoutWidth); - Assert.AreEqual(10, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(102, root_child2.LayoutWidth); - Assert.AreEqual(10, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs index 7501c59d..0d5e1bee 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs @@ -7,52 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html using System; using NUnit.Framework; @@ -67,76 +22,76 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Start, 10); - root_child0.StyleWidth = 10; + root_child0.SetMargin(CSSEdge.Start, 10f); + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); } [Test] public void Test_margin_top() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Top, 10); - root_child0.StyleHeight = 10; + root_child0.SetMargin(CSSEdge.Top, 10f); + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -145,38 +100,38 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.End, 10); - root_child0.StyleWidth = 10; + root_child0.SetMargin(CSSEdge.End, 10f); + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); } [Test] @@ -184,38 +139,38 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Bottom, 10); - root_child0.StyleHeight = 10; + root_child0.SetMargin(CSSEdge.Bottom, 10f); + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(80, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(80, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -223,76 +178,76 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.SetMargin(CSSEdge.Start, 10); + root_child0.FlexGrow = 1f; + root_child0.SetMargin(CSSEdge.Start, 10f); root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(90, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(90f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(90, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(90f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); } [Test] public void Test_margin_and_flex_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.SetMargin(CSSEdge.Top, 10); + root_child0.FlexGrow = 1f; + root_child0.SetMargin(CSSEdge.Top, 10f); root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(90, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(90, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); } [Test] @@ -300,76 +255,76 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.SetMargin(CSSEdge.Top, 10); + root_child0.FlexGrow = 1f; + root_child0.SetMargin(CSSEdge.Top, 10f); root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(90, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(90, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); } [Test] public void Test_margin_and_stretch_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.SetMargin(CSSEdge.Start, 10); + root_child0.FlexGrow = 1f; + root_child0.SetMargin(CSSEdge.Start, 10f); root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(90, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(90f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(90, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(90f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); } [Test] @@ -377,102 +332,102 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; + root_child0.FlexGrow = 1f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(50, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); } [Test] public void Test_margin_with_sibling_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; + root_child0.FlexGrow = 1f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(50, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index 69d8996f..4d3d1c13 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -7,54 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html using System; using NUnit.Framework; @@ -68,38 +21,38 @@ namespace Facebook.CSSLayout public void Test_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleMaxWidth = 50; - root_child0.StyleHeight = 10; + root_child0.StyleMaxWidth = 50f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -107,90 +60,90 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleMaxHeight = 50; + root_child0.StyleWidth = 10f; + root_child0.StyleMaxHeight = 50f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(90, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); } [Test] public void Test_min_height() { CSSNode root = new CSSNode(); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.StyleMinHeight = 60; + root_child0.FlexGrow = 1f; + root_child0.StyleMinHeight = 60f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(80, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(80f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(80, root_child1.LayoutY); - Assert.AreEqual(100, root_child1.LayoutWidth); - Assert.AreEqual(20, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(80f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); } [Test] @@ -198,52 +151,52 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100; - root.StyleHeight = 100; + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.StyleMinWidth = 60; + root_child0.FlexGrow = 1f; + root_child0.StyleMinWidth = 60f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.FlexGrow = 1; + root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(80, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(20, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(80f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(20f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(20, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(100, root_child0.LayoutHeight); + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(0, root_child1.LayoutY); - Assert.AreEqual(20, root_child1.LayoutWidth); - Assert.AreEqual(100, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(20f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); } [Test] @@ -251,39 +204,39 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 100; - root.StyleMinHeight = 100; - root.StyleMaxHeight = 200; + root.StyleWidth = 100f; + root.StyleMinHeight = 100f; + root.StyleMaxHeight = 200f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 60; - root_child0.StyleHeight = 60; + root_child0.StyleWidth = 60f; + root_child0.StyleHeight = 60f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(20, root_child0.LayoutY); - Assert.AreEqual(60, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(40, root_child0.LayoutX); - Assert.AreEqual(20, root_child0.LayoutY); - Assert.AreEqual(60, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); } [Test] @@ -291,39 +244,39 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.Center; - root.StyleMinWidth = 100; - root.StyleMaxWidth = 200; - root.StyleHeight = 100; + root.StyleMinWidth = 100f; + root.StyleMaxWidth = 200f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 60; - root_child0.StyleHeight = 60; + root_child0.StyleWidth = 60f; + root_child0.StyleHeight = 60f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(20, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(60, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(20, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(60, root_child0.LayoutWidth); - Assert.AreEqual(60, root_child0.LayoutHeight); + Assert.AreEqual(20f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); } [Test] @@ -331,174 +284,174 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleMinHeight = 100; - root.StyleMaxHeight = 110; + root.StyleMinHeight = 100f; + root.StyleMaxHeight = 110f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50; - root_child0.StyleHeight = 50; + root_child0.StyleWidth = 50f; + root_child0.StyleHeight = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50; - root_child1.StyleHeight = 50; + root_child1.StyleWidth = 50f; + root_child1.StyleHeight = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50; - root_child2.StyleHeight = 50; + root_child2.StyleWidth = 50f; + root_child2.StyleHeight = 50f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(110, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(110f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(-20, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(-20f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(30, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(50, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(50f, root_child2.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(50, root.LayoutWidth); - Assert.AreEqual(110, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(50f, root.LayoutWidth); + Assert.AreEqual(110f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(-20, root_child0.LayoutY); - Assert.AreEqual(50, root_child0.LayoutWidth); - Assert.AreEqual(50, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(-20f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child1.LayoutX); - Assert.AreEqual(30, root_child1.LayoutY); - Assert.AreEqual(50, root_child1.LayoutWidth); - Assert.AreEqual(50, root_child1.LayoutHeight); + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); - Assert.AreEqual(0, root_child2.LayoutX); - Assert.AreEqual(80, root_child2.LayoutY); - Assert.AreEqual(50, root_child2.LayoutWidth); - Assert.AreEqual(50, root_child2.LayoutHeight); + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(80f, root_child2.LayoutY); + Assert.AreEqual(50f, root_child2.LayoutWidth); + Assert.AreEqual(50f, root_child2.LayoutHeight); } [Test] public void Test_flex_grow_within_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 200; - root.StyleHeight = 100; + root.StyleWidth = 200f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexDirection = CSSFlexDirection.Row; - root_child0.StyleMaxWidth = 100; + root_child0.StyleMaxWidth = 100f; root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.FlexGrow = 1; - root_child0_child0.StyleHeight = 20; + root_child0_child0.FlexGrow = 1f; + root_child0_child0.StyleHeight = 20f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(200, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(20, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(20, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(200, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(100, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(100, root_child0.LayoutWidth); - Assert.AreEqual(20, root_child0.LayoutHeight); + Assert.AreEqual(100f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(100, root_child0_child0.LayoutWidth); - Assert.AreEqual(20, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(100f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); } [Test] public void Test_flex_grow_within_constrained_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 200; - root.StyleHeight = 100; + root.StyleWidth = 200f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexDirection = CSSFlexDirection.Row; - root_child0.StyleMaxWidth = 300; + root_child0.StyleMaxWidth = 300f; root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.FlexGrow = 1; - root_child0_child0.StyleHeight = 20; + root_child0_child0.FlexGrow = 1f; + root_child0_child0.StyleHeight = 20f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(200, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(200, root_child0.LayoutWidth); - Assert.AreEqual(20, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(20, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(200f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(200, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(0, root_child0.LayoutX); - Assert.AreEqual(0, root_child0.LayoutY); - Assert.AreEqual(200, root_child0.LayoutWidth); - Assert.AreEqual(20, root_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); - Assert.AreEqual(0, root_child0_child0.LayoutX); - Assert.AreEqual(0, root_child0_child0.LayoutY); - Assert.AreEqual(200, root_child0_child0.LayoutWidth); - Assert.AreEqual(20, root_child0_child0.LayoutHeight); + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(200f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs index 576cacec..6d95bb17 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html using System; using NUnit.Framework; @@ -43,148 +21,148 @@ namespace Facebook.CSSLayout public void Test_padding_no_size() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10); - root.SetPadding(CSSEdge.Top, 10); - root.SetPadding(CSSEdge.Right, 10); - root.SetPadding(CSSEdge.Bottom, 10); + root.SetPadding(CSSEdge.Left, 10f); + root.SetPadding(CSSEdge.Top, 10f); + root.SetPadding(CSSEdge.Right, 10f); + root.SetPadding(CSSEdge.Bottom, 10f); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(20, root.LayoutWidth); - Assert.AreEqual(20, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(20f, root.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(20, root.LayoutWidth); - Assert.AreEqual(20, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(20f, root.LayoutHeight); } [Test] public void Test_padding_container_match_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10); - root.SetPadding(CSSEdge.Top, 10); - root.SetPadding(CSSEdge.Right, 10); - root.SetPadding(CSSEdge.Bottom, 10); + root.SetPadding(CSSEdge.Left, 10f); + root.SetPadding(CSSEdge.Top, 10f); + root.SetPadding(CSSEdge.Right, 10f); + root.SetPadding(CSSEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(30, root.LayoutWidth); - Assert.AreEqual(30, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(30f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] public void Test_padding_flex_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10); - root.SetPadding(CSSEdge.Top, 10); - root.SetPadding(CSSEdge.Right, 10); - root.SetPadding(CSSEdge.Bottom, 10); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetPadding(CSSEdge.Left, 10f); + root.SetPadding(CSSEdge.Top, 10f); + root.SetPadding(CSSEdge.Right, 10f); + root.SetPadding(CSSEdge.Bottom, 10f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexGrow = 1; - root_child0.StyleWidth = 10; + root_child0.FlexGrow = 1f; + root_child0.StyleWidth = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(80, root_child0.LayoutHeight); + Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(80f, root_child0.LayoutHeight); } [Test] public void Test_padding_stretch_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10); - root.SetPadding(CSSEdge.Top, 10); - root.SetPadding(CSSEdge.Right, 10); - root.SetPadding(CSSEdge.Bottom, 10); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetPadding(CSSEdge.Left, 10f); + root.SetPadding(CSSEdge.Top, 10f); + root.SetPadding(CSSEdge.Right, 10f); + root.SetPadding(CSSEdge.Bottom, 10f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10, root_child0.LayoutX); - Assert.AreEqual(10, root_child0.LayoutY); - Assert.AreEqual(80, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } [Test] @@ -193,41 +171,41 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; root.AlignItems = CSSAlign.Center; - root.SetPadding(CSSEdge.Start, 10); - root.SetPadding(CSSEdge.End, 20); - root.SetPadding(CSSEdge.Bottom, 20); - root.StyleWidth = 100; - root.StyleHeight = 100; + root.SetPadding(CSSEdge.Start, 10f); + root.SetPadding(CSSEdge.End, 20f); + root.SetPadding(CSSEdge.Bottom, 20f); + root.StyleWidth = 100f; + root.StyleHeight = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10; - root_child0.StyleHeight = 10; + root_child0.StyleWidth = 10f; + root_child0.StyleHeight = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(40, root_child0.LayoutX); - Assert.AreEqual(35, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(35f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); root.StyleDirection = CSSDirection.RTL; root.CalculateLayout(); - Assert.AreEqual(0, root.LayoutX); - Assert.AreEqual(0, root.LayoutY); - Assert.AreEqual(100, root.LayoutWidth); - Assert.AreEqual(100, root.LayoutHeight); + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50, root_child0.LayoutX); - Assert.AreEqual(35, root_child0.LayoutY); - Assert.AreEqual(10, root_child0.LayoutWidth); - Assert.AreEqual(10, root_child0.LayoutHeight); + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(35f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs new file mode 100644 index 00000000..5f1e2a12 --- /dev/null +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs @@ -0,0 +1,807 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html + +using System; +using NUnit.Framework; + +namespace Facebook.CSSLayout +{ + [TestFixture] + public class CSSLayoutRoundingTest + { + [Test] + public void Test_rounding_flex_basis_flex_grow_row_width_of_100() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.FlexDirection = CSSFlexDirection.Row; + root.StyleWidth = 100f; + root.StyleHeight = 100f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(33f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(33f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(34f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(67f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(33f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(67f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(33f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(33f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(34f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(33f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_flex_basis_flex_grow_row_prime_number_width() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.FlexDirection = CSSFlexDirection.Row; + root.StyleWidth = 113f; + root.StyleHeight = 100f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root.Insert(2, root_child2); + + CSSNode root_child3 = new CSSNode(); + root_child3.FlexGrow = 1f; + root.Insert(3, root_child3); + + CSSNode root_child4 = new CSSNode(); + root_child4.FlexGrow = 1f; + root.Insert(4, root_child4); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(113f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(23f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(23f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(22f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(45f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(23f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + Assert.AreEqual(68f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(22f, root_child3.LayoutWidth); + Assert.AreEqual(100f, root_child3.LayoutHeight); + + Assert.AreEqual(90f, root_child4.LayoutX); + Assert.AreEqual(0f, root_child4.LayoutY); + Assert.AreEqual(23f, root_child4.LayoutWidth); + Assert.AreEqual(100f, root_child4.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(113f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(23f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(68f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(22f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(45f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(23f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + Assert.AreEqual(23f, root_child3.LayoutX); + Assert.AreEqual(0f, root_child3.LayoutY); + Assert.AreEqual(22f, root_child3.LayoutWidth); + Assert.AreEqual(100f, root_child3.LayoutHeight); + + Assert.AreEqual(0f, root_child4.LayoutX); + Assert.AreEqual(0f, root_child4.LayoutY); + Assert.AreEqual(23f, root_child4.LayoutWidth); + Assert.AreEqual(100f, root_child4.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_flex_basis_flex_shrink_row() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.FlexDirection = CSSFlexDirection.Row; + root.StyleWidth = 101f; + root.StyleHeight = 100f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexShrink = 1f; + root_child0.FlexBasis = 100f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexBasis = 25f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexBasis = 25f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(101f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(51f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(51f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(25f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(76f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(25f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(101f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(51f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(25f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(25f, root_child1.LayoutWidth); + Assert.AreEqual(100f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(25f, root_child2.LayoutWidth); + Assert.AreEqual(100f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_flex_basis_overrides_main_size() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.StyleWidth = 100f; + root.StyleHeight = 113f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_total_fractial() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.StyleWidth = 87.4f; + root.StyleHeight = 113.4f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 0.7f; + root_child0.FlexBasis = 50.3f; + root_child0.StyleHeight = 20.3f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1.6f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1.1f; + root_child2.StyleHeight = 10.7f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(87f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(87f, root_child0.LayoutWidth); + Assert.AreEqual(59f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(59f, root_child1.LayoutY); + Assert.AreEqual(87f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(87f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(87f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(87f, root_child0.LayoutWidth); + Assert.AreEqual(59f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(59f, root_child1.LayoutY); + Assert.AreEqual(87f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(87f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_total_fractial_nested() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.StyleWidth = 87.4f; + root.StyleHeight = 113.4f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 0.7f; + root_child0.FlexBasis = 50.3f; + root_child0.StyleHeight = 20.3f; + root.Insert(0, root_child0); + + CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.FlexGrow = 1f; + root_child0_child0.FlexBasis = 0.3f; + root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f); + root_child0_child0.StyleHeight = 9.9f; + root_child0.Insert(0, root_child0_child0); + + CSSNode root_child0_child1 = new CSSNode(); + root_child0_child1.FlexGrow = 4f; + root_child0_child1.FlexBasis = 0.3f; + root_child0_child1.SetPosition(CSSEdge.Top, 13.3f); + root_child0_child1.StyleHeight = 1.1f; + root_child0.Insert(1, root_child0_child1); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1.6f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1.1f; + root_child2.StyleHeight = 10.7f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(87f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(87f, root_child0.LayoutWidth); + Assert.AreEqual(59f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(-13f, root_child0_child0.LayoutY); + Assert.AreEqual(87f, root_child0_child0.LayoutWidth); + Assert.AreEqual(12f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child1.LayoutX); + Assert.AreEqual(25f, root_child0_child1.LayoutY); + Assert.AreEqual(87f, root_child0_child1.LayoutWidth); + Assert.AreEqual(47f, root_child0_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(59f, root_child1.LayoutY); + Assert.AreEqual(87f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(87f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(87f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(87f, root_child0.LayoutWidth); + Assert.AreEqual(59f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(-13f, root_child0_child0.LayoutY); + Assert.AreEqual(87f, root_child0_child0.LayoutWidth); + Assert.AreEqual(12f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child1.LayoutX); + Assert.AreEqual(25f, root_child0_child1.LayoutY); + Assert.AreEqual(87f, root_child0_child1.LayoutWidth); + Assert.AreEqual(47f, root_child0_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(59f, root_child1.LayoutY); + Assert.AreEqual(87f, root_child1.LayoutWidth); + Assert.AreEqual(30f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(87f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_fractial_input_1() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.StyleWidth = 100f; + root.StyleHeight = 113.4f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_fractial_input_2() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.StyleWidth = 100f; + root.StyleHeight = 113.6f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(114f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(65f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(65f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(24f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(25f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(114f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(65f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(65f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(24f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(25f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_fractial_input_3() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.SetPosition(CSSEdge.Top, 0.3f); + root.StyleWidth = 100f; + root.StyleHeight = 113.4f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(114f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(114f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + [Test] + public void Test_rounding_fractial_input_4() + { + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + + CSSNode root = new CSSNode(); + root.SetPosition(CSSEdge.Top, 0.7f); + root.StyleWidth = 100f; + root.StyleHeight = 113.4f; + + CSSNode root_child0 = new CSSNode(); + root_child0.FlexGrow = 1f; + root_child0.FlexBasis = 50f; + root_child0.StyleHeight = 20f; + root.Insert(0, root_child0); + + CSSNode root_child1 = new CSSNode(); + root_child1.FlexGrow = 1f; + root_child1.StyleHeight = 10f; + root.Insert(1, root_child1); + + CSSNode root_child2 = new CSSNode(); + root_child2.FlexGrow = 1f; + root_child2.StyleHeight = 10f; + root.Insert(2, root_child2); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(1f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(1f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(113f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(64f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(64f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(25f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(89f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(24f, root_child2.LayoutHeight); + + CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + } + + } +} diff --git a/gentest/fixtures/CSSLayoutRoundingTest.html b/gentest/fixtures/CSSLayoutRoundingTest.html new file mode 100644 index 00000000..c66e6b16 --- /dev/null +++ b/gentest/fixtures/CSSLayoutRoundingTest.html @@ -0,0 +1,64 @@ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 2a5e8d24..fe655a7c 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -26,20 +26,35 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { ]); }}, - emitTestPrologue:{value:function(name) { + emitTestPrologue:{value:function(name, experiments) { this.push('TEST(CSSLayoutTest, ' + name + ') {'); this.pushIndent(); + + if (experiments.length > 0) { + for (var i in experiments) { + this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', true);'); + } + this.push(''); + } }}, emitTestTreePrologue:{value:function(nodeName) { this.push('const CSSNodeRef ' + nodeName + ' = CSSNodeNew();'); }}, - emitTestEpilogue:{value:function() { + emitTestEpilogue:{value:function(experiments) { this.push([ '', 'CSSNodeFreeRecursive(root);', ]); + + if (experiments.length > 0) { + this.push(''); + for (var i in experiments) { + this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', false);'); + } + } + this.popIndent(); this.push([ '}', @@ -130,7 +145,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + value + ');'); + this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, CSSNodeStyleSetDirection:{value:function(nodeName, value) { diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index f96d557f..a50774bb 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -31,18 +31,32 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { this.pushIndent(); }}, - emitTestPrologue:{value:function(name) { + emitTestPrologue:{value:function(name, experiments) { this.push('[Test]'); this.push('public void Test_' + name + '()'); this.push('{'); this.pushIndent(); + + if (experiments.length > 0) { + for (var i in experiments) { + this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', true);'); + } + this.push(''); + } }}, emitTestTreePrologue:{value:function(nodeName) { this.push('CSSNode ' + nodeName + ' = new CSSNode();'); }}, - emitTestEpilogue:{value:function() { + emitTestEpilogue:{value:function(experiments) { + if (experiments.length > 0) { + this.push(''); + for (var i in experiments) { + this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', false);'); + } + } + this.popIndent(); this.push([ '}', @@ -61,7 +75,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, AssertEQ:{value:function(v0, v1) { - this.push('Assert.AreEqual(' + v0 + ', ' + v1 + ');'); + this.push('Assert.AreEqual(' + v0 + 'f, ' + v1 + ');'); }}, CSSAlignAuto:{value:'CSSAlign.Auto'}, @@ -141,7 +155,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetBorder(' + edge + ', ' + value + ');'); + this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetDirection:{value:function(nodeName, value) { @@ -149,7 +163,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push(nodeName + '.FlexBasis = ' + value + ';'); + this.push(nodeName + '.FlexBasis = ' + value + 'f;'); }}, CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -157,11 +171,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push(nodeName + '.FlexGrow = ' + value + ';'); + this.push(nodeName + '.FlexGrow = ' + value + 'f;'); }}, CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push(nodeName + '.FlexShrink = ' + value + ';'); + this.push(nodeName + '.FlexShrink = ' + value + 'f;'); }}, CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { @@ -169,7 +183,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleHeight = ' + value + ';'); + this.push(nodeName + '.StyleHeight = ' + value + 'f;'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -177,23 +191,23 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetMargin(' + edge + ', ' + value + ');'); + this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMaxHeight = ' + value + ';'); + this.push(nodeName + '.StyleMaxHeight = ' + value + 'f;'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMaxWidth = ' + value + ';'); + this.push(nodeName + '.StyleMaxWidth = ' + value + 'f;'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMinHeight = ' + value + ';'); + this.push(nodeName + '.StyleMinHeight = ' + value + 'f;'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMinWidth = ' + value + ';'); + this.push(nodeName + '.StyleMinWidth = ' + value + 'f;'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -201,11 +215,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPadding(' + edge + ', ' + value + ');'); + this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPosition(' + edge + ', ' + value + ');'); + this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -213,6 +227,6 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleWidth = ' + value + ';'); + this.push(nodeName + '.StyleWidth = ' + value + 'f;'); }}, }); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 853bf658..793c964d 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -11,6 +11,18 @@ var JavaEmitter = function() { Emitter.call(this, 'java', ' '); }; +function toJavaUpper(symbol) { + var out = ''; + for (var i = 0; i < symbol.length; i++) { + var c = symbol[i]; + if (c == c.toUpperCase() && i != 0 && symbol[i - 1] != symbol[i - 1].toUpperCase()) { + out += '_'; + } + out += c.toUpperCase(); + } + return out; +} + JavaEmitter.prototype = Object.create(Emitter.prototype, { constructor:{value:JavaEmitter}, @@ -27,17 +39,31 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { this.pushIndent(); }}, - emitTestPrologue:{value:function(name) { + emitTestPrologue:{value:function(name, experiments) { this.push('@Test'); this.push('public void test_' + name + '() {'); this.pushIndent(); + + if (experiments.length > 0) { + for (var i in experiments) { + this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); + } + this.push(''); + } }}, emitTestTreePrologue:{value:function(nodeName) { this.push('final CSSNode ' + nodeName + ' = new CSSNode();'); }}, - emitTestEpilogue:{value:function() { + emitTestEpilogue:{value:function(experiments) { + if (experiments.length > 0) { + this.push(''); + for (var i in experiments) { + this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); + } + } + this.popIndent(); this.push([ '}', @@ -54,7 +80,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, AssertEQ:{value:function(v0, v1) { - this.push('assertEquals(' + v0 + ', ' + v1 + ', 0.0f);'); + this.push('assertEquals(' + v0 + 'f, ' + v1 + ', 0.0f);'); }}, CSSAlignAuto:{value:'CSSAlign.AUTO'}, @@ -134,7 +160,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setBorder(' + edge + ', ' + value + ');'); + this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetDirection:{value:function(nodeName, value) { @@ -142,7 +168,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexBasis(' + value + ');'); + this.push(nodeName + '.setFlexBasis(' + value + 'f);'); }}, CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { @@ -150,11 +176,11 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexGrow(' + value + ');'); + this.push(nodeName + '.setFlexGrow(' + value + 'f);'); }}, CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { - this.push(nodeName + '.setFlexShrink(' + value + ');'); + this.push(nodeName + '.setFlexShrink(' + value + 'f);'); }}, CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { @@ -162,7 +188,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleHeight(' + value + ');'); + this.push(nodeName + '.setStyleHeight(' + value + 'f);'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -170,23 +196,23 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setMargin(' + edge + ', ' + value + ');'); + this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMaxHeight(' + value + ');'); + this.push(nodeName + '.setStyleMaxHeight(' + value + 'f);'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMaxWidth(' + value + ');'); + this.push(nodeName + '.setStyleMaxWidth(' + value + 'f);'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMinHeight(' + value + ');'); + this.push(nodeName + '.setStyleMinHeight(' + value + 'f);'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMinWidth(' + value + ');'); + this.push(nodeName + '.setStyleMinWidth(' + value + 'f);'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -198,7 +224,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.setPosition(' + edge + ', ' + value + ');'); + this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);'); }}, CSSNodeStyleSetPositionType:{value:function(nodeName, value) { @@ -206,6 +232,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleWidth(' + value + ');'); + this.push(nodeName + '.setStyleWidth(' + value + 'f);'); }}, }); diff --git a/gentest/gentest.js b/gentest/gentest.js index 26204c35..02f44609 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -46,36 +46,7 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) { ' * of patent rights can be found in the PATENTS file in the same directory.', ' */', '', - '/**', - ' * @Generated by gentest/gentest.sh with the following input', - ' *', - ]); - - var indentation = 0; - e.push(genericContainer.innerHTML.split('\n').map(function(line) { - return line.trim(); - }).filter(function(line) { - return line.length > 0 && line !== '
'; - }).map(function(line) { - var result; - if (line.indexOf('{"browser"=>"ALL", "performance"=>"ALL"}) + "loggingPrefs"=>{ + "browser"=>"ALL", + "performance"=>"ALL" + } +) browser = Watir::Browser.new(:chrome, :desired_capabilities => caps) Dir.chdir(File.dirname($0)) + Dir['fixtures/*.html'].each do |file| fixture = File.read(file) name = File.basename(file, '.*') @@ -22,7 +29,7 @@ Dir['fixtures/*.html'].each do |file| template = File.open('test-template.html').read f = File.open('test.html', 'w') - f.write sprintf(template, ltr_fixture, rtl_fixture, fixture) + f.write sprintf(template, name, ltr_fixture, rtl_fixture, fixture) f.close FileUtils.copy('test.html', "#{name}.html") if $DEBUG diff --git a/gentest/test-template.html b/gentest/test-template.html index 9e0364c3..0b4102f7 100644 --- a/gentest/test-template.html +++ b/gentest/test-template.html @@ -2,7 +2,7 @@ - test page + %s diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index e4ced9fc..f7fd50cb 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -7,37 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html package com.facebook.csslayout; @@ -49,163 +19,163 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10); - root_child0.setPosition(Spacing.TOP, 10); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setPosition(Spacing.START, 10f); + root_child0.setPosition(Spacing.TOP, 10f); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_absolute_layout_width_height_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.END, 10); - root_child0.setPosition(Spacing.BOTTOM, 10); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setPosition(Spacing.END, 10f); + root_child0.setPosition(Spacing.BOTTOM, 10f); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(80, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(80, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_absolute_layout_start_top_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10); - root_child0.setPosition(Spacing.TOP, 10); - root_child0.setPosition(Spacing.END, 10); - root_child0.setPosition(Spacing.BOTTOM, 10); + root_child0.setPosition(Spacing.START, 10f); + root_child0.setPosition(Spacing.TOP, 10f); + root_child0.setPosition(Spacing.END, 10f); + root_child0.setPosition(Spacing.BOTTOM, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_absolute_layout_width_height_start_top_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10); - root_child0.setPosition(Spacing.TOP, 10); - root_child0.setPosition(Spacing.END, 10); - root_child0.setPosition(Spacing.BOTTOM, 10); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setPosition(Spacing.START, 10f); + root_child0.setPosition(Spacing.TOP, 10f); + root_child0.setPosition(Spacing.END, 10f); + root_child0.setPosition(Spacing.BOTTOM, 10f); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -213,124 +183,124 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setOverflow(CSSOverflow.HIDDEN); - root.setStyleWidth(50); - root.setStyleHeight(50); + root.setStyleWidth(50f); + root.setStyleHeight(50f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 0); - root_child0.setPosition(Spacing.TOP, 0); + root_child0.setPosition(Spacing.START, 0f); + root_child0.setPosition(Spacing.TOP, 0f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setStyleWidth(100); - root_child0_child0.setStyleHeight(100); + root_child0_child0.setStyleWidth(100f); + root_child0_child0.setStyleHeight(100f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(50, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(50, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); - assertEquals(-50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(-50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); } @Test public void test_absolute_layout_within_border() { final CSSNode root = new CSSNode(); - root.setMargin(Spacing.LEFT, 10); - root.setMargin(Spacing.TOP, 10); - root.setMargin(Spacing.RIGHT, 10); - root.setMargin(Spacing.BOTTOM, 10); + root.setMargin(Spacing.LEFT, 10f); + root.setMargin(Spacing.TOP, 10f); + root.setMargin(Spacing.RIGHT, 10f); + root.setMargin(Spacing.BOTTOM, 10f); root.setPadding(Spacing.LEFT, 10); root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.BOTTOM, 10); - root.setBorder(Spacing.LEFT, 10); - root.setBorder(Spacing.TOP, 10); - root.setBorder(Spacing.RIGHT, 10); - root.setBorder(Spacing.BOTTOM, 10); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setBorder(Spacing.LEFT, 10f); + root.setBorder(Spacing.TOP, 10f); + root.setBorder(Spacing.RIGHT, 10f); + root.setBorder(Spacing.BOTTOM, 10f); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.LEFT, 0); - root_child0.setPosition(Spacing.TOP, 0); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(50); + root_child0.setPosition(Spacing.LEFT, 0f); + root_child0.setPosition(Spacing.TOP, 0f); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setPositionType(CSSPositionType.ABSOLUTE); - root_child1.setPosition(Spacing.RIGHT, 0); - root_child1.setPosition(Spacing.BOTTOM, 0); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(50); + root_child1.setPosition(Spacing.RIGHT, 0f); + root_child1.setPosition(Spacing.BOTTOM, 0f); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(10, root.getLayoutX(), 0.0f); - assertEquals(10, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(10f, root.getLayoutX(), 0.0f); + assertEquals(10f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(40, root_child1.getLayoutX(), 0.0f); - assertEquals(40, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(10, root.getLayoutX(), 0.0f); - assertEquals(10, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(10f, root.getLayoutX(), 0.0f); + assertEquals(10f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(40, root_child1.getLayoutX(), 0.0f); - assertEquals(40, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java index c8ae2f98..e48d4ee3 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java @@ -7,42 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html package com.facebook.csslayout; @@ -55,98 +20,98 @@ public class CSSLayoutAlignContentTest { public void test_align_content_flex_start() { final CSSNode root = new CSSNode(); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(10); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); - root_child2.setStyleHeight(10); + root_child2.setStyleWidth(50f); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50); - root_child3.setStyleHeight(10); + root_child3.setStyleWidth(50f); + root_child3.setStyleHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50); - root_child4.setStyleHeight(10); + root_child4.setStyleWidth(50f); + root_child4.setStyleHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(0, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(50, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(50, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(50, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); } @Test @@ -154,98 +119,98 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.FLEX_END); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(10); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); - root_child2.setStyleHeight(10); + root_child2.setStyleWidth(50f); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50); - root_child3.setStyleHeight(10); + root_child3.setStyleWidth(50f); + root_child3.setStyleHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50); - root_child4.setStyleHeight(10); + root_child4.setStyleWidth(50f); + root_child4.setStyleHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(0, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(50, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(50, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(50, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); } @Test @@ -253,98 +218,98 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.CENTER); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(10); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); - root_child2.setStyleHeight(10); + root_child2.setStyleWidth(50f); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50); - root_child3.setStyleHeight(10); + root_child3.setStyleWidth(50f); + root_child3.setStyleHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50); - root_child4.setStyleHeight(10); + root_child4.setStyleWidth(50f); + root_child4.setStyleHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(0, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(50, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(50, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(10, root_child3.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(50, root_child4.getLayoutX(), 0.0f); - assertEquals(40, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(10, root_child4.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); } @Test @@ -352,93 +317,93 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.STRETCH); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); + root_child0.setStyleWidth(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50); + root_child1.setStyleWidth(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); + root_child2.setStyleWidth(50f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50); + root_child3.setStyleWidth(50f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50); + root_child4.setStyleWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(0, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(0, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(0, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(0, root_child4.getLayoutX(), 0.0f); - assertEquals(0, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(0, root_child4.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(50, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(0, root_child2.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(50, root_child3.getLayoutX(), 0.0f); - assertEquals(0, root_child3.getLayoutY(), 0.0f); - assertEquals(50, root_child3.getLayoutWidth(), 0.0f); - assertEquals(0, root_child3.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); - assertEquals(50, root_child4.getLayoutX(), 0.0f); - assertEquals(0, root_child4.getLayoutY(), 0.0f); - assertEquals(50, root_child4.getLayoutWidth(), 0.0f); - assertEquals(0, root_child4.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java index 49689901..cca9b555 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html package com.facebook.csslayout; @@ -38,151 +19,151 @@ public class CSSLayoutAlignItemsTest { @Test public void test_align_items_stretch() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_items_center() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.CENTER); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(45, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(45, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_items_flex_start() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_START); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_items_flex_end() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_END); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java index 999972de..d6236541 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html package com.facebook.csslayout; @@ -38,154 +19,154 @@ public class CSSLayoutAlignSelfTest { @Test public void test_align_self_center() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.CENTER); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(45, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(45, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_self_flex_end() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_END); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_self_flex_start() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_START); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_self_flex_end_override_flex_start() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_START); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_END); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java index ee7505e4..f382f73b 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html package com.facebook.csslayout; @@ -41,145 +19,145 @@ public class CSSLayoutBorderTest { @Test public void test_border_no_size() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10); - root.setBorder(Spacing.TOP, 10); - root.setBorder(Spacing.RIGHT, 10); - root.setBorder(Spacing.BOTTOM, 10); + root.setBorder(Spacing.LEFT, 10f); + root.setBorder(Spacing.TOP, 10f); + root.setBorder(Spacing.RIGHT, 10f); + root.setBorder(Spacing.BOTTOM, 10f); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(20, root.getLayoutWidth(), 0.0f); - assertEquals(20, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(20f, root.getLayoutWidth(), 0.0f); + assertEquals(20f, root.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(20, root.getLayoutWidth(), 0.0f); - assertEquals(20, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(20f, root.getLayoutWidth(), 0.0f); + assertEquals(20f, root.getLayoutHeight(), 0.0f); } @Test public void test_border_container_match_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10); - root.setBorder(Spacing.TOP, 10); - root.setBorder(Spacing.RIGHT, 10); - root.setBorder(Spacing.BOTTOM, 10); + root.setBorder(Spacing.LEFT, 10f); + root.setBorder(Spacing.TOP, 10f); + root.setBorder(Spacing.RIGHT, 10f); + root.setBorder(Spacing.BOTTOM, 10f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_border_flex_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10); - root.setBorder(Spacing.TOP, 10); - root.setBorder(Spacing.RIGHT, 10); - root.setBorder(Spacing.BOTTOM, 10); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setBorder(Spacing.LEFT, 10f); + root.setBorder(Spacing.TOP, 10f); + root.setBorder(Spacing.RIGHT, 10f); + root.setBorder(Spacing.BOTTOM, 10f); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setStyleWidth(10); + root_child0.setFlexGrow(1f); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_border_stretch_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10); - root.setBorder(Spacing.TOP, 10); - root.setBorder(Spacing.RIGHT, 10); - root.setBorder(Spacing.BOTTOM, 10); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setBorder(Spacing.LEFT, 10f); + root.setBorder(Spacing.TOP, 10f); + root.setBorder(Spacing.RIGHT, 10f); + root.setBorder(Spacing.BOTTOM, 10f); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -187,41 +165,41 @@ public class CSSLayoutBorderTest { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); root.setAlignItems(CSSAlign.CENTER); - root.setBorder(Spacing.START, 10); - root.setBorder(Spacing.END, 20); - root.setBorder(Spacing.BOTTOM, 20); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setBorder(Spacing.START, 10f); + root.setBorder(Spacing.END, 20f); + root.setBorder(Spacing.BOTTOM, 20f); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(40, root_child0.getLayoutX(), 0.0f); - assertEquals(35, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(35f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(35, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(35f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java index 7d741b7c..75b1fe70 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java @@ -7,46 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html package com.facebook.csslayout; @@ -58,387 +19,387 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_column_no_height() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); + root.setStyleWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_direction_row_no_width() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleHeight(100); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(20, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(20, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_direction_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(20, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_direction_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(20, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(80, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(70, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_direction_column_reverse() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(90, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(80, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(70, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(70f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(90, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(80, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(70, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(70f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_direction_row_reverse() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW_REVERSE); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(80, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(70, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(20, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(100, root_child2.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java index ccc641c6..f675cbbf 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java @@ -7,48 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html package com.facebook.csslayout; @@ -60,392 +19,392 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_flex_grow_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(75, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(75, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(25, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(75f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(75, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(75, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(25, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(75f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_flex_basis_flex_grow_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(75, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(75f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(75, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(25, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(75f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(25, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(75, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(25f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(75f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(25, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_flex_basis_flex_shrink_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); + root_child0.setFlexShrink(1f); + root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexBasis(50); + root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_flex_basis_flex_shrink_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexShrink(1); - root_child0.setFlexBasis(100); + root_child0.setFlexShrink(1f); + root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexBasis(50); + root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_flex_shrink_to_zero() { final CSSNode root = new CSSNode(); - root.setStyleHeight(75); + root.setStyleHeight(75f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(50); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexShrink(1); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(50); + root_child1.setFlexShrink(1f); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); - root_child2.setStyleHeight(50); + root_child2.setStyleWidth(50f); + root_child2.setStyleHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(75, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(75f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(50, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(50, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(75, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(75f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(50, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(50, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_basis_overrides_main_size() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setFlexBasis(50); - root_child0.setStyleHeight(20); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); - root_child1.setStyleHeight(10); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setFlexGrow(1); - root_child2.setStyleHeight(10); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(60, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(20, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(60, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(100, root_child2.getLayoutWidth(), 0.0f); - assertEquals(20, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_grow_shrink_at_most() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexGrow(1f); + root_child0_child0.setFlexShrink(1f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java index bd4b506d..71ba2541 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java @@ -7,38 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html package com.facebook.csslayout; @@ -51,82 +20,82 @@ public class CSSLayoutFlexWrapTest { public void test_wrap_column() { final CSSNode root = new CSSNode(); root.setWrap(CSSWrap.WRAP); - root.setStyleHeight(100); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30); - root_child0.setStyleHeight(30); + root_child0.setStyleWidth(30f); + root_child0.setStyleHeight(30f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30); - root_child1.setStyleHeight(30); + root_child1.setStyleWidth(30f); + root_child1.setStyleHeight(30f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30); - root_child2.setStyleHeight(30); + root_child2.setStyleWidth(30f); + root_child2.setStyleHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30); - root_child3.setStyleHeight(30); + root_child3.setStyleWidth(30f); + root_child3.setStyleHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(60, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(30, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(30, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(30, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(60, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(60f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(30, root_child3.getLayoutX(), 0.0f); - assertEquals(0, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(60, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(30, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(30, root_child0.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(30, root_child1.getLayoutX(), 0.0f); - assertEquals(30, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(30, root_child1.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(30, root_child2.getLayoutX(), 0.0f); - assertEquals(60, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(60f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(0, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); } @Test @@ -134,82 +103,82 @@ public class CSSLayoutFlexWrapTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); + root.setStyleWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30); - root_child0.setStyleHeight(30); + root_child0.setStyleWidth(30f); + root_child0.setStyleHeight(30f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30); - root_child1.setStyleHeight(30); + root_child1.setStyleWidth(30f); + root_child1.setStyleHeight(30f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30); - root_child2.setStyleHeight(30); + root_child2.setStyleWidth(30f); + root_child2.setStyleHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30); - root_child3.setStyleHeight(30); + root_child3.setStyleWidth(30f); + root_child3.setStyleHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(30, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(30, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(30, root_child1.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(60, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(70, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(30, root_child0.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(40, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(30, root_child1.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(10, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(70, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); } @Test @@ -218,82 +187,82 @@ public class CSSLayoutFlexWrapTest { root.setFlexDirection(CSSFlexDirection.ROW); root.setAlignItems(CSSAlign.FLEX_END); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); + root.setStyleWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(30f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30); - root_child1.setStyleHeight(20); + root_child1.setStyleWidth(30f); + root_child1.setStyleHeight(20f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30); - root_child2.setStyleHeight(30); + root_child2.setStyleWidth(30f); + root_child2.setStyleHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30); - root_child3.setStyleHeight(30); + root_child3.setStyleWidth(30f); + root_child3.setStyleHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(20, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(30, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(60, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(70, root_child0.getLayoutX(), 0.0f); - assertEquals(20, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(40, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(10, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(70, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); } @Test @@ -302,82 +271,82 @@ public class CSSLayoutFlexWrapTest { root.setFlexDirection(CSSFlexDirection.ROW); root.setAlignItems(CSSAlign.CENTER); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100); + root.setStyleWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(30f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30); - root_child1.setStyleHeight(20); + root_child1.setStyleWidth(30f); + root_child1.setStyleHeight(20f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30); - root_child2.setStyleHeight(30); + root_child2.setStyleWidth(30f); + root_child2.setStyleHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30); - root_child3.setStyleHeight(30); + root_child3.setStyleWidth(30f); + root_child3.setStyleHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(30, root_child1.getLayoutX(), 0.0f); - assertEquals(5, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(5f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(60, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(0, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(60, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); - assertEquals(70, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(30, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(40, root_child1.getLayoutX(), 0.0f); - assertEquals(5, root_child1.getLayoutY(), 0.0f); - assertEquals(30, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(5f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(10, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(30, root_child2.getLayoutWidth(), 0.0f); - assertEquals(30, root_child2.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); - assertEquals(70, root_child3.getLayoutX(), 0.0f); - assertEquals(30, root_child3.getLayoutY(), 0.0f); - assertEquals(30, root_child3.getLayoutWidth(), 0.0f); - assertEquals(30, root_child3.getLayoutHeight(), 0.0f); + assertEquals(70f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java index cef3690a..1c7488de 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java @@ -7,70 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html package com.facebook.csslayout; @@ -83,65 +20,65 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_row_flex_start() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(20, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(92, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(92f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(82, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(82f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(72, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(72f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); } @Test @@ -149,65 +86,65 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(72, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(72f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(82, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(82f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(92, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(92f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(20, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(10, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); } @Test @@ -215,65 +152,65 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(36, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(36f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(56, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(56, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(56f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(36, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(36f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); } @Test @@ -281,65 +218,65 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.SPACE_BETWEEN); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(92, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(92f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(92, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(92f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); } @Test @@ -347,388 +284,388 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.SPACE_AROUND); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10); + root_child1.setStyleWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10); + root_child2.setStyleWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(12, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(12f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(80, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(102, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(46, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(10, root_child1.getLayoutWidth(), 0.0f); - assertEquals(102, root_child1.getLayoutHeight(), 0.0f); + assertEquals(46f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(12, root_child2.getLayoutX(), 0.0f); - assertEquals(0, root_child2.getLayoutY(), 0.0f); - assertEquals(10, root_child2.getLayoutWidth(), 0.0f); - assertEquals(102, root_child2.getLayoutHeight(), 0.0f); + assertEquals(12f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_column_flex_start() { final CSSNode root = new CSSNode(); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(10, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(10, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(10, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_column_flex_end() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(72, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(72f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(82, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(82f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(92, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(92f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(72, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(72f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(82, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(82f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(92, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(92f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_column_center() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(36, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(36f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(56, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(56f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(36, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(36f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(56, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(56f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_column_space_between() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.SPACE_BETWEEN); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(92, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(92f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(92, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(92f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_column_space_around() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.SPACE_AROUND); - root.setStyleWidth(102); - root.setStyleHeight(102); + root.setStyleWidth(102f); + root.setStyleHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10); + root_child1.setStyleHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10); + root_child2.setStyleHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(12, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(102, root.getLayoutWidth(), 0.0f); - assertEquals(102, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(12, root_child0.getLayoutY(), 0.0f); - assertEquals(102, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(46, root_child1.getLayoutY(), 0.0f); - assertEquals(102, root_child1.getLayoutWidth(), 0.0f); - assertEquals(10, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(102, root_child2.getLayoutWidth(), 0.0f); - assertEquals(10, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java index f85ce54d..94f0f0ad 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java @@ -7,52 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html package com.facebook.csslayout; @@ -65,75 +20,75 @@ public class CSSLayoutMarginTest { public void test_margin_start() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.START, 10); - root_child0.setStyleWidth(10); + root_child0.setMargin(Spacing.START, 10f); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_top() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.TOP, 10); - root_child0.setStyleHeight(10); + root_child0.setMargin(Spacing.TOP, 10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -141,327 +96,327 @@ public class CSSLayoutMarginTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.END, 10); - root_child0.setStyleWidth(10); + root_child0.setMargin(Spacing.END, 10f); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_bottom() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.BOTTOM, 10); - root_child0.setStyleHeight(10); + root_child0.setMargin(Spacing.BOTTOM, 10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(80, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(80, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_and_flex_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setMargin(Spacing.START, 10); + root_child0.setFlexGrow(1f); + root_child0.setMargin(Spacing.START, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(90, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(90, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_and_flex_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setMargin(Spacing.TOP, 10); + root_child0.setFlexGrow(1f); + root_child0.setMargin(Spacing.TOP, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(90, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(90, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_and_stretch_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setMargin(Spacing.TOP, 10); + root_child0.setFlexGrow(1f); + root_child0.setMargin(Spacing.TOP, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(90, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(90, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_and_stretch_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setMargin(Spacing.START, 10); + root_child0.setFlexGrow(1f); + root_child0.setMargin(Spacing.START, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(90, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(90, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_margin_with_sibling_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); + root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(50, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_margin_with_sibling_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); + root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(50, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index d513f5e4..24ff93ab 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -7,54 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html package com.facebook.csslayout; @@ -66,429 +19,429 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleMaxWidth(50); - root_child0.setStyleHeight(10); + root_child0.setStyleMaxWidth(50f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_max_height() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleMaxHeight(50); + root_child0.setStyleWidth(10f); + root_child0.setStyleMaxHeight(50f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(90, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_min_height() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setStyleMinHeight(60); + root_child0.setFlexGrow(1f); + root_child0.setStyleMinHeight(60f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(80, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(80, root_child1.getLayoutY(), 0.0f); - assertEquals(100, root_child1.getLayoutWidth(), 0.0f); - assertEquals(20, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_min_width() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setStyleMinWidth(60); + root_child0.setFlexGrow(1f); + root_child0.setStyleMinWidth(60f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setFlexGrow(1); + root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(80, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(20, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(20, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(100, root_child0.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(0, root_child1.getLayoutY(), 0.0f); - assertEquals(20, root_child1.getLayoutWidth(), 0.0f); - assertEquals(100, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_min_max() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(100); - root.setStyleMinHeight(100); - root.setStyleMaxHeight(200); + root.setStyleWidth(100f); + root.setStyleMinHeight(100f); + root.setStyleMaxHeight(200f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(60); - root_child0.setStyleHeight(60); + root_child0.setStyleWidth(60f); + root_child0.setStyleHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(20, root_child0.getLayoutY(), 0.0f); - assertEquals(60, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(40, root_child0.getLayoutX(), 0.0f); - assertEquals(20, root_child0.getLayoutY(), 0.0f); - assertEquals(60, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_align_items_min_max() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.CENTER); - root.setStyleMinWidth(100); - root.setStyleMaxWidth(200); - root.setStyleHeight(100); + root.setStyleMinWidth(100f); + root.setStyleMaxWidth(200f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(60); - root_child0.setStyleHeight(60); + root_child0.setStyleWidth(60f); + root_child0.setStyleHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(20, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(60, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(20, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(60, root_child0.getLayoutWidth(), 0.0f); - assertEquals(60, root_child0.getLayoutHeight(), 0.0f); + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); } @Test public void test_justify_content_overflow_min_max() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleMinHeight(100); - root.setStyleMaxHeight(110); + root.setStyleMinHeight(100f); + root.setStyleMaxHeight(110f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50); - root_child0.setStyleHeight(50); + root_child0.setStyleWidth(50f); + root_child0.setStyleHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50); - root_child1.setStyleHeight(50); + root_child1.setStyleWidth(50f); + root_child1.setStyleHeight(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50); - root_child2.setStyleHeight(50); + root_child2.setStyleWidth(50f); + root_child2.setStyleHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(110, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(-20, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(30, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(50, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(50, root.getLayoutWidth(), 0.0f); - assertEquals(110, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(-20, root_child0.getLayoutY(), 0.0f); - assertEquals(50, root_child0.getLayoutWidth(), 0.0f); - assertEquals(50, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child1.getLayoutX(), 0.0f); - assertEquals(30, root_child1.getLayoutY(), 0.0f); - assertEquals(50, root_child1.getLayoutWidth(), 0.0f); - assertEquals(50, root_child1.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - assertEquals(0, root_child2.getLayoutX(), 0.0f); - assertEquals(80, root_child2.getLayoutY(), 0.0f); - assertEquals(50, root_child2.getLayoutWidth(), 0.0f); - assertEquals(50, root_child2.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); } @Test public void test_flex_grow_within_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(200); - root.setStyleHeight(100); + root.setStyleWidth(200f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexDirection(CSSFlexDirection.ROW); - root_child0.setStyleMaxWidth(100); + root_child0.setStyleMaxWidth(100f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setStyleHeight(20); + root_child0_child0.setFlexGrow(1f); + root_child0_child0.setStyleHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(200, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(200, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(100, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); } @Test public void test_flex_grow_within_constrained_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(200); - root.setStyleHeight(100); + root.setStyleWidth(200f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexDirection(CSSFlexDirection.ROW); - root_child0.setStyleMaxWidth(300); + root_child0.setStyleMaxWidth(300f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setStyleHeight(20); + root_child0_child0.setFlexGrow(1f); + root_child0_child0.setStyleHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(200, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(200, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java index e8bd8671..41750c20 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html package com.facebook.csslayout; @@ -48,18 +26,18 @@ public class CSSLayoutPaddingTest { root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(20, root.getLayoutWidth(), 0.0f); - assertEquals(20, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(20f, root.getLayoutWidth(), 0.0f); + assertEquals(20f, root.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(20, root.getLayoutWidth(), 0.0f); - assertEquals(20, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(20f, root.getLayoutWidth(), 0.0f); + assertEquals(20f, root.getLayoutHeight(), 0.0f); } @Test @@ -71,34 +49,34 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.BOTTOM, 10); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(30, root.getLayoutWidth(), 0.0f); - assertEquals(30, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(30f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -108,38 +86,38 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.BOTTOM, 10); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexGrow(1); - root_child0.setStyleWidth(10); + root_child0.setFlexGrow(1f); + root_child0.setStyleWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(80, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(80, root_child0.getLayoutHeight(), 0.0f); + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -149,37 +127,37 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.BOTTOM, 10); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(10, root_child0.getLayoutX(), 0.0f); - assertEquals(10, root_child0.getLayoutY(), 0.0f); - assertEquals(80, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } @Test @@ -190,38 +168,38 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.START, 10); root.setPadding(Spacing.END, 20); root.setPadding(Spacing.BOTTOM, 20); - root.setStyleWidth(100); - root.setStyleHeight(100); + root.setStyleWidth(100f); + root.setStyleHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10); - root_child0.setStyleHeight(10); + root_child0.setStyleWidth(10f); + root_child0.setStyleHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(40, root_child0.getLayoutX(), 0.0f); - assertEquals(35, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(35f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); root.calculateLayout(null); - assertEquals(0, root.getLayoutX(), 0.0f); - assertEquals(0, root.getLayoutY(), 0.0f); - assertEquals(100, root.getLayoutWidth(), 0.0f); - assertEquals(100, root.getLayoutHeight(), 0.0f); + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); - assertEquals(50, root_child0.getLayoutX(), 0.0f); - assertEquals(35, root_child0.getLayoutY(), 0.0f); - assertEquals(10, root_child0.getLayoutWidth(), 0.0f); - assertEquals(10, root_child0.getLayoutHeight(), 0.0f); + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(35f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java new file mode 100644 index 00000000..3ecec462 --- /dev/null +++ b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java @@ -0,0 +1,795 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html + +package com.facebook.csslayout; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class CSSLayoutRoundingTest { + @Test + public void test_rounding_flex_basis_flex_grow_row_width_of_100() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setFlexDirection(CSSFlexDirection.ROW); + root.setStyleWidth(100f); + root.setStyleHeight(100f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(33f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(33f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(34f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(67f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(67f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(33f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(33f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(34f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_flex_basis_flex_grow_row_prime_number_width() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setFlexDirection(CSSFlexDirection.ROW); + root.setStyleWidth(113f); + root.setStyleHeight(100f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root.addChildAt(root_child2, 2); + + final CSSNode root_child3 = new CSSNode(); + root_child3.setFlexGrow(1f); + root.addChildAt(root_child3, 3); + + final CSSNode root_child4 = new CSSNode(); + root_child4.setFlexGrow(1f); + root.addChildAt(root_child4, 4); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(113f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(23f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(23f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(22f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(45f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(23f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(68f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(22f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(113f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(23f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(68f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(22f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(45f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(23f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(23f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(22f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_flex_basis_flex_shrink_row() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setFlexDirection(CSSFlexDirection.ROW); + root.setStyleWidth(101f); + root.setStyleHeight(100f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexShrink(1f); + root_child0.setFlexBasis(100f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexBasis(25f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexBasis(25f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(101f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(51f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(51f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(76f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(101f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(51f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_flex_basis_overrides_main_size() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setStyleWidth(100f); + root.setStyleHeight(113f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_total_fractial() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setStyleWidth(87.4f); + root.setStyleHeight(113.4f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(0.7f); + root_child0.setFlexBasis(50.3f); + root_child0.setStyleHeight(20.3f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1.6f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1.1f); + root_child2.setStyleHeight(10.7f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(87f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(59f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(59f, root_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(87f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(59f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(59f, root_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_total_fractial_nested() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setStyleWidth(87.4f); + root.setStyleHeight(113.4f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(0.7f); + root_child0.setFlexBasis(50.3f); + root_child0.setStyleHeight(20.3f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child0_child0 = new CSSNode(); + root_child0_child0.setFlexGrow(1f); + root_child0_child0.setFlexBasis(0.3f); + root_child0_child0.setPosition(Spacing.BOTTOM, 13.3f); + root_child0_child0.setStyleHeight(9.9f); + root_child0.addChildAt(root_child0_child0, 0); + + final CSSNode root_child0_child1 = new CSSNode(); + root_child0_child1.setFlexGrow(4f); + root_child0_child1.setFlexBasis(0.3f); + root_child0_child1.setPosition(Spacing.TOP, 13.3f); + root_child0_child1.setStyleHeight(1.1f); + root_child0.addChildAt(root_child0_child1, 1); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1.6f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1.1f); + root_child2.setStyleHeight(10.7f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(87f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(59f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-13f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(12f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(25f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(47f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(59f, root_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(87f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(59f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-13f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(87f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(12f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(25f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(47f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(59f, root_child1.getLayoutY(), 0.0f); + assertEquals(87f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_fractial_input_1() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setStyleWidth(100f); + root.setStyleHeight(113.4f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_fractial_input_2() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setStyleWidth(100f); + root.setStyleHeight(113.6f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(114f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(65f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(65f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(114f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(65f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(65f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_fractial_input_3() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setPosition(Spacing.TOP, 0.3f); + root.setStyleWidth(100f); + root.setStyleHeight(113.4f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(114f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(114f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + + @Test + public void test_rounding_fractial_input_4() { + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + + final CSSNode root = new CSSNode(); + root.setPosition(Spacing.TOP, 0.7f); + root.setStyleWidth(100f); + root.setStyleHeight(113.4f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setFlexGrow(1f); + root_child0.setFlexBasis(50f); + root_child0.setStyleHeight(20f); + root.addChildAt(root_child0, 0); + + final CSSNode root_child1 = new CSSNode(); + root_child1.setFlexGrow(1f); + root_child1.setStyleHeight(10f); + root.addChildAt(root_child1, 1); + + final CSSNode root_child2 = new CSSNode(); + root_child2.setFlexGrow(1f); + root_child2.setStyleHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(1f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(null); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(1f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(64f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(64f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(89f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); + + CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + } + +} diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index 2692f05e..a0bedbe5 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -7,37 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html #include #include diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index 64523b8e..d3078098 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -7,42 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html #include #include diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index 0047dfc5..c72acc7a 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html #include #include diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index 28eee5bb..6e090730 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -7,26 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html #include #include diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index 7e818ba9..56dac071 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html #include #include diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index 14a1b181..9b319d0d 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -7,46 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html #include #include diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index a769e9e8..3ccef380 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -7,48 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html #include #include diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index a3a16d4e..ae5113c4 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -7,38 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html #include #include diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index 17e5e16a..6ac22334 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -7,70 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html #include #include diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index 75d87d7a..091ef4d0 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -7,52 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html #include #include diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index b5f162a9..aaf2710a 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -7,54 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
-
- -
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html #include #include diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index e802b890..808d8186 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -7,29 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/** - * @Generated by gentest/gentest.sh with the following input - * -
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html #include #include diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp index fa5226b4..ee4adb36 100644 --- a/tests/CSSLayoutRelayoutTest.cpp +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -10,19 +10,9 @@ #include #include -class CSSLayoutRelayoutTest : public ::testing::Test { +TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); -protected: - virtual void SetUp() { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); - } - - virtual void TearDown() { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false); - } -}; - -TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) { const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -36,4 +26,6 @@ TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) { ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false); } diff --git a/tests/CSSLayoutRoundingMeasureFuncTest.cpp b/tests/CSSLayoutRoundingMeasureFuncTest.cpp new file mode 100644 index 00000000..85acd10e --- /dev/null +++ b/tests/CSSLayoutRoundingMeasureFuncTest.cpp @@ -0,0 +1,73 @@ +/** + * 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 + +static CSSSize _measureFloor(CSSNodeRef node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + + return CSSSize{ + width = 10.2, + height = 10.2, + }; +} + +static CSSSize _measureCeil(CSSNodeRef node, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode) { + + return CSSSize{ + width = 10.5, + height = 10.5, + }; +} + +TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + + const CSSNodeRef root = CSSNodeNew(); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeSetMeasureFunc(root_child0, _measureFloor); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); +} + +TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + + const CSSNodeRef root = CSSNodeNew(); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeSetMeasureFunc(root_child0, _measureCeil); + CSSNodeInsertChild(root, root_child0, 0); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); +} diff --git a/tests/CSSLayoutPixelRoundingTest.cpp b/tests/CSSLayoutRoundingTest.cpp similarity index 81% rename from tests/CSSLayoutPixelRoundingTest.cpp rename to tests/CSSLayoutRoundingTest.cpp index 8fb3c73a..9991dbaa 100644 --- a/tests/CSSLayoutPixelRoundingTest.cpp +++ b/tests/CSSLayoutRoundingTest.cpp @@ -7,67 +7,14 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -/* -* -
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-
- * - */ + // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html #include #include -class CSSLayoutFeatureRoundingTest : public ::testing::Test { +TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); -protected: - virtual void SetUp() { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); - } - - virtual void TearDown() { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); - } -}; - -TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_width_of_100) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); @@ -129,9 +76,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_wid ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_prime_number_width) { +TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetWidth(root, 113); @@ -221,9 +172,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_pri ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child4)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_shrink_row) { +TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetWidth(root, 101); @@ -286,10 +241,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_shrink_row) ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } +TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); -TEST_F(CSSLayoutFeatureRoundingTest, pixel_roundingflex_basis_overrides_main_size) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 113); @@ -311,52 +269,232 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_roundingflex_basis_overrides_main_siz CSSNodeInsertChild(root, root_child2, 2); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(113, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); - ASSERT_EQ(113, CSSNodeLayoutGetHeight(root)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); - ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + 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_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + 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)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_1) { +TEST(CSSLayoutTest, rounding_total_fractial) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 87.4f); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child1, 1.6f); + CSSNodeStyleSetHeight(root_child1, 10); + CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); +} + +TEST(CSSLayoutTest, rounding_total_fractial_nested) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 87.4f); + CSSNodeStyleSetHeight(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 CSSNodeRef root_child0_child0 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child0_child0, 1); + CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f); + CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f); + CSSNodeStyleSetHeight(root_child0_child0, 9.9f); + CSSNodeInsertChild(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, CSSEdgeTop, 13.3f); + CSSNodeStyleSetHeight(root_child0_child1, 1.1f); + CSSNodeInsertChild(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 CSSNodeRef root_child2 = CSSNodeNew(); + CSSNodeStyleSetFlexGrow(root_child2, 1.1f); + CSSNodeStyleSetHeight(root_child2, 10.7f); + CSSNodeInsertChild(root, root_child2, 2); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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, 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, 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, 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, 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); +} + +TEST(CSSLayoutTest, rounding_fractial_input_1) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 113.4f); @@ -421,9 +559,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_1) { ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_2) { +TEST(CSSLayoutTest, rounding_fractial_input_2) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 113.6f); @@ -488,9 +630,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_2) { ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_3) { +TEST(CSSLayoutTest, rounding_fractial_input_3) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.3f); CSSNodeStyleSetWidth(root, 100); @@ -556,9 +702,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_3) { ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } -TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_4) { +TEST(CSSLayoutTest, rounding_fractial_input_4) { + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.7f); CSSNodeStyleSetWidth(root, 100); @@ -624,229 +774,6 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_4) { ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); CSSNodeFreeRecursive(root); -} - -TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 87.4f); - CSSNodeStyleSetHeight(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 CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child1, 1.6f); - CSSNodeStyleSetHeight(root_child1, 10); - CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - - 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, 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, 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, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - - CSSNodeFreeRecursive(root); -} - - -TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial_nested) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetWidth(root, 87.4f); - CSSNodeStyleSetHeight(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 CSSNodeRef root_child0_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child0, 1.2f); - CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f); - CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f); - CSSNodeStyleSetHeight(root_child0_child0, 9.9f); - CSSNodeInsertChild(root_child0, root_child0_child0, 0); - - const CSSNodeRef root_child0_child1 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child0_child1, 4.2f); - CSSNodeStyleSetFlexBasis(root_child0_child1, 0.3f); - CSSNodeStyleSetPosition(root_child0_child1, CSSEdgeTop, 13.3f); - CSSNodeStyleSetHeight(root_child0_child1, 1.1f); - CSSNodeInsertChild(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 CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetFlexGrow(root_child2, 1.1f); - CSSNodeStyleSetHeight(root_child2, 10.7f); - CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - 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, 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, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(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, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); - - 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, 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, CSSNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(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, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - - CSSNodeFreeRecursive(root); -} - - -static CSSSize _measureFloor(CSSNodeRef node, - float width, - CSSMeasureMode widthMode, - float height, - CSSMeasureMode heightMode) { - - return CSSSize{ - width = 10.2, - height = 10.2, - }; -} - -static CSSSize _measureCeil(CSSNodeRef node, - float width, - CSSMeasureMode widthMode, - float height, - CSSMeasureMode heightMode) { - - return CSSSize{ - width = 10.5, - height = 10.5, - }; -} - - -TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_floor) { - const CSSNodeRef root = CSSNodeNew(); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetMeasureFunc(root_child0, _measureFloor); - CSSNodeInsertChild(root, root_child0, 0); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - - CSSNodeFreeRecursive(root); -} - -TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_ceil) { - const CSSNodeRef root = CSSNodeNew(); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeSetMeasureFunc(root_child0, _measureCeil); - CSSNodeInsertChild(root, root_child0, 0); - - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); - - ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0)); - - CSSNodeFreeRecursive(root); + + CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); } From 0240d099490498325b48791d9525cc6a57e7751b Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Mon, 28 Nov 2016 09:18:12 -0800 Subject: [PATCH 076/108] Enable `-fPIC` for C library Summary: At least or x86_64 linux, it appears that you need position-independent code is required in order to link against it. Otherwise you see errors like this: ``` /usr/bin/ld: lib_sys.rlib(CSSLayout.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: lib_sys.rlib(CSSNodeList.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status ``` If I understand it correctly, you don't strictly need PIC for static libraries, but as soon as you want to link *other* dynamically linked library into it, it is required - which makes logical sense to me. Let me know if you want to enable this by default or leave it up to the developers to enable this if needed. Closes https://github.com/facebook/css-layout/pull/263 Reviewed By: passy Differential Revision: D4237009 Pulled By: emilsjolander fbshipit-source-id: e73ea0ea22520758ec958a031d6e2ca62fdcda15 --- BUCK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUCK b/BUCK index 7c7358ff..78dd806d 100644 --- a/BUCK +++ b/BUCK @@ -20,7 +20,7 @@ GMOCK_OVERRIDE_FLAGS = [ '-Wno-inconsistent-missing-override', ] -COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11'] +COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC'] TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11'] cxx_library( From c31df519e020a38cfb8d75797b4931c1395f23f0 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 28 Nov 2016 09:20:59 -0800 Subject: [PATCH 077/108] Dont strip class names referenced from native Summary: Ensure we don't strip classes used from native Reviewed By: lexs Differential Revision: D4237790 fbshipit-source-id: 1bd0780d965efbb8334917011ffd65896670ece1 --- enums.py | 2 ++ java/com/facebook/csslayout/CSSAlign.java | 3 +++ java/com/facebook/csslayout/CSSDimension.java | 3 +++ java/com/facebook/csslayout/CSSDirection.java | 3 +++ java/com/facebook/csslayout/CSSEdge.java | 3 +++ java/com/facebook/csslayout/CSSExperimentalFeature.java | 3 +++ java/com/facebook/csslayout/CSSFlexDirection.java | 3 +++ java/com/facebook/csslayout/CSSJustify.java | 3 +++ java/com/facebook/csslayout/CSSLogLevel.java | 3 +++ java/com/facebook/csslayout/CSSLogger.java | 1 + java/com/facebook/csslayout/CSSMeasureMode.java | 3 +++ java/com/facebook/csslayout/CSSNode.java | 1 + java/com/facebook/csslayout/CSSOverflow.java | 3 +++ java/com/facebook/csslayout/CSSPositionType.java | 3 +++ java/com/facebook/csslayout/CSSPrintOptions.java | 3 +++ java/com/facebook/csslayout/CSSWrap.java | 3 +++ 16 files changed, 43 insertions(+) diff --git a/enums.py b/enums.py index 5e361b9e..22e1b0ff 100644 --- a/enums.py +++ b/enums.py @@ -135,6 +135,8 @@ for name, values in ENUMS.items(): with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f: f.write(LICENSE) f.write('package com.facebook.csslayout;\n\n') + f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n') + f.write('@DoNotStrip\n') f.write('public enum %s {\n' % name) if len(values) > 0: for value in values: diff --git a/java/com/facebook/csslayout/CSSAlign.java b/java/com/facebook/csslayout/CSSAlign.java index 2dedee0b..4f4af8cb 100644 --- a/java/com/facebook/csslayout/CSSAlign.java +++ b/java/com/facebook/csslayout/CSSAlign.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSAlign { AUTO(0), FLEX_START(1), diff --git a/java/com/facebook/csslayout/CSSDimension.java b/java/com/facebook/csslayout/CSSDimension.java index e3fde021..77785ea6 100644 --- a/java/com/facebook/csslayout/CSSDimension.java +++ b/java/com/facebook/csslayout/CSSDimension.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSDimension { WIDTH(0), HEIGHT(1); diff --git a/java/com/facebook/csslayout/CSSDirection.java b/java/com/facebook/csslayout/CSSDirection.java index c0e84f1a..38916ea5 100644 --- a/java/com/facebook/csslayout/CSSDirection.java +++ b/java/com/facebook/csslayout/CSSDirection.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSDirection { INHERIT(0), LTR(1), diff --git a/java/com/facebook/csslayout/CSSEdge.java b/java/com/facebook/csslayout/CSSEdge.java index 50d184e3..8fe6a2fb 100644 --- a/java/com/facebook/csslayout/CSSEdge.java +++ b/java/com/facebook/csslayout/CSSEdge.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSEdge { LEFT(0), TOP(1), diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/CSSExperimentalFeature.java index d9476e81..3489e919 100644 --- a/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSExperimentalFeature { ROUNDING(0), WEB_FLEX_BASIS(1); diff --git a/java/com/facebook/csslayout/CSSFlexDirection.java b/java/com/facebook/csslayout/CSSFlexDirection.java index 10e5cd6a..3047516d 100644 --- a/java/com/facebook/csslayout/CSSFlexDirection.java +++ b/java/com/facebook/csslayout/CSSFlexDirection.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSFlexDirection { COLUMN(0), COLUMN_REVERSE(1), diff --git a/java/com/facebook/csslayout/CSSJustify.java b/java/com/facebook/csslayout/CSSJustify.java index 2d36a85f..2c9abc6b 100644 --- a/java/com/facebook/csslayout/CSSJustify.java +++ b/java/com/facebook/csslayout/CSSJustify.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSJustify { FLEX_START(0), CENTER(1), diff --git a/java/com/facebook/csslayout/CSSLogLevel.java b/java/com/facebook/csslayout/CSSLogLevel.java index 94551bc0..9d54b1eb 100644 --- a/java/com/facebook/csslayout/CSSLogLevel.java +++ b/java/com/facebook/csslayout/CSSLogLevel.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSLogLevel { ERROR(0), WARN(1), diff --git a/java/com/facebook/csslayout/CSSLogger.java b/java/com/facebook/csslayout/CSSLogger.java index f1f28fe2..d270e39f 100644 --- a/java/com/facebook/csslayout/CSSLogger.java +++ b/java/com/facebook/csslayout/CSSLogger.java @@ -15,6 +15,7 @@ import com.facebook.proguard.annotations.DoNotStrip; * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); * See CSSLogLevel for the different log levels. */ +@DoNotStrip public interface CSSLogger { @DoNotStrip void log(CSSLogLevel level, String message); diff --git a/java/com/facebook/csslayout/CSSMeasureMode.java b/java/com/facebook/csslayout/CSSMeasureMode.java index d2c69e6f..5b14c7dd 100644 --- a/java/com/facebook/csslayout/CSSMeasureMode.java +++ b/java/com/facebook/csslayout/CSSMeasureMode.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSMeasureMode { UNDEFINED(0), EXACTLY(1), diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index d1943e9c..309a4975 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.soloader.SoLoader; +@DoNotStrip public class CSSNode implements CSSNodeAPI { static { diff --git a/java/com/facebook/csslayout/CSSOverflow.java b/java/com/facebook/csslayout/CSSOverflow.java index 8ba708ae..df6bedd7 100644 --- a/java/com/facebook/csslayout/CSSOverflow.java +++ b/java/com/facebook/csslayout/CSSOverflow.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSOverflow { VISIBLE(0), HIDDEN(1), diff --git a/java/com/facebook/csslayout/CSSPositionType.java b/java/com/facebook/csslayout/CSSPositionType.java index 4dcaa0df..01eeece6 100644 --- a/java/com/facebook/csslayout/CSSPositionType.java +++ b/java/com/facebook/csslayout/CSSPositionType.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSPositionType { RELATIVE(0), ABSOLUTE(1); diff --git a/java/com/facebook/csslayout/CSSPrintOptions.java b/java/com/facebook/csslayout/CSSPrintOptions.java index ec83ab47..49cbc25e 100644 --- a/java/com/facebook/csslayout/CSSPrintOptions.java +++ b/java/com/facebook/csslayout/CSSPrintOptions.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSPrintOptions { LAYOUT(1), STYLE(2), diff --git a/java/com/facebook/csslayout/CSSWrap.java b/java/com/facebook/csslayout/CSSWrap.java index 69a59056..52a7aaf8 100644 --- a/java/com/facebook/csslayout/CSSWrap.java +++ b/java/com/facebook/csslayout/CSSWrap.java @@ -9,6 +9,9 @@ package com.facebook.csslayout; +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip public enum CSSWrap { NO_WRAP(0), WRAP(1); From 97d524fa9661bcfb44e19c113ed01fa2b5e21e5a Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 28 Nov 2016 15:45:57 -0800 Subject: [PATCH 078/108] Add notice in readme about ongoing API changes Summary: Add notice in readme to prepare open source for large renaming diffs. Reviewed By: splhack Differential Revision: D4240761 fbshipit-source-id: 4c8070a06c3ac009b67eb7bef5de11ce3ab3e4d8 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2b9c9f55..ea044d33 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # CSSLayout [![Build Status](https://travis-ci.org/facebook/css-layout.svg?branch=master)](https://travis-ci.org/facebook/css-layout) +## NOTICE +A lot is changing this week in the API regarding naming. We suggest you hold off updating to the latest version of the code until this notice is gone. Expect it to take about a week. + ## Goals CSSLayout is a cross-platform implementation of flexbox. The goal of CSSLayout is allow native developers to have the same expressive layout system as developers developing for the modern web are used to. CSSLayout allows developers for web, android, iOS, and windows to use the same layout primitives across platforms. This saves time, increases collaboration between platform teams, and makes it easier for developers to work on multiple platforms. From 631880147021ecce91e0ec3841ce0f1a19cf3b60 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 29 Nov 2016 04:28:23 -0800 Subject: [PATCH 079/108] Always use soloader. Catching exception and re-trying hides errors Summary: Soloader is safer than System load library, retrying with System load library just hides errors Reviewed By: lexs Differential Revision: D4243906 fbshipit-source-id: e4d691c9c49f3b9316f67e39b9f277657d78fb3c --- java/com/facebook/csslayout/CSSNode.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 309a4975..5250fd06 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -21,13 +21,7 @@ import com.facebook.soloader.SoLoader; public class CSSNode implements CSSNodeAPI { static { - try { - SoLoader.loadLibrary("csslayout"); - } catch (Exception ignored) { - // The user probably didn't call SoLoader.init(). Fall back to System.loadLibrary() instead. - System.out.println("Falling back to System.loadLibrary()"); - System.loadLibrary("csslayout"); - } + SoLoader.loadLibrary("csslayout"); } /** From 5fa42cd1b06cc2512213e51bf0d0bf9e50801151 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 29 Nov 2016 09:04:43 -0800 Subject: [PATCH 080/108] Remove Style prefix in java and cs apis Summary: The Style prefix does not make sense in the java and c# api and only a few methods had it. This diff removes the last of those. Reviewed By: splhack Differential Revision: D4232920 fbshipit-source-id: 6e2ff21bbb7e0e441892023c14df579d1bc7aa49 --- csharp/Facebook.CSSLayout/CSSNode.Create.cs | 43 ++++---- csharp/Facebook.CSSLayout/CSSNode.cs | 14 +-- .../CSSLayoutAbsolutePositionTest.cs | 48 ++++----- .../CSSLayoutAlignContentTest.cs | 86 ++++++++-------- .../CSSLayoutAlignItemsTest.cs | 30 +++--- .../CSSLayoutAlignSelfTest.cs | 32 +++--- .../Facebook.CSSLayout/CSSLayoutBorderTest.cs | 24 ++--- .../CSSLayoutFlexDirectionTest.cs | 56 +++++------ .../Facebook.CSSLayout/CSSLayoutFlexTest.cs | 44 ++++----- .../CSSLayoutFlexWrapTest.cs | 72 +++++++------- .../CSSLayoutJustifyContentTest.cs | 98 +++++++++---------- .../Facebook.CSSLayout/CSSLayoutMarginTest.cs | 48 ++++----- .../CSSLayoutMinMaxDimensionTest.cs | 80 +++++++-------- .../CSSLayoutPaddingTest.cs | 24 ++--- .../CSSLayoutRoundingTest.cs | 86 ++++++++-------- .../Facebook.CSSLayout/CSSNodeCreateTest.cs | 24 ++--- .../tests/Facebook.CSSLayout/CSSNodeTest.cs | 18 ++-- gentest/gentest-cs.js | 12 +-- gentest/gentest-java.js | 12 +-- java/com/facebook/csslayout/CSSNode.java | 28 +++--- java/com/facebook/csslayout/CSSNodeAPI.java | 24 ++--- .../facebook/csslayout/CSSNodeDEPRECATED.java | 24 ++--- .../CSSLayoutAbsolutePositionTest.java | 48 ++++----- .../csslayout/CSSLayoutAlignContentTest.java | 86 ++++++++-------- .../csslayout/CSSLayoutAlignItemsTest.java | 30 +++--- .../csslayout/CSSLayoutAlignSelfTest.java | 32 +++--- .../csslayout/CSSLayoutBorderTest.java | 24 ++--- .../csslayout/CSSLayoutFlexDirectionTest.java | 56 +++++------ .../facebook/csslayout/CSSLayoutFlexTest.java | 44 ++++----- .../csslayout/CSSLayoutFlexWrapTest.java | 72 +++++++------- .../CSSLayoutJustifyContentTest.java | 98 +++++++++---------- .../csslayout/CSSLayoutMarginTest.java | 48 ++++----- .../CSSLayoutMinMaxDimensionTest.java | 80 +++++++-------- .../csslayout/CSSLayoutPaddingTest.java | 24 ++--- .../csslayout/CSSLayoutRoundingTest.java | 86 ++++++++-------- .../com/facebook/csslayout/CSSNodeTest.java | 6 +- 36 files changed, 833 insertions(+), 828 deletions(-) diff --git a/csharp/Facebook.CSSLayout/CSSNode.Create.cs b/csharp/Facebook.CSSLayout/CSSNode.Create.cs index 1b5bb207..ff301b8d 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.Create.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.Create.cs @@ -31,12 +31,13 @@ namespace Facebook.CSSLayout Spacing margin = null, Spacing padding = null, Spacing border = null, - float? styleWidth = null, - float? styleHeight = null, - float? styleMaxWidth = null, - float? styleMaxHeight = null, - float? styleMinWidth = null, - float? styleMinHeight = null) + float? width = null, + float? height = null, + float? maxWidth = null, + float? maxHeight = null, + float? minWidth = null, + float? minHeight = null, + float? aspectRatio = null) { CSSNode node = new CSSNode(); @@ -197,38 +198,42 @@ namespace Facebook.CSSLayout } } - if (styleWidth.HasValue) + if (width.HasValue) { - node.StyleWidth = styleWidth.Value; + node.Width = width.Value; } - if (styleHeight.HasValue) + if (height.HasValue) { - node.StyleHeight = styleHeight.Value; + node.Height = height.Value; } - if (styleMinWidth.HasValue) + if (minWidth.HasValue) { - node.StyleMinWidth = styleMinWidth.Value; + node.MinWidth = minWidth.Value; } - if (styleMinHeight.HasValue) + if (minHeight.HasValue) { - node.StyleMinHeight = styleMinHeight.Value; + node.MinHeight = minHeight.Value; } - if (styleMaxWidth.HasValue) + if (maxWidth.HasValue) { - node.StyleMaxWidth = styleMaxWidth.Value; + node.MaxWidth = maxWidth.Value; } - if (styleMaxHeight.HasValue) + if (maxHeight.HasValue) { - node.StyleMaxHeight = styleMaxHeight.Value; + node.MaxHeight = maxHeight.Value; + } + + if (aspectRatio.HasValue) + { + node.AspectRatio = aspectRatio.Value; } return node; } } } - diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 4536f83b..0583a823 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -286,7 +286,7 @@ namespace Facebook.CSSLayout Native.CSSNodeStyleSetPosition(_cssNode, edge, position); } - public float StyleWidth + public float Width { get { @@ -299,7 +299,7 @@ namespace Facebook.CSSLayout } } - public float StyleHeight + public float Height { get { @@ -312,7 +312,7 @@ namespace Facebook.CSSLayout } } - public float StyleMaxWidth + public float MaxWidth { get { @@ -325,7 +325,7 @@ namespace Facebook.CSSLayout } } - public float StyleMaxHeight + public float MaxHeight { get { @@ -338,7 +338,7 @@ namespace Facebook.CSSLayout } } - public float StyleMinWidth + public float MinWidth { get { @@ -351,7 +351,7 @@ namespace Facebook.CSSLayout } } - public float StyleMinHeight + public float MinHeight { get { @@ -364,7 +364,7 @@ namespace Facebook.CSSLayout } } - public float StyleAspectRatio + public float AspectRatio { get { diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index 5458bbb2..0e3086d1 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -21,15 +21,15 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_width_height_start_top() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; root_child0.SetPosition(CSSEdge.Start, 10f); root_child0.SetPosition(CSSEdge.Top, 10f); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -62,15 +62,15 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_width_height_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; root_child0.SetPosition(CSSEdge.End, 10f); root_child0.SetPosition(CSSEdge.Bottom, 10f); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -103,8 +103,8 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_start_top_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; @@ -144,8 +144,8 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_width_height_start_top_end_bottom() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; @@ -153,8 +153,8 @@ namespace Facebook.CSSLayout root_child0.SetPosition(CSSEdge.Top, 10f); root_child0.SetPosition(CSSEdge.End, 10f); root_child0.SetPosition(CSSEdge.Bottom, 10f); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -189,8 +189,8 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.Overflow = CSSOverflow.Hidden; - root.StyleWidth = 50f; - root.StyleHeight = 50f; + root.Width = 50f; + root.Height = 50f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; @@ -199,8 +199,8 @@ namespace Facebook.CSSLayout root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.StyleWidth = 100f; - root_child0_child0.StyleHeight = 100f; + root_child0_child0.Width = 100f; + root_child0_child0.Height = 100f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -255,23 +255,23 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; root_child0.SetPosition(CSSEdge.Left, 0f); root_child0.SetPosition(CSSEdge.Top, 0f); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 50f; + root_child0.Width = 50f; + root_child0.Height = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.PositionType = CSSPositionType.Absolute; root_child1.SetPosition(CSSEdge.Right, 0f); root_child1.SetPosition(CSSEdge.Bottom, 0f); - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 50f; + root_child1.Width = 50f; + root_child1.Height = 50f; root.Insert(1, root_child1); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs index db761e6e..d2735862 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs @@ -22,32 +22,32 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 10f; + root_child0.Width = 50f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 10f; + root_child1.Width = 50f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; - root_child2.StyleHeight = 10f; + root_child2.Width = 50f; + root_child2.Height = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50f; - root_child3.StyleHeight = 10f; + root_child3.Width = 50f; + root_child3.Height = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50f; - root_child4.StyleHeight = 10f; + root_child4.Width = 50f; + root_child4.Height = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -122,32 +122,32 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.FlexEnd; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 10f; + root_child0.Width = 50f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 10f; + root_child1.Width = 50f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; - root_child2.StyleHeight = 10f; + root_child2.Width = 50f; + root_child2.Height = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50f; - root_child3.StyleHeight = 10f; + root_child3.Width = 50f; + root_child3.Height = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50f; - root_child4.StyleHeight = 10f; + root_child4.Width = 50f; + root_child4.Height = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -222,32 +222,32 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.Center; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 10f; + root_child0.Width = 50f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 10f; + root_child1.Width = 50f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; - root_child2.StyleHeight = 10f; + root_child2.Width = 50f; + root_child2.Height = 10f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50f; - root_child3.StyleHeight = 10f; + root_child3.Width = 50f; + root_child3.Height = 10f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50f; - root_child4.StyleHeight = 10f; + root_child4.Width = 50f; + root_child4.Height = 10f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -322,27 +322,27 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.AlignContent = CSSAlign.Stretch; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; + root_child0.Width = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50f; + root_child1.Width = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; + root_child2.Width = 50f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 50f; + root_child3.Width = 50f; root.Insert(3, root_child3); CSSNode root_child4 = new CSSNode(); - root_child4.StyleWidth = 50f; + root_child4.Width = 50f; root.Insert(4, root_child4); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs index b3c9db2d..e7ce8095 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs @@ -21,11 +21,11 @@ namespace Facebook.CSSLayout public void Test_align_items_stretch() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -59,12 +59,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.Center; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -98,12 +98,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexStart; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -137,12 +137,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexEnd; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs index c84b5213..3cb9e7a0 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs @@ -21,13 +21,13 @@ namespace Facebook.CSSLayout public void Test_align_self_center() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.Center; - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -60,13 +60,13 @@ namespace Facebook.CSSLayout public void Test_align_self_flex_end() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexEnd; - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -99,13 +99,13 @@ namespace Facebook.CSSLayout public void Test_align_self_flex_start() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexStart; - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -139,13 +139,13 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.FlexStart; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.AlignSelf = CSSAlign.FlexEnd; - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs index 756344e0..2a2d263d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs @@ -52,8 +52,8 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -90,12 +90,12 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -132,11 +132,11 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Top, 10f); root.SetBorder(CSSEdge.Right, 10f); root.SetBorder(CSSEdge.Bottom, 10f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -174,12 +174,12 @@ namespace Facebook.CSSLayout root.SetBorder(CSSEdge.Start, 10f); root.SetBorder(CSSEdge.End, 20f); root.SetBorder(CSSEdge.Bottom, 20f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs index a35c5810..0658e3bc 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs @@ -21,18 +21,18 @@ namespace Facebook.CSSLayout public void Test_flex_direction_column_no_height() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; + root.Width = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -86,18 +86,18 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleHeight = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -150,19 +150,19 @@ namespace Facebook.CSSLayout public void Test_flex_direction_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -216,19 +216,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -282,19 +282,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.ColumnReverse; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -348,19 +348,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.RowReverse; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs index d6afed25..27c8099c 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs @@ -21,8 +21,8 @@ namespace Facebook.CSSLayout public void Test_flex_basis_flex_grow_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -74,8 +74,8 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -126,8 +126,8 @@ namespace Facebook.CSSLayout public void Test_flex_basis_flex_shrink_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexShrink = 1f; @@ -179,8 +179,8 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexShrink = 1f; @@ -231,22 +231,22 @@ namespace Facebook.CSSLayout public void Test_flex_shrink_to_zero() { CSSNode root = new CSSNode(); - root.StyleHeight = 75f; + root.Height = 75f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 50f; + root_child0.Width = 50f; + root_child0.Height = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexShrink = 1f; - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 50f; + root_child1.Width = 50f; + root_child1.Height = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; - root_child2.StyleHeight = 50f; + root_child2.Width = 50f; + root_child2.Height = 50f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -299,23 +299,23 @@ namespace Facebook.CSSLayout public void Test_flex_basis_overrides_main_size() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -368,8 +368,8 @@ namespace Facebook.CSSLayout public void Test_flex_grow_shrink_at_most() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root.Insert(0, root_child0); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs index db476d02..3f52a8fb 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs @@ -22,26 +22,26 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.Wrap = CSSWrap.Wrap; - root.StyleHeight = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30f; - root_child0.StyleHeight = 30f; + root_child0.Width = 30f; + root_child0.Height = 30f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30f; - root_child1.StyleHeight = 30f; + root_child1.Width = 30f; + root_child1.Height = 30f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30f; - root_child2.StyleHeight = 30f; + root_child2.Width = 30f; + root_child2.Height = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30f; - root_child3.StyleHeight = 30f; + root_child3.Width = 30f; + root_child3.Height = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -106,26 +106,26 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; + root.Width = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30f; - root_child0.StyleHeight = 30f; + root_child0.Width = 30f; + root_child0.Height = 30f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30f; - root_child1.StyleHeight = 30f; + root_child1.Width = 30f; + root_child1.Height = 30f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30f; - root_child2.StyleHeight = 30f; + root_child2.Width = 30f; + root_child2.Height = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30f; - root_child3.StyleHeight = 30f; + root_child3.Width = 30f; + root_child3.Height = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -191,26 +191,26 @@ namespace Facebook.CSSLayout root.FlexDirection = CSSFlexDirection.Row; root.AlignItems = CSSAlign.FlexEnd; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; + root.Width = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30f; - root_child0.StyleHeight = 10f; + root_child0.Width = 30f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30f; - root_child1.StyleHeight = 20f; + root_child1.Width = 30f; + root_child1.Height = 20f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30f; - root_child2.StyleHeight = 30f; + root_child2.Width = 30f; + root_child2.Height = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30f; - root_child3.StyleHeight = 30f; + root_child3.Width = 30f; + root_child3.Height = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -276,26 +276,26 @@ namespace Facebook.CSSLayout root.FlexDirection = CSSFlexDirection.Row; root.AlignItems = CSSAlign.Center; root.Wrap = CSSWrap.Wrap; - root.StyleWidth = 100f; + root.Width = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 30f; - root_child0.StyleHeight = 10f; + root_child0.Width = 30f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 30f; - root_child1.StyleHeight = 20f; + root_child1.Width = 30f; + root_child1.Height = 20f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 30f; - root_child2.StyleHeight = 30f; + root_child2.Width = 30f; + root_child2.Height = 30f; root.Insert(2, root_child2); CSSNode root_child3 = new CSSNode(); - root_child3.StyleWidth = 30f; - root_child3.StyleHeight = 30f; + root_child3.Width = 30f; + root_child3.Height = 30f; root.Insert(3, root_child3); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs index 87a90240..849b2be1 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs @@ -22,19 +22,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -89,19 +89,19 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -156,19 +156,19 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -223,19 +223,19 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.SpaceBetween; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -290,19 +290,19 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.SpaceAround; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 10f; + root_child1.Width = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 10f; + root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -355,18 +355,18 @@ namespace Facebook.CSSLayout public void Test_justify_content_column_flex_start() { CSSNode root = new CSSNode(); - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -420,19 +420,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -486,19 +486,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -552,19 +552,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.SpaceBetween; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -618,19 +618,19 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.SpaceAround; - root.StyleWidth = 102f; - root.StyleHeight = 102f; + root.Width = 102f; + root.Height = 102f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs index 0d5e1bee..a7791c07 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs @@ -22,12 +22,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.SetMargin(CSSEdge.Start, 10f); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.CSSLayout public void Test_margin_top() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.SetMargin(CSSEdge.Top, 10f); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -100,12 +100,12 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.SetMargin(CSSEdge.End, 10f); - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -139,12 +139,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.FlexEnd; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.SetMargin(CSSEdge.Bottom, 10f); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -178,8 +178,8 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -216,8 +216,8 @@ namespace Facebook.CSSLayout public void Test_margin_and_flex_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -255,8 +255,8 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -293,8 +293,8 @@ namespace Facebook.CSSLayout public void Test_margin_and_stretch_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -332,8 +332,8 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -383,8 +383,8 @@ namespace Facebook.CSSLayout public void Test_margin_with_sibling_column() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index 4d3d1c13..3b88d4f1 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -21,12 +21,12 @@ namespace Facebook.CSSLayout public void Test_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleMaxWidth = 50f; - root_child0.StyleHeight = 10f; + root_child0.MaxWidth = 50f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -60,12 +60,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleMaxHeight = 50f; + root_child0.Width = 10f; + root_child0.MaxHeight = 50f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -98,12 +98,12 @@ namespace Facebook.CSSLayout public void Test_min_height() { CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.StyleMinHeight = 60f; + root_child0.MinHeight = 60f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); @@ -151,12 +151,12 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.StyleMinWidth = 60f; + root_child0.MinWidth = 60f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); @@ -204,13 +204,13 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleWidth = 100f; - root.StyleMinHeight = 100f; - root.StyleMaxHeight = 200f; + root.Width = 100f; + root.MinHeight = 100f; + root.MaxHeight = 200f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 60f; - root_child0.StyleHeight = 60f; + root_child0.Width = 60f; + root_child0.Height = 60f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -244,13 +244,13 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.AlignItems = CSSAlign.Center; - root.StyleMinWidth = 100f; - root.StyleMaxWidth = 200f; - root.StyleHeight = 100f; + root.MinWidth = 100f; + root.MaxWidth = 200f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 60f; - root_child0.StyleHeight = 60f; + root_child0.Width = 60f; + root_child0.Height = 60f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -284,22 +284,22 @@ namespace Facebook.CSSLayout { CSSNode root = new CSSNode(); root.JustifyContent = CSSJustify.Center; - root.StyleMinHeight = 100f; - root.StyleMaxHeight = 110f; + root.MinHeight = 100f; + root.MaxHeight = 110f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 50f; - root_child0.StyleHeight = 50f; + root_child0.Width = 50f; + root_child0.Height = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.StyleWidth = 50f; - root_child1.StyleHeight = 50f; + root_child1.Width = 50f; + root_child1.Height = 50f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); - root_child2.StyleWidth = 50f; - root_child2.StyleHeight = 50f; + root_child2.Width = 50f; + root_child2.Height = 50f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -352,17 +352,17 @@ namespace Facebook.CSSLayout public void Test_flex_grow_within_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 200f; - root.StyleHeight = 100f; + root.Width = 200f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexDirection = CSSFlexDirection.Row; - root_child0.StyleMaxWidth = 100f; + root_child0.MaxWidth = 100f; root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.FlexGrow = 1f; - root_child0_child0.StyleHeight = 20f; + root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -405,17 +405,17 @@ namespace Facebook.CSSLayout public void Test_flex_grow_within_constrained_max_width() { CSSNode root = new CSSNode(); - root.StyleWidth = 200f; - root.StyleHeight = 100f; + root.Width = 200f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexDirection = CSSFlexDirection.Row; - root_child0.StyleMaxWidth = 300f; + root_child0.MaxWidth = 300f; root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.FlexGrow = 1f; - root_child0_child0.StyleHeight = 20f; + root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs index 6d95bb17..7712b8af 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs @@ -52,8 +52,8 @@ namespace Facebook.CSSLayout root.SetPadding(CSSEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -90,12 +90,12 @@ namespace Facebook.CSSLayout root.SetPadding(CSSEdge.Top, 10f); root.SetPadding(CSSEdge.Right, 10f); root.SetPadding(CSSEdge.Bottom, 10f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.StyleWidth = 10f; + root_child0.Width = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -132,11 +132,11 @@ namespace Facebook.CSSLayout root.SetPadding(CSSEdge.Top, 10f); root.SetPadding(CSSEdge.Right, 10f); root.SetPadding(CSSEdge.Bottom, 10f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleHeight = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -174,12 +174,12 @@ namespace Facebook.CSSLayout root.SetPadding(CSSEdge.Start, 10f); root.SetPadding(CSSEdge.End, 20f); root.SetPadding(CSSEdge.Bottom, 20f); - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.StyleWidth = 10f; - root_child0.StyleHeight = 10f; + root_child0.Width = 10f; + root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs index 5f1e2a12..cfd11f1e 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs @@ -24,8 +24,8 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 100f; - root.StyleHeight = 100f; + root.Width = 100f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -94,8 +94,8 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 113f; - root.StyleHeight = 100f; + root.Width = 113f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; @@ -192,8 +192,8 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.FlexDirection = CSSFlexDirection.Row; - root.StyleWidth = 101f; - root.StyleHeight = 100f; + root.Width = 101f; + root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexShrink = 1f; @@ -262,23 +262,23 @@ namespace Facebook.CSSLayout CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 113f; + root.Width = 100f; + root.Height = 113f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -335,23 +335,23 @@ namespace Facebook.CSSLayout CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.StyleWidth = 87.4f; - root.StyleHeight = 113.4f; + root.Width = 87.4f; + root.Height = 113.4f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; - root_child0.StyleHeight = 20.3f; + root_child0.Height = 20.3f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1.6f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1.1f; - root_child2.StyleHeight = 10.7f; + root_child2.Height = 10.7f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -408,37 +408,37 @@ namespace Facebook.CSSLayout CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.StyleWidth = 87.4f; - root.StyleHeight = 113.4f; + root.Width = 87.4f; + root.Height = 113.4f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; - root_child0.StyleHeight = 20.3f; + root_child0.Height = 20.3f; root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexBasis = 0.3f; root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f); - root_child0_child0.StyleHeight = 9.9f; + root_child0_child0.Height = 9.9f; root_child0.Insert(0, root_child0_child0); CSSNode root_child0_child1 = new CSSNode(); root_child0_child1.FlexGrow = 4f; root_child0_child1.FlexBasis = 0.3f; root_child0_child1.SetPosition(CSSEdge.Top, 13.3f); - root_child0_child1.StyleHeight = 1.1f; + root_child0_child1.Height = 1.1f; root_child0.Insert(1, root_child0_child1); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1.6f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1.1f; - root_child2.StyleHeight = 10.7f; + root_child2.Height = 10.7f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -515,23 +515,23 @@ namespace Facebook.CSSLayout CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 113.4f; + root.Width = 100f; + root.Height = 113.4f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -588,23 +588,23 @@ namespace Facebook.CSSLayout CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.StyleWidth = 100f; - root.StyleHeight = 113.6f; + root.Width = 100f; + root.Height = 113.6f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -662,23 +662,23 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.SetPosition(CSSEdge.Top, 0.3f); - root.StyleWidth = 100f; - root.StyleHeight = 113.4f; + root.Width = 100f; + root.Height = 113.4f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); @@ -736,23 +736,23 @@ namespace Facebook.CSSLayout CSSNode root = new CSSNode(); root.SetPosition(CSSEdge.Top, 0.7f); - root.StyleWidth = 100f; - root.StyleHeight = 113.4f; + root.Width = 100f; + root.Height = 113.4f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; - root_child0.StyleHeight = 20f; + root_child0.Height = 20f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; - root_child1.StyleHeight = 10f; + root_child1.Height = 10f; root.Insert(1, root_child1); CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; - root_child2.StyleHeight = 10f; + root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = CSSDirection.LTR; root.CalculateLayout(); diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs index 84f064f0..96481d0f 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs @@ -87,12 +87,12 @@ namespace Facebook.CSSLayout padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), - styleWidth: 21, - styleHeight: 22, - styleMinWidth: 23, - styleMinHeight: 24, - styleMaxWidth: 25, - styleMaxHeight: 26); + width: 21, + height: 22, + minWidth: 23, + minHeight: 24, + maxWidth: 25, + maxHeight: 26); Assert.AreEqual(CSSDirection.RTL, node.StyleDirection); Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection); @@ -132,12 +132,12 @@ namespace Facebook.CSSLayout Assert.AreEqual(19, node.GetBorder(CSSEdge.Left)); Assert.AreEqual(20, node.GetBorder(CSSEdge.Right)); - Assert.AreEqual(21, node.StyleWidth); - Assert.AreEqual(22, node.StyleHeight); - Assert.AreEqual(23, node.StyleMinWidth); - Assert.AreEqual(24, node.StyleMinHeight); - Assert.AreEqual(25, node.StyleMaxWidth); - Assert.AreEqual(26, node.StyleMaxHeight); + Assert.AreEqual(21, node.Width); + Assert.AreEqual(22, node.Height); + Assert.AreEqual(23, node.MinWidth); + Assert.AreEqual(24, node.MinHeight); + Assert.AreEqual(25, node.MaxWidth); + Assert.AreEqual(26, node.MaxHeight); } } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index 2e40f5e9..b56c6d43 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -201,14 +201,14 @@ namespace Facebook.CSSLayout public void TestPrint() { CSSNode parent = new CSSNode(); - parent.StyleWidth = 100; - parent.StyleHeight = 120; + parent.Width = 100; + parent.Height = 120; CSSNode child0 = new CSSNode(); - child0.StyleWidth = 30; - child0.StyleHeight = 40; + child0.Width = 30; + child0.Height = 40; CSSNode child1 = new CSSNode(); - child1.StyleWidth = 35; - child1.StyleHeight = 45; + child1.Width = 35; + child1.Height = 45; parent.Insert(0, child0); parent.Insert(0, child1); parent.CalculateLayout(); @@ -219,13 +219,13 @@ namespace Facebook.CSSLayout public void TestCopyStyle() { CSSNode node0 = new CSSNode(); - Assert.IsTrue(CSSConstants.IsUndefined(node0.StyleMaxHeight)); + Assert.IsTrue(CSSConstants.IsUndefined(node0.MaxHeight)); CSSNode node1 = new CSSNode(); - node1.StyleMaxHeight = 100; + node1.MaxHeight = 100; node0.CopyStyle(node1); - Assert.AreEqual(100, node0.StyleMaxHeight); + Assert.AreEqual(100, node0.MaxHeight); } #if !UNITY_EDITOR diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index a50774bb..4ceb2a2f 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -183,7 +183,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleHeight = ' + value + 'f;'); + this.push(nodeName + '.Height = ' + value + 'f;'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -195,19 +195,19 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMaxHeight = ' + value + 'f;'); + this.push(nodeName + '.MaxHeight = ' + value + 'f;'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMaxWidth = ' + value + 'f;'); + this.push(nodeName + '.MaxWidth = ' + value + 'f;'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMinHeight = ' + value + 'f;'); + this.push(nodeName + '.MinHeight = ' + value + 'f;'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleMinWidth = ' + value + 'f;'); + this.push(nodeName + '.MinWidth = ' + value + 'f;'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -227,6 +227,6 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.StyleWidth = ' + value + 'f;'); + this.push(nodeName + '.Width = ' + value + 'f;'); }}, }); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 793c964d..124f63ed 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -188,7 +188,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleHeight(' + value + 'f);'); + this.push(nodeName + '.setHeight(' + value + 'f);'); }}, CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { @@ -200,19 +200,19 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMaxHeight(' + value + 'f);'); + this.push(nodeName + '.setMaxHeight(' + value + 'f);'); }}, CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMaxWidth(' + value + 'f);'); + this.push(nodeName + '.setMaxWidth(' + value + 'f);'); }}, CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMinHeight(' + value + 'f);'); + this.push(nodeName + '.setMinHeight(' + value + 'f);'); }}, CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleMinWidth(' + value + 'f);'); + this.push(nodeName + '.setMinWidth(' + value + 'f);'); }}, CSSNodeStyleSetOverflow:{value:function(nodeName, value) { @@ -232,6 +232,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, CSSNodeStyleSetWidth:{value:function(nodeName, value) { - this.push(nodeName + '.setStyleWidth(' + value + 'f);'); + this.push(nodeName + '.setWidth(' + value + 'f);'); }}, }); diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 5250fd06..b7b39383 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -401,83 +401,83 @@ public class CSSNode implements CSSNodeAPI { private native float jni_CSSNodeStyleGetWidth(long nativePointer); @Override - public float getStyleWidth() { + public float getWidth() { return jni_CSSNodeStyleGetWidth(mNativePointer); } private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width); @Override - public void setStyleWidth(float width) { + public void setWidth(float width) { jni_CSSNodeStyleSetWidth(mNativePointer, width); } private native float jni_CSSNodeStyleGetHeight(long nativePointer); @Override - public float getStyleHeight() { + public float getHeight() { return jni_CSSNodeStyleGetHeight(mNativePointer); } private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height); @Override - public void setStyleHeight(float height) { + public void setHeight(float height) { jni_CSSNodeStyleSetHeight(mNativePointer, height); } private native float jni_CSSNodeStyleGetMinWidth(long nativePointer); @Override - public float getStyleMinWidth() { + public float getMinWidth() { return jni_CSSNodeStyleGetMinWidth(mNativePointer); } private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth); @Override - public void setStyleMinWidth(float minWidth) { + public void setMinWidth(float minWidth) { jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth); } private native float jni_CSSNodeStyleGetMinHeight(long nativePointer); @Override - public float getStyleMinHeight() { + public float getMinHeight() { return jni_CSSNodeStyleGetMinHeight(mNativePointer); } private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight); @Override - public void setStyleMinHeight(float minHeight) { + public void setMinHeight(float minHeight) { jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight); } private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer); @Override - public float getStyleMaxWidth() { + public float getMaxWidth() { return jni_CSSNodeStyleGetMaxWidth(mNativePointer); } private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth); @Override - public void setStyleMaxWidth(float maxWidth) { + public void setMaxWidth(float maxWidth) { jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth); } private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer); @Override - public float getStyleMaxHeight() { + public float getMaxHeight() { return jni_CSSNodeStyleGetMaxHeight(mNativePointer); } private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight); @Override - public void setStyleMaxHeight(float maxheight) { + public void setMaxHeight(float maxheight) { jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); } private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer); - public float getStyleAspectRatio() { + public float getAspectRatio() { return jni_CSSNodeStyleGetAspectRatio(mNativePointer); } private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio); - public void setStyleAspectRatio(float aspectRatio) { + public void setAspectRatio(float aspectRatio) { jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio); } diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/CSSNodeAPI.java index d35d8b48..4570581c 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/CSSNodeAPI.java @@ -68,18 +68,18 @@ public interface CSSNodeAPI { void setBorder(int spacingType, float border); float getPosition(int spacingType); void setPosition(int spacingType, float position); - float getStyleWidth(); - void setStyleWidth(float width); - float getStyleHeight(); - void setStyleHeight(float height); - float getStyleMaxWidth(); - void setStyleMaxWidth(float maxWidth); - float getStyleMinWidth(); - void setStyleMinWidth(float minWidth); - float getStyleMaxHeight(); - void setStyleMaxHeight(float maxHeight); - float getStyleMinHeight(); - void setStyleMinHeight(float minHeight); + float getWidth(); + void setWidth(float width); + float getHeight(); + void setHeight(float height); + float getMaxWidth(); + void setMaxWidth(float maxWidth); + float getMinWidth(); + void setMinWidth(float minWidth); + float getMaxHeight(); + void setMaxHeight(float maxHeight); + float getMinHeight(); + void setMinHeight(float minHeight); float getLayoutX(); float getLayoutY(); float getLayoutWidth(); diff --git a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java index 0031ee69..07d7f526 100644 --- a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java +++ b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java @@ -464,12 +464,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's width, as defined in the style. */ @Override - public float getStyleWidth() { + public float getWidth() { return style.dimensions[DIMENSION_WIDTH]; } @Override - public void setStyleWidth(float width) { + public void setWidth(float width) { if (!valuesEqual(style.dimensions[DIMENSION_WIDTH], width)) { style.dimensions[DIMENSION_WIDTH] = width; dirty(); @@ -480,12 +480,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's height, as defined in the style. */ @Override - public float getStyleHeight() { + public float getHeight() { return style.dimensions[DIMENSION_HEIGHT]; } @Override - public void setStyleHeight(float height) { + public void setHeight(float height) { if (!valuesEqual(style.dimensions[DIMENSION_HEIGHT], height)) { style.dimensions[DIMENSION_HEIGHT] = height; dirty(); @@ -496,12 +496,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's max width, as defined in the style */ @Override - public float getStyleMaxWidth() { + public float getMaxWidth() { return style.maxWidth; } @Override - public void setStyleMaxWidth(float maxWidth) { + public void setMaxWidth(float maxWidth) { if (!valuesEqual(style.maxWidth, maxWidth)) { style.maxWidth = maxWidth; dirty(); @@ -512,12 +512,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's min width, as defined in the style */ @Override - public float getStyleMinWidth() { + public float getMinWidth() { return style.minWidth; } @Override - public void setStyleMinWidth(float minWidth) { + public void setMinWidth(float minWidth) { if (!valuesEqual(style.minWidth, minWidth)) { style.minWidth = minWidth; dirty(); @@ -528,12 +528,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's max height, as defined in the style */ @Override - public float getStyleMaxHeight() { + public float getMaxHeight() { return style.maxHeight; } @Override - public void setStyleMaxHeight(float maxHeight) { + public void setMaxHeight(float maxHeight) { if (!valuesEqual(style.maxHeight, maxHeight)) { style.maxHeight = maxHeight; dirty(); @@ -544,12 +544,12 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { * Get this node's min height, as defined in the style */ @Override - public float getStyleMinHeight() { + public float getMinHeight() { return style.minHeight; } @Override - public void setStyleMinHeight(float minHeight) { + public void setMinHeight(float minHeight) { if (!valuesEqual(style.minHeight, minHeight)) { style.minHeight = minHeight; dirty(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index f7fd50cb..0d10ee41 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -19,15 +19,15 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPosition(Spacing.START, 10f); root_child0.setPosition(Spacing.TOP, 10f); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -59,15 +59,15 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_width_height_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPosition(Spacing.END, 10f); root_child0.setPosition(Spacing.BOTTOM, 10f); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -99,8 +99,8 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_start_top_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); @@ -139,8 +139,8 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top_end_bottom() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); @@ -148,8 +148,8 @@ public class CSSLayoutAbsolutePositionTest { root_child0.setPosition(Spacing.TOP, 10f); root_child0.setPosition(Spacing.END, 10f); root_child0.setPosition(Spacing.BOTTOM, 10f); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -183,8 +183,8 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setOverflow(CSSOverflow.HIDDEN); - root.setStyleWidth(50f); - root.setStyleHeight(50f); + root.setWidth(50f); + root.setHeight(50f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); @@ -193,8 +193,8 @@ public class CSSLayoutAbsolutePositionTest { root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); - root_child0_child0.setStyleWidth(100f); - root_child0_child0.setStyleHeight(100f); + root_child0_child0.setWidth(100f); + root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -248,23 +248,23 @@ public class CSSLayoutAbsolutePositionTest { root.setBorder(Spacing.TOP, 10f); root.setBorder(Spacing.RIGHT, 10f); root.setBorder(Spacing.BOTTOM, 10f); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPosition(Spacing.LEFT, 0f); root_child0.setPosition(Spacing.TOP, 0f); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(50f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setPositionType(CSSPositionType.ABSOLUTE); root_child1.setPosition(Spacing.RIGHT, 0f); root_child1.setPosition(Spacing.BOTTOM, 0f); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(50f); + root_child1.setWidth(50f); + root_child1.setHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java index e48d4ee3..c4cb8c87 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java @@ -20,32 +20,32 @@ public class CSSLayoutAlignContentTest { public void test_align_content_flex_start() { final CSSNode root = new CSSNode(); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(50f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(10f); + root_child1.setWidth(50f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); - root_child2.setStyleHeight(10f); + root_child2.setWidth(50f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50f); - root_child3.setStyleHeight(10f); + root_child3.setWidth(50f); + root_child3.setHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50f); - root_child4.setStyleHeight(10f); + root_child4.setWidth(50f); + root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -119,32 +119,32 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.FLEX_END); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(50f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(10f); + root_child1.setWidth(50f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); - root_child2.setStyleHeight(10f); + root_child2.setWidth(50f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50f); - root_child3.setStyleHeight(10f); + root_child3.setWidth(50f); + root_child3.setHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50f); - root_child4.setStyleHeight(10f); + root_child4.setWidth(50f); + root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -218,32 +218,32 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.CENTER); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(50f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(10f); + root_child1.setWidth(50f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); - root_child2.setStyleHeight(10f); + root_child2.setWidth(50f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50f); - root_child3.setStyleHeight(10f); + root_child3.setWidth(50f); + root_child3.setHeight(10f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50f); - root_child4.setStyleHeight(10f); + root_child4.setWidth(50f); + root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -317,27 +317,27 @@ public class CSSLayoutAlignContentTest { final CSSNode root = new CSSNode(); root.setAlignContent(CSSAlign.STRETCH); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); + root_child0.setWidth(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50f); + root_child1.setWidth(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); + root_child2.setWidth(50f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(50f); + root_child3.setWidth(50f); root.addChildAt(root_child3, 3); final CSSNode root_child4 = new CSSNode(); - root_child4.setStyleWidth(50f); + root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java index cca9b555..1ddeb33a 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java @@ -19,11 +19,11 @@ public class CSSLayoutAlignItemsTest { @Test public void test_align_items_stretch() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -56,12 +56,12 @@ public class CSSLayoutAlignItemsTest { public void test_align_items_center() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.CENTER); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -94,12 +94,12 @@ public class CSSLayoutAlignItemsTest { public void test_align_items_flex_start() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_START); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -132,12 +132,12 @@ public class CSSLayoutAlignItemsTest { public void test_align_items_flex_end() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_END); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java index d6236541..4a2e8fa3 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java @@ -19,13 +19,13 @@ public class CSSLayoutAlignSelfTest { @Test public void test_align_self_center() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.CENTER); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -57,13 +57,13 @@ public class CSSLayoutAlignSelfTest { @Test public void test_align_self_flex_end() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_END); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -95,13 +95,13 @@ public class CSSLayoutAlignSelfTest { @Test public void test_align_self_flex_start() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_START); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -134,13 +134,13 @@ public class CSSLayoutAlignSelfTest { public void test_align_self_flex_end_override_flex_start() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.FLEX_START); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setAlignSelf(CSSAlign.FLEX_END); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java index f382f73b..95a6a26a 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java @@ -49,8 +49,8 @@ public class CSSLayoutBorderTest { root.setBorder(Spacing.BOTTOM, 10f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -86,12 +86,12 @@ public class CSSLayoutBorderTest { root.setBorder(Spacing.TOP, 10f); root.setBorder(Spacing.RIGHT, 10f); root.setBorder(Spacing.BOTTOM, 10f); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -127,11 +127,11 @@ public class CSSLayoutBorderTest { root.setBorder(Spacing.TOP, 10f); root.setBorder(Spacing.RIGHT, 10f); root.setBorder(Spacing.BOTTOM, 10f); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -168,12 +168,12 @@ public class CSSLayoutBorderTest { root.setBorder(Spacing.START, 10f); root.setBorder(Spacing.END, 20f); root.setBorder(Spacing.BOTTOM, 20f); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java index 75b1fe70..fd7ff970 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java @@ -19,18 +19,18 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_column_no_height() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); + root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -83,18 +83,18 @@ public class CSSLayoutFlexDirectionTest { public void test_flex_direction_row_no_width() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleHeight(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -146,19 +146,19 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -211,19 +211,19 @@ public class CSSLayoutFlexDirectionTest { public void test_flex_direction_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -276,19 +276,19 @@ public class CSSLayoutFlexDirectionTest { public void test_flex_direction_column_reverse() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -341,19 +341,19 @@ public class CSSLayoutFlexDirectionTest { public void test_flex_direction_row_reverse() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW_REVERSE); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java index f675cbbf..4cfd6fb9 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java @@ -19,8 +19,8 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_flex_grow_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -71,8 +71,8 @@ public class CSSLayoutFlexTest { public void test_flex_basis_flex_grow_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -122,8 +122,8 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_flex_shrink_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexShrink(1f); @@ -174,8 +174,8 @@ public class CSSLayoutFlexTest { public void test_flex_basis_flex_shrink_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexShrink(1f); @@ -225,22 +225,22 @@ public class CSSLayoutFlexTest { @Test public void test_flex_shrink_to_zero() { final CSSNode root = new CSSNode(); - root.setStyleHeight(75f); + root.setHeight(75f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(50f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexShrink(1f); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(50f); + root_child1.setWidth(50f); + root_child1.setHeight(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); - root_child2.setStyleHeight(50f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -292,23 +292,23 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_overrides_main_size() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -360,8 +360,8 @@ public class CSSLayoutFlexTest { @Test public void test_flex_grow_shrink_at_most() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root.addChildAt(root_child0, 0); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java index 71ba2541..a4090a87 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java @@ -20,26 +20,26 @@ public class CSSLayoutFlexWrapTest { public void test_wrap_column() { final CSSNode root = new CSSNode(); root.setWrap(CSSWrap.WRAP); - root.setStyleHeight(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30f); - root_child0.setStyleHeight(30f); + root_child0.setWidth(30f); + root_child0.setHeight(30f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30f); - root_child1.setStyleHeight(30f); + root_child1.setWidth(30f); + root_child1.setHeight(30f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30f); - root_child2.setStyleHeight(30f); + root_child2.setWidth(30f); + root_child2.setHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30f); - root_child3.setStyleHeight(30f); + root_child3.setWidth(30f); + root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -103,26 +103,26 @@ public class CSSLayoutFlexWrapTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); + root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30f); - root_child0.setStyleHeight(30f); + root_child0.setWidth(30f); + root_child0.setHeight(30f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30f); - root_child1.setStyleHeight(30f); + root_child1.setWidth(30f); + root_child1.setHeight(30f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30f); - root_child2.setStyleHeight(30f); + root_child2.setWidth(30f); + root_child2.setHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30f); - root_child3.setStyleHeight(30f); + root_child3.setWidth(30f); + root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -187,26 +187,26 @@ public class CSSLayoutFlexWrapTest { root.setFlexDirection(CSSFlexDirection.ROW); root.setAlignItems(CSSAlign.FLEX_END); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); + root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(30f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30f); - root_child1.setStyleHeight(20f); + root_child1.setWidth(30f); + root_child1.setHeight(20f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30f); - root_child2.setStyleHeight(30f); + root_child2.setWidth(30f); + root_child2.setHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30f); - root_child3.setStyleHeight(30f); + root_child3.setWidth(30f); + root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -271,26 +271,26 @@ public class CSSLayoutFlexWrapTest { root.setFlexDirection(CSSFlexDirection.ROW); root.setAlignItems(CSSAlign.CENTER); root.setWrap(CSSWrap.WRAP); - root.setStyleWidth(100f); + root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(30f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(30f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(30f); - root_child1.setStyleHeight(20f); + root_child1.setWidth(30f); + root_child1.setHeight(20f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(30f); - root_child2.setStyleHeight(30f); + root_child2.setWidth(30f); + root_child2.setHeight(30f); root.addChildAt(root_child2, 2); final CSSNode root_child3 = new CSSNode(); - root_child3.setStyleWidth(30f); - root_child3.setStyleHeight(30f); + root_child3.setWidth(30f); + root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java index 1c7488de..3bb94f6d 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java @@ -20,19 +20,19 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_row_flex_start() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -86,19 +86,19 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -152,19 +152,19 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -218,19 +218,19 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.SPACE_BETWEEN); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -284,19 +284,19 @@ public class CSSLayoutJustifyContentTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.SPACE_AROUND); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(10f); + root_child1.setWidth(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(10f); + root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -348,18 +348,18 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_column_flex_start() { final CSSNode root = new CSSNode(); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -412,19 +412,19 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_column_flex_end() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -477,19 +477,19 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_column_center() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -542,19 +542,19 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_column_space_between() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.SPACE_BETWEEN); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -607,19 +607,19 @@ public class CSSLayoutJustifyContentTest { public void test_justify_content_column_space_around() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.SPACE_AROUND); - root.setStyleWidth(102f); - root.setStyleHeight(102f); + root.setWidth(102f); + root.setHeight(102f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java index 94f0f0ad..adfd56e1 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java @@ -20,12 +20,12 @@ public class CSSLayoutMarginTest { public void test_margin_start() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setMargin(Spacing.START, 10f); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -57,12 +57,12 @@ public class CSSLayoutMarginTest { @Test public void test_margin_top() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setMargin(Spacing.TOP, 10f); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -96,12 +96,12 @@ public class CSSLayoutMarginTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setMargin(Spacing.END, 10f); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -134,12 +134,12 @@ public class CSSLayoutMarginTest { public void test_margin_bottom() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.FLEX_END); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setMargin(Spacing.BOTTOM, 10f); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -172,8 +172,8 @@ public class CSSLayoutMarginTest { public void test_margin_and_flex_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -209,8 +209,8 @@ public class CSSLayoutMarginTest { @Test public void test_margin_and_flex_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -247,8 +247,8 @@ public class CSSLayoutMarginTest { public void test_margin_and_stretch_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -284,8 +284,8 @@ public class CSSLayoutMarginTest { @Test public void test_margin_and_stretch_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -322,8 +322,8 @@ public class CSSLayoutMarginTest { public void test_margin_with_sibling_row() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -372,8 +372,8 @@ public class CSSLayoutMarginTest { @Test public void test_margin_with_sibling_column() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index 24ff93ab..e3bd448a 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -19,12 +19,12 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleMaxWidth(50f); - root_child0.setStyleHeight(10f); + root_child0.setMaxWidth(50f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -57,12 +57,12 @@ public class CSSLayoutMinMaxDimensionTest { public void test_max_height() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleMaxHeight(50f); + root_child0.setWidth(10f); + root_child0.setMaxHeight(50f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -94,12 +94,12 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_min_height() { final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setStyleMinHeight(60f); + root_child0.setMinHeight(60f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); @@ -146,12 +146,12 @@ public class CSSLayoutMinMaxDimensionTest { public void test_min_width() { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setStyleMinWidth(60f); + root_child0.setMinWidth(60f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); @@ -198,13 +198,13 @@ public class CSSLayoutMinMaxDimensionTest { public void test_justify_content_min_max() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleWidth(100f); - root.setStyleMinHeight(100f); - root.setStyleMaxHeight(200f); + root.setWidth(100f); + root.setMinHeight(100f); + root.setMaxHeight(200f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(60f); - root_child0.setStyleHeight(60f); + root_child0.setWidth(60f); + root_child0.setHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -237,13 +237,13 @@ public class CSSLayoutMinMaxDimensionTest { public void test_align_items_min_max() { final CSSNode root = new CSSNode(); root.setAlignItems(CSSAlign.CENTER); - root.setStyleMinWidth(100f); - root.setStyleMaxWidth(200f); - root.setStyleHeight(100f); + root.setMinWidth(100f); + root.setMaxWidth(200f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(60f); - root_child0.setStyleHeight(60f); + root_child0.setWidth(60f); + root_child0.setHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -276,22 +276,22 @@ public class CSSLayoutMinMaxDimensionTest { public void test_justify_content_overflow_min_max() { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); - root.setStyleMinHeight(100f); - root.setStyleMaxHeight(110f); + root.setMinHeight(100f); + root.setMaxHeight(110f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(50f); - root_child0.setStyleHeight(50f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setStyleWidth(50f); - root_child1.setStyleHeight(50f); + root_child1.setWidth(50f); + root_child1.setHeight(50f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); - root_child2.setStyleWidth(50f); - root_child2.setStyleHeight(50f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -343,17 +343,17 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_flex_grow_within_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(200f); - root.setStyleHeight(100f); + root.setWidth(200f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexDirection(CSSFlexDirection.ROW); - root_child0.setStyleMaxWidth(100f); + root_child0.setMaxWidth(100f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setFlexGrow(1f); - root_child0_child0.setStyleHeight(20f); + root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -395,17 +395,17 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_max_width() { final CSSNode root = new CSSNode(); - root.setStyleWidth(200f); - root.setStyleHeight(100f); + root.setWidth(200f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexDirection(CSSFlexDirection.ROW); - root_child0.setStyleMaxWidth(300f); + root_child0.setMaxWidth(300f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setFlexGrow(1f); - root_child0_child0.setStyleHeight(20f); + root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java index 41750c20..f1031b97 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java @@ -49,8 +49,8 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.BOTTOM, 10); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -86,12 +86,12 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.BOTTOM, 10); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setStyleWidth(10f); + root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -127,11 +127,11 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.BOTTOM, 10); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleHeight(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -168,12 +168,12 @@ public class CSSLayoutPaddingTest { root.setPadding(Spacing.START, 10); root.setPadding(Spacing.END, 20); root.setPadding(Spacing.BOTTOM, 20); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setStyleWidth(10f); - root_child0.setStyleHeight(10f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java index 3ecec462..e32e70c2 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java @@ -22,8 +22,8 @@ public class CSSLayoutRoundingTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(100f); - root.setStyleHeight(100f); + root.setWidth(100f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -91,8 +91,8 @@ public class CSSLayoutRoundingTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(113f); - root.setStyleHeight(100f); + root.setWidth(113f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); @@ -188,8 +188,8 @@ public class CSSLayoutRoundingTest { final CSSNode root = new CSSNode(); root.setFlexDirection(CSSFlexDirection.ROW); - root.setStyleWidth(101f); - root.setStyleHeight(100f); + root.setWidth(101f); + root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexShrink(1f); @@ -257,23 +257,23 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(113f); + root.setWidth(100f); + root.setHeight(113f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -329,23 +329,23 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setStyleWidth(87.4f); - root.setStyleHeight(113.4f); + root.setWidth(87.4f); + root.setHeight(113.4f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); - root_child0.setStyleHeight(20.3f); + root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1.6f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1.1f); - root_child2.setStyleHeight(10.7f); + root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -401,37 +401,37 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setStyleWidth(87.4f); - root.setStyleHeight(113.4f); + root.setWidth(87.4f); + root.setHeight(113.4f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); - root_child0.setStyleHeight(20.3f); + root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0.3f); root_child0_child0.setPosition(Spacing.BOTTOM, 13.3f); - root_child0_child0.setStyleHeight(9.9f); + root_child0_child0.setHeight(9.9f); root_child0.addChildAt(root_child0_child0, 0); final CSSNode root_child0_child1 = new CSSNode(); root_child0_child1.setFlexGrow(4f); root_child0_child1.setFlexBasis(0.3f); root_child0_child1.setPosition(Spacing.TOP, 13.3f); - root_child0_child1.setStyleHeight(1.1f); + root_child0_child1.setHeight(1.1f); root_child0.addChildAt(root_child0_child1, 1); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1.6f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1.1f); - root_child2.setStyleHeight(10.7f); + root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -507,23 +507,23 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(113.4f); + root.setWidth(100f); + root.setHeight(113.4f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -579,23 +579,23 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setStyleWidth(100f); - root.setStyleHeight(113.6f); + root.setWidth(100f); + root.setHeight(113.6f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -652,23 +652,23 @@ public class CSSLayoutRoundingTest { final CSSNode root = new CSSNode(); root.setPosition(Spacing.TOP, 0.3f); - root.setStyleWidth(100f); - root.setStyleHeight(113.4f); + root.setWidth(100f); + root.setHeight(113.4f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); @@ -725,23 +725,23 @@ public class CSSLayoutRoundingTest { final CSSNode root = new CSSNode(); root.setPosition(Spacing.TOP, 0.7f); - root.setStyleWidth(100f); - root.setStyleHeight(113.4f); + root.setWidth(100f); + root.setHeight(113.4f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); - root_child0.setStyleHeight(20f); + root_child0.setHeight(20f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); - root_child1.setStyleHeight(10f); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); - root_child2.setStyleHeight(10f); + root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); root.calculateLayout(null); diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index f269a91c..7e65a301 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -76,12 +76,12 @@ public class CSSNodeTest { @Test public void testCopyStyle() { final CSSNode node0 = new CSSNode(); - assertTrue(CSSConstants.isUndefined(node0.getStyleMaxHeight())); + assertTrue(CSSConstants.isUndefined(node0.getMaxHeight())); final CSSNode node1 = new CSSNode(); - node1.setStyleMaxHeight(100); + node1.setMaxHeight(100); node0.copyStyle(node1); - assertEquals(100, (int) node0.getStyleMaxHeight()); + assertEquals(100, (int) node0.getMaxHeight()); } } From b32b6029de3385093f5712262e44ac1f349fb76f Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 29 Nov 2016 12:23:02 -0800 Subject: [PATCH 081/108] Remove deprecated java code Summary: Remove deprecated java code and make use of CSSEdge instead of the now removed Spacing class. Reviewed By: AaaChiuuu Differential Revision: D4233198 fbshipit-source-id: 736d79be266e1b9f2d62e5fe6d901de47123cdc1 --- gentest/gentest-java.js | 14 +- .../csslayout/CSSCachedMeasurement.java | 20 - java/com/facebook/csslayout/CSSLayout.java | 77 - .../facebook/csslayout/CSSLayoutContext.java | 22 - java/com/facebook/csslayout/CSSNode.java | 45 +- java/com/facebook/csslayout/CSSNodeAPI.java | 19 +- .../facebook/csslayout/CSSNodeDEPRECATED.java | 626 -------- java/com/facebook/csslayout/CSSStyle.java | 76 - .../facebook/csslayout/CachedCSSLayout.java | 23 - java/com/facebook/csslayout/FloatUtil.java | 22 - java/com/facebook/csslayout/LayoutEngine.java | 1369 ----------------- java/com/facebook/csslayout/Spacing.java | 190 --- .../CSSLayoutAbsolutePositionTest.java | 84 +- .../csslayout/CSSLayoutAlignContentTest.java | 16 +- .../csslayout/CSSLayoutAlignItemsTest.java | 16 +- .../csslayout/CSSLayoutAlignSelfTest.java | 16 +- .../csslayout/CSSLayoutBorderTest.java | 58 +- .../csslayout/CSSLayoutFlexDirectionTest.java | 24 +- .../facebook/csslayout/CSSLayoutFlexTest.java | 28 +- .../csslayout/CSSLayoutFlexWrapTest.java | 16 +- .../CSSLayoutJustifyContentTest.java | 40 +- .../csslayout/CSSLayoutMarginTest.java | 56 +- .../CSSLayoutMinMaxDimensionTest.java | 36 +- .../csslayout/CSSLayoutPaddingTest.java | 58 +- .../csslayout/CSSLayoutRoundingTest.java | 48 +- .../com/facebook/csslayout/CSSNodeTest.java | 2 +- 26 files changed, 285 insertions(+), 2716 deletions(-) delete mode 100644 java/com/facebook/csslayout/CSSCachedMeasurement.java delete mode 100644 java/com/facebook/csslayout/CSSLayout.java delete mode 100644 java/com/facebook/csslayout/CSSLayoutContext.java delete mode 100644 java/com/facebook/csslayout/CSSNodeDEPRECATED.java delete mode 100644 java/com/facebook/csslayout/CSSStyle.java delete mode 100644 java/com/facebook/csslayout/CachedCSSLayout.java delete mode 100644 java/com/facebook/csslayout/FloatUtil.java delete mode 100644 java/com/facebook/csslayout/LayoutEngine.java delete mode 100644 java/com/facebook/csslayout/Spacing.java diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 124f63ed..83cc8f24 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -93,12 +93,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { CSSDirectionLTR:{value:'CSSDirection.LTR'}, CSSDirectionRTL:{value:'CSSDirection.RTL'}, - CSSEdgeBottom:{value:'Spacing.BOTTOM'}, - CSSEdgeEnd:{value:'Spacing.END'}, - CSSEdgeLeft:{value:'Spacing.LEFT'}, - CSSEdgeRight:{value:'Spacing.RIGHT'}, - CSSEdgeStart:{value:'Spacing.START'}, - CSSEdgeTop:{value:'Spacing.TOP'}, + CSSEdgeBottom:{value:'CSSEdge.BOTTOM'}, + CSSEdgeEnd:{value:'CSSEdge.END'}, + CSSEdgeLeft:{value:'CSSEdge.LEFT'}, + CSSEdgeRight:{value:'CSSEdge.RIGHT'}, + CSSEdgeStart:{value:'CSSEdge.START'}, + CSSEdgeTop:{value:'CSSEdge.TOP'}, CSSFlexDirectionColumn:{value:'CSSFlexDirection.COLUMN'}, CSSFlexDirectionColumnReverse:{value:'CSSFlexDirection.COLUMN_REVERSE'}, @@ -124,7 +124,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { CSSNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.setDirection(' + dir + ');'); - this.push(node + '.calculateLayout(null);'); + this.push(node + '.calculateLayout();'); }}, CSSNodeInsertChild:{value:function(parentName, nodeName, index) { diff --git a/java/com/facebook/csslayout/CSSCachedMeasurement.java b/java/com/facebook/csslayout/CSSCachedMeasurement.java deleted file mode 100644 index deb1de6a..00000000 --- a/java/com/facebook/csslayout/CSSCachedMeasurement.java +++ /dev/null @@ -1,20 +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. - */ - -package com.facebook.csslayout; - -public class CSSCachedMeasurement { - public float availableWidth; - public float availableHeight; - public CSSMeasureMode widthMeasureMode = null; - public CSSMeasureMode heightMeasureMode = null; - - public float computedWidth; - public float computedHeight; -} diff --git a/java/com/facebook/csslayout/CSSLayout.java b/java/com/facebook/csslayout/CSSLayout.java deleted file mode 100644 index 9bddaf91..00000000 --- a/java/com/facebook/csslayout/CSSLayout.java +++ /dev/null @@ -1,77 +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. - */ - -package com.facebook.csslayout; - -import java.util.Arrays; - -/** - * Where the output of {@link LayoutEngine#layoutNode(CSSNodeDEPRECATED, float)} will go in the CSSNodeDEPRECATED. - */ -public class CSSLayout { - // 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. - public static final int MAX_CACHED_RESULT_COUNT = 16; - - public static final int POSITION_LEFT = 0; - public static final int POSITION_TOP = 1; - public static final int POSITION_RIGHT = 2; - public static final int POSITION_BOTTOM = 3; - - public static final int DIMENSION_WIDTH = 0; - public static final int DIMENSION_HEIGHT = 1; - - public float[] position = new float[4]; - public float[] dimensions = new float[2]; - public CSSDirection direction = CSSDirection.LTR; - - public float computedFlexBasis; - - public int generationCount; - public CSSDirection lastParentDirection; - - public int nextCachedMeasurementsIndex; - public CSSCachedMeasurement[] cachedMeasurements = new CSSCachedMeasurement[MAX_CACHED_RESULT_COUNT]; - public float[] measuredDimensions = new float[2]; - - public CSSCachedMeasurement cachedLayout = new CSSCachedMeasurement(); - - CSSLayout() { - resetResult(); - } - - public void resetResult() { - Arrays.fill(position, 0); - Arrays.fill(dimensions, CSSConstants.UNDEFINED); - direction = CSSDirection.LTR; - - computedFlexBasis = CSSConstants.UNDEFINED; - - generationCount = 0; - lastParentDirection = null; - - nextCachedMeasurementsIndex = 0; - measuredDimensions[DIMENSION_WIDTH] = CSSConstants.UNDEFINED; - measuredDimensions[DIMENSION_HEIGHT] = CSSConstants.UNDEFINED; - - cachedLayout.widthMeasureMode = null; - cachedLayout.heightMeasureMode = null; - } - - @Override - public String toString() { - return "layout: {" + - "left: " + position[POSITION_LEFT] + ", " + - "top: " + position[POSITION_TOP] + ", " + - "width: " + dimensions[DIMENSION_WIDTH] + ", " + - "height: " + dimensions[DIMENSION_HEIGHT] + ", " + - "direction: " + direction + - "}"; - } -} diff --git a/java/com/facebook/csslayout/CSSLayoutContext.java b/java/com/facebook/csslayout/CSSLayoutContext.java deleted file mode 100644 index 91e4f0ba..00000000 --- a/java/com/facebook/csslayout/CSSLayoutContext.java +++ /dev/null @@ -1,22 +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. - */ - -package com.facebook.csslayout; - -/** - * A context for holding values local to a given instance of layout computation. - * - * This is necessary for making layout thread-safe. A separate instance should - * be used when {@link CSSNodeDEPRECATED#calculateLayout} is called concurrently on - * different node hierarchies. - */ -public class CSSLayoutContext { - /*package*/ final MeasureOutput measureOutput = new MeasureOutput(); - int currentGenerationCount; -} diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index b7b39383..47939fe6 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -157,7 +157,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_CSSNodeCalculateLayout(long nativePointer); @Override - public void calculateLayout(CSSLayoutContext layoutContext) { + public void calculateLayout() { jni_CSSNodeCalculateLayout(mNativePointer); } @@ -337,66 +337,66 @@ public class CSSNode implements CSSNodeAPI { private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge); @Override - public float getMargin(int spacingType) { + public float getMargin(CSSEdge edge) { if (!mHasSetMargin) { - return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; } - return jni_CSSNodeStyleGetMargin(mNativePointer, spacingType); + return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin); @Override - public void setMargin(int spacingType, float margin) { + public void setMargin(CSSEdge edge, float margin) { mHasSetMargin = true; - jni_CSSNodeStyleSetMargin(mNativePointer, spacingType, margin); + jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); } private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge); @Override - public float getPadding(int spacingType) { + public float getPadding(CSSEdge edge) { if (!mHasSetPadding) { - return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; } - return jni_CSSNodeStyleGetPadding(mNativePointer, spacingType); + return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding); @Override - public void setPadding(int spacingType, float padding) { + public void setPadding(CSSEdge edge, float padding) { mHasSetPadding = true; - jni_CSSNodeStyleSetPadding(mNativePointer, spacingType, padding); + jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); } private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge); @Override - public float getBorder(int spacingType) { + public float getBorder(CSSEdge edge) { if (!mHasSetBorder) { - return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; } - return jni_CSSNodeStyleGetBorder(mNativePointer, spacingType); + return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border); @Override - public void setBorder(int spacingType, float border) { + public void setBorder(CSSEdge edge, float border) { mHasSetBorder = true; - jni_CSSNodeStyleSetBorder(mNativePointer, spacingType, border); + jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border); } private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge); @Override - public float getPosition(int spacingType) { + public float getPosition(CSSEdge edge) { if (!mHasSetPosition) { return CSSConstants.UNDEFINED; } - return jni_CSSNodeStyleGetPosition(mNativePointer, spacingType); + return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position); @Override - public void setPosition(int spacingType, float position) { + public void setPosition(CSSEdge edge, float position) { mHasSetPosition = true; - jni_CSSNodeStyleSetPosition(mNativePointer, spacingType, position); + jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position); } private native float jni_CSSNodeStyleGetWidth(long nativePointer); @@ -537,11 +537,6 @@ public class CSSNode implements CSSNodeAPI { return mMeasureFunction != null; } - @Override - public boolean valuesEqual(float f1, float f2) { - return FloatUtil.floatsEqual(f1, f2); - } - @Override public void setData(Object data) { mData = data; diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/CSSNodeAPI.java index 4570581c..8e5d19d5 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/CSSNodeAPI.java @@ -31,12 +31,11 @@ public interface CSSNodeAPI { int indexOf(CSSNodeType child); void setMeasureFunction(MeasureFunction measureFunction); boolean isMeasureDefined(); - void calculateLayout(CSSLayoutContext layoutContext); + void calculateLayout(); boolean isDirty(); boolean hasNewLayout(); void dirty(); void markLayoutSeen(); - boolean valuesEqual(float f1, float f2); void copyStyle(CSSNodeType srcNode); CSSDirection getStyleDirection(); void setDirection(CSSDirection direction); @@ -60,14 +59,14 @@ public interface CSSNodeAPI { void setFlexShrink(float flexShrink); float getFlexBasis(); void setFlexBasis(float flexBasis); - float getMargin(int spacingType); - void setMargin(int spacingType, float margin); - float getPadding(int spacingType); - void setPadding(int spacingType, float padding); - float getBorder(int spacingType); - void setBorder(int spacingType, float border); - float getPosition(int spacingType); - void setPosition(int spacingType, float position); + float getMargin(CSSEdge edge); + void setMargin(CSSEdge edge, float margin); + float getPadding(CSSEdge edge); + void setPadding(CSSEdge edge, float padding); + float getBorder(CSSEdge edge); + void setBorder(CSSEdge edge, float border); + float getPosition(CSSEdge edge); + void setPosition(CSSEdge edge, float position); float getWidth(); void setWidth(float width); float getHeight(); diff --git a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java b/java/com/facebook/csslayout/CSSNodeDEPRECATED.java deleted file mode 100644 index 07d7f526..00000000 --- a/java/com/facebook/csslayout/CSSNodeDEPRECATED.java +++ /dev/null @@ -1,626 +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. - */ - -package com.facebook.csslayout; - -import javax.annotation.Nullable; - -import java.util.ArrayList; - -import com.facebook.infer.annotation.Assertions; - -import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT; -import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH; -import static com.facebook.csslayout.CSSLayout.POSITION_LEFT; -import static com.facebook.csslayout.CSSLayout.POSITION_TOP; - -/** - * A CSS Node. It has a style object you can manipulate at {@link #style}. After calling - * {@link #calculateLayout()}, {@link #layout} will be filled with the results of the layout. - */ -public class CSSNodeDEPRECATED implements CSSNodeAPI { - - private enum LayoutState { - /** - * Some property of this node or its children has changes and the current values in - * {@link #layout} are not valid. - */ - DIRTY, - - /** - * This node has a new layout relative to the last time {@link #markLayoutSeen()} was called. - */ - HAS_NEW_LAYOUT, - - /** - * {@link #layout} is valid for the node's properties and this layout has been marked as - * having been seen. - */ - UP_TO_DATE, - } - - // VisibleForTesting - final CSSStyle style = new CSSStyle(); - final CSSLayout layout = new CSSLayout(); - final CachedCSSLayout lastLayout = new CachedCSSLayout(); - - public int lineIndex = 0; - - CSSNodeDEPRECATED nextChild; - - private @Nullable ArrayList mChildren; - private @Nullable CSSNodeDEPRECATED mParent; - private @Nullable MeasureFunction mMeasureFunction = null; - private LayoutState mLayoutState = LayoutState.DIRTY; - private Object mData; - - @Override - public int getChildCount() { - return mChildren == null ? 0 : mChildren.size(); - } - - @Override - public CSSNodeDEPRECATED getChildAt(int i) { - Assertions.assertNotNull(mChildren); - return mChildren.get(i); - } - - @Override - public void addChildAt(CSSNodeDEPRECATED child, int i) { - if (child.mParent != null) { - throw new IllegalStateException("Child already has a parent, it must be removed first."); - } - if (mChildren == null) { - // 4 is kinda arbitrary, but the default of 10 seems really high for an average View. - mChildren = new ArrayList<>(4); - } - - mChildren.add(i, child); - child.mParent = this; - dirty(); - } - - @Override - public CSSNodeDEPRECATED removeChildAt(int i) { - Assertions.assertNotNull(mChildren); - CSSNodeDEPRECATED removed = mChildren.remove(i); - removed.mParent = null; - dirty(); - return removed; - } - - @Override - public @Nullable - CSSNodeDEPRECATED getParent() { - return mParent; - } - - /** - * @return the index of the given child, or -1 if the child doesn't exist in this node. - */ - @Override - public int indexOf(CSSNodeDEPRECATED child) { - Assertions.assertNotNull(mChildren); - return mChildren.indexOf(child); - } - - @Override - public void setMeasureFunction(MeasureFunction measureFunction) { - if (mMeasureFunction != measureFunction) { - mMeasureFunction = measureFunction; - dirty(); - } - } - - @Override - public boolean isMeasureDefined() { - return mMeasureFunction != null; - } - - long measure(float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - if (!isMeasureDefined()) { - throw new RuntimeException("Measure function isn't defined!"); - } - return Assertions.assertNotNull(mMeasureFunction).measure(this, width, widthMode, height, heightMode); - } - - /** - * Performs the actual layout and saves the results in {@link #layout} - */ - @Override - public void calculateLayout(CSSLayoutContext layoutContext) { - LayoutEngine.layoutNode(layoutContext, this, CSSConstants.UNDEFINED, CSSConstants.UNDEFINED, null); - } - - /** - * See {@link LayoutState#DIRTY}. - */ - @Override - public boolean isDirty() { - return mLayoutState == LayoutState.DIRTY; - } - - /** - * See {@link LayoutState#HAS_NEW_LAYOUT}. - */ - @Override - public boolean hasNewLayout() { - return mLayoutState == LayoutState.HAS_NEW_LAYOUT; - } - - @Override - public void dirty() { - if (mLayoutState == LayoutState.DIRTY) { - return; - } else if (mLayoutState == LayoutState.HAS_NEW_LAYOUT) { - throw new IllegalStateException("Previous layout was ignored! markLayoutSeen() never called"); - } - - mLayoutState = LayoutState.DIRTY; - layout.computedFlexBasis = CSSConstants.UNDEFINED; - - if (mParent != null) { - mParent.dirty(); - } - } - - void markHasNewLayout() { - mLayoutState = LayoutState.HAS_NEW_LAYOUT; - } - - /** - * Tells the node that the current values in {@link #layout} have been seen. Subsequent calls - * to {@link #hasNewLayout()} will return false until this node is laid out with new parameters. - * You must call this each time the layout is generated if the node has a new layout. - */ - @Override - public void markLayoutSeen() { - if (!hasNewLayout()) { - throw new IllegalStateException("Expected node to have a new layout to be seen!"); - } - - mLayoutState = LayoutState.UP_TO_DATE; - } - - private void toStringWithIndentation(StringBuilder result, int level) { - // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. - StringBuilder indentation = new StringBuilder(); - for (int i = 0; i < level; ++i) { - indentation.append("__"); - } - - result.append(indentation.toString()); - result.append(layout.toString()); - - if (getChildCount() == 0) { - return; - } - - result.append(", children: [\n"); - for (int i = 0; i < getChildCount(); i++) { - getChildAt(i).toStringWithIndentation(result, level + 1); - result.append("\n"); - } - result.append(indentation + "]"); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - this.toStringWithIndentation(sb, 0); - return sb.toString(); - } - - @Override - public boolean valuesEqual(float f1, float f2) { - return FloatUtil.floatsEqual(f1, f2); - } - - @Override - public void copyStyle(CSSNodeDEPRECATED srcNode) { - throw new UnsupportedOperationException("copyStyle is not implemented"); - } - - /** - * Get this node's direction, as defined in the style. - */ - @Override - public CSSDirection getStyleDirection() { - return style.direction; - } - - @Override - public void setDirection(CSSDirection direction) { - if (style.direction != direction) { - style.direction = direction; - dirty(); - } - } - - /** - * Get this node's flex direction, as defined by style. - */ - @Override - public CSSFlexDirection getFlexDirection() { - return style.flexDirection; - } - - @Override - public void setFlexDirection(CSSFlexDirection flexDirection) { - if (style.flexDirection != flexDirection) { - style.flexDirection = flexDirection; - dirty(); - } - } - - /** - * Get this node's justify content, as defined by style. - */ - @Override - public CSSJustify getJustifyContent() { - return style.justifyContent; - } - - @Override - public void setJustifyContent(CSSJustify justifyContent) { - if (style.justifyContent != justifyContent) { - style.justifyContent = justifyContent; - dirty(); - } - } - - /** - * Get this node's align items, as defined by style. - */ - @Override - public CSSAlign getAlignItems() { - return style.alignItems; - } - - @Override - public void setAlignItems(CSSAlign alignItems) { - if (style.alignItems != alignItems) { - style.alignItems = alignItems; - dirty(); - } - } - - /** - * Get this node's align items, as defined by style. - */ - @Override - public CSSAlign getAlignSelf() { - return style.alignSelf; - } - - @Override - public void setAlignSelf(CSSAlign alignSelf) { - if (style.alignSelf != alignSelf) { - style.alignSelf = alignSelf; - dirty(); - } - } - - @Override - public CSSAlign getAlignContent() { - return style.alignContent; - } - - @Override - public void setAlignContent(CSSAlign alignContent) { - if (style.alignContent != alignContent) { - style.alignContent = alignContent; - dirty(); - } - } - - /** - * Get this node's position type, as defined by style. - */ - @Override - public CSSPositionType getPositionType() { - return style.positionType; - } - - @Override - public void setPositionType(CSSPositionType positionType) { - if (style.positionType != positionType) { - style.positionType = positionType; - dirty(); - } - } - - @Override - public void setWrap(CSSWrap flexWrap) { - if (style.flexWrap != flexWrap) { - style.flexWrap = flexWrap; - dirty(); - } - } - - @Override - public void setFlex(float flex) { - if (CSSConstants.isUndefined(flex) || flex == 0) { - setFlexGrow(0); - setFlexShrink(0); - setFlexBasis(CSSConstants.UNDEFINED); - } else if (flex > 0) { - setFlexGrow(flex); - setFlexShrink(0); - setFlexBasis(0); - } else { - setFlexGrow(0); - setFlexShrink(-flex); - setFlexBasis(CSSConstants.UNDEFINED); - } - } - - @Override - public float getFlexGrow() { - return style.flexGrow; - } - - @Override - public void setFlexGrow(float flexGrow) { - if (!valuesEqual(style.flexGrow, flexGrow)) { - style.flexGrow = flexGrow; - dirty(); - } - } - - @Override - public float getFlexShrink() { - return style.flexShrink; - } - - @Override - public void setFlexShrink(float flexShrink) { - if (!valuesEqual(style.flexShrink, flexShrink)) { - style.flexShrink = flexShrink; - dirty(); - } - } - - @Override - public float getFlexBasis() { - return style.flexBasis; - } - - @Override - public void setFlexBasis(float flexBasis) { - if (!valuesEqual(style.flexBasis, flexBasis)) { - style.flexBasis = flexBasis; - dirty(); - } - } - - /** - * Get this node's margin, as defined by style + default margin. - */ - @Override - public float getMargin(int spacingType) { - return style.margin.get(spacingType); - } - - @Override - public void setMargin(int spacingType, float margin) { - if (style.margin.set(spacingType, margin)) { - dirty(); - } - } - - /** - * Get this node's padding, as defined by style + default padding. - */ - @Override - public float getPadding(int spacingType) { - return style.padding.get(spacingType); - } - - @Override - public void setPadding(int spacingType, float padding) { - if (style.padding.set(spacingType, padding)) { - dirty(); - } - } - - /** - * Get this node's border, as defined by style. - */ - @Override - public float getBorder(int spacingType) { - return style.border.get(spacingType); - } - - @Override - public void setBorder(int spacingType, float border) { - if (style.border.set(spacingType, border)) { - dirty(); - } - } - - /** - * Get this node's position, as defined by style. - */ - @Override - public float getPosition(int spacingType) { - return style.position.get(spacingType); - } - - @Override - public void setPosition(int spacingType, float position) { - if (style.position.set(spacingType, position)) { - dirty(); - } - } - - /** - * Get this node's width, as defined in the style. - */ - @Override - public float getWidth() { - return style.dimensions[DIMENSION_WIDTH]; - } - - @Override - public void setWidth(float width) { - if (!valuesEqual(style.dimensions[DIMENSION_WIDTH], width)) { - style.dimensions[DIMENSION_WIDTH] = width; - dirty(); - } - } - - /** - * Get this node's height, as defined in the style. - */ - @Override - public float getHeight() { - return style.dimensions[DIMENSION_HEIGHT]; - } - - @Override - public void setHeight(float height) { - if (!valuesEqual(style.dimensions[DIMENSION_HEIGHT], height)) { - style.dimensions[DIMENSION_HEIGHT] = height; - dirty(); - } - } - - /** - * Get this node's max width, as defined in the style - */ - @Override - public float getMaxWidth() { - return style.maxWidth; - } - - @Override - public void setMaxWidth(float maxWidth) { - if (!valuesEqual(style.maxWidth, maxWidth)) { - style.maxWidth = maxWidth; - dirty(); - } - } - - /** - * Get this node's min width, as defined in the style - */ - @Override - public float getMinWidth() { - return style.minWidth; - } - - @Override - public void setMinWidth(float minWidth) { - if (!valuesEqual(style.minWidth, minWidth)) { - style.minWidth = minWidth; - dirty(); - } - } - - /** - * Get this node's max height, as defined in the style - */ - @Override - public float getMaxHeight() { - return style.maxHeight; - } - - @Override - public void setMaxHeight(float maxHeight) { - if (!valuesEqual(style.maxHeight, maxHeight)) { - style.maxHeight = maxHeight; - dirty(); - } - } - - /** - * Get this node's min height, as defined in the style - */ - @Override - public float getMinHeight() { - return style.minHeight; - } - - @Override - public void setMinHeight(float minHeight) { - if (!valuesEqual(style.minHeight, minHeight)) { - style.minHeight = minHeight; - dirty(); - } - } - - @Override - public float getLayoutX() { - return layout.position[POSITION_LEFT]; - } - - @Override - public float getLayoutY() { - return layout.position[POSITION_TOP]; - } - - @Override - public float getLayoutWidth() { - return layout.dimensions[DIMENSION_WIDTH]; - } - - @Override - public float getLayoutHeight() { - return layout.dimensions[DIMENSION_HEIGHT]; - } - - @Override - public CSSDirection getLayoutDirection() { - return layout.direction; - } - - /** - * Get this node's overflow property, as defined in the style - */ - @Override - public CSSOverflow getOverflow() { - return style.overflow; - } - - @Override - public void setOverflow(CSSOverflow overflow) { - if (style.overflow != overflow) { - style.overflow = overflow; - dirty(); - } - } - - @Override - public void setData(Object data) { - mData = data; - } - - @Override - public Object getData() { - return mData; - } - - /** - * Resets this instance to its default state. This method is meant to be used when - * recycling {@link CSSNodeDEPRECATED} instances. - */ - @Override - public void reset() { - if (mParent != null || (mChildren != null && mChildren.size() > 0)) { - throw new IllegalStateException("You should not free an attached CSSNodeDEPRECATED"); - } - - style.reset(); - layout.resetResult(); - lineIndex = 0; - mLayoutState = LayoutState.DIRTY; - mMeasureFunction = null; - } -} diff --git a/java/com/facebook/csslayout/CSSStyle.java b/java/com/facebook/csslayout/CSSStyle.java deleted file mode 100644 index 916e54e2..00000000 --- a/java/com/facebook/csslayout/CSSStyle.java +++ /dev/null @@ -1,76 +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. - */ - -package com.facebook.csslayout; - -import java.util.Arrays; - -/** - * The CSS style definition for a {@link CSSNodeDEPRECATED}. - */ -public class CSSStyle { - - public CSSDirection direction; - public CSSFlexDirection flexDirection; - public CSSJustify justifyContent; - public CSSAlign alignContent; - public CSSAlign alignItems; - public CSSAlign alignSelf; - public CSSPositionType positionType; - public CSSWrap flexWrap; - public CSSOverflow overflow; - public float flexGrow; - public float flexShrink; - public float flexBasis; - - public Spacing margin = new Spacing(); - public Spacing padding = new Spacing(); - public Spacing border = new Spacing(); - public Spacing position = new Spacing(CSSConstants.UNDEFINED); - - public float[] dimensions = new float[2]; - - public float minWidth = CSSConstants.UNDEFINED; - public float minHeight = CSSConstants.UNDEFINED; - - public float maxWidth = CSSConstants.UNDEFINED; - public float maxHeight = CSSConstants.UNDEFINED; - - CSSStyle() { - reset(); - } - - void reset() { - direction = CSSDirection.INHERIT; - flexDirection = CSSFlexDirection.COLUMN; - justifyContent = CSSJustify.FLEX_START; - alignContent = CSSAlign.FLEX_START; - alignItems = CSSAlign.STRETCH; - alignSelf = CSSAlign.AUTO; - positionType = CSSPositionType.RELATIVE; - flexWrap = CSSWrap.NO_WRAP; - overflow = CSSOverflow.VISIBLE; - flexGrow = 0; - flexShrink = 0; - flexBasis = CSSConstants.UNDEFINED; - - margin.reset(); - padding.reset(); - border.reset(); - position.reset(); - - Arrays.fill(dimensions, CSSConstants.UNDEFINED); - - minWidth = CSSConstants.UNDEFINED; - minHeight = CSSConstants.UNDEFINED; - - maxWidth = CSSConstants.UNDEFINED; - maxHeight = CSSConstants.UNDEFINED; - } -} diff --git a/java/com/facebook/csslayout/CachedCSSLayout.java b/java/com/facebook/csslayout/CachedCSSLayout.java deleted file mode 100644 index a012a5ba..00000000 --- a/java/com/facebook/csslayout/CachedCSSLayout.java +++ /dev/null @@ -1,23 +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. - */ - -package com.facebook.csslayout; - -/** - * CSSLayout with additional information about the conditions under which it was generated. - * {@link #requestedWidth} and {@link #requestedHeight} are the width and height the parent set on - * this node before calling layout visited us. - */ -public class CachedCSSLayout extends CSSLayout { - - public float requestedWidth = CSSConstants.UNDEFINED; - public float requestedHeight = CSSConstants.UNDEFINED; - public float parentMaxWidth = CSSConstants.UNDEFINED; - public float parentMaxHeight = CSSConstants.UNDEFINED; -} diff --git a/java/com/facebook/csslayout/FloatUtil.java b/java/com/facebook/csslayout/FloatUtil.java deleted file mode 100644 index 8b211e8d..00000000 --- a/java/com/facebook/csslayout/FloatUtil.java +++ /dev/null @@ -1,22 +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. - */ - -package com.facebook.csslayout; - -public class FloatUtil { - - private static final float EPSILON = .00001f; - - public static boolean floatsEqual(float f1, float f2) { - if (Float.isNaN(f1) || Float.isNaN(f2)) { - return Float.isNaN(f1) && Float.isNaN(f2); - } - return Math.abs(f2 - f1) < EPSILON; - } -} diff --git a/java/com/facebook/csslayout/LayoutEngine.java b/java/com/facebook/csslayout/LayoutEngine.java deleted file mode 100644 index c6fa42c2..00000000 --- a/java/com/facebook/csslayout/LayoutEngine.java +++ /dev/null @@ -1,1369 +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. - */ - -package com.facebook.csslayout; - -import com.facebook.infer.annotation.Assertions; - -import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT; -import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH; -import static com.facebook.csslayout.CSSLayout.POSITION_BOTTOM; -import static com.facebook.csslayout.CSSLayout.POSITION_LEFT; -import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT; -import static com.facebook.csslayout.CSSLayout.POSITION_TOP; - -/** - * Calculates layouts based on CSS style. See {@link #layoutNode(CSSNodeDEPRECATED, float, float)}. - */ -public class LayoutEngine { - - private static final int CSS_FLEX_DIRECTION_COLUMN = - CSSFlexDirection.COLUMN.ordinal(); - private static final int CSS_FLEX_DIRECTION_COLUMN_REVERSE = - CSSFlexDirection.COLUMN_REVERSE.ordinal(); - private static final int CSS_FLEX_DIRECTION_ROW = - CSSFlexDirection.ROW.ordinal(); - private static final int CSS_FLEX_DIRECTION_ROW_REVERSE = - CSSFlexDirection.ROW_REVERSE.ordinal(); - - private static final int CSS_POSITION_RELATIVE = CSSPositionType.RELATIVE.ordinal(); - private static final int CSS_POSITION_ABSOLUTE = CSSPositionType.ABSOLUTE.ordinal(); - - private static final int[] leading = { - POSITION_TOP, - POSITION_BOTTOM, - POSITION_LEFT, - POSITION_RIGHT, - }; - - private static final int[] trailing = { - POSITION_BOTTOM, - POSITION_TOP, - POSITION_RIGHT, - POSITION_LEFT, - }; - - private static final int[] pos = { - POSITION_TOP, - POSITION_BOTTOM, - POSITION_LEFT, - POSITION_RIGHT, - }; - - private static final int[] dim = { - DIMENSION_HEIGHT, - DIMENSION_HEIGHT, - DIMENSION_WIDTH, - DIMENSION_WIDTH, - }; - - private static final int[] leadingSpacing = { - Spacing.TOP, - Spacing.BOTTOM, - Spacing.START, - Spacing.START - }; - - private static final int[] trailingSpacing = { - Spacing.BOTTOM, - Spacing.TOP, - Spacing.END, - Spacing.END - }; - - private static boolean isFlexBasisAuto(CSSNodeDEPRECATED node) { - return CSSConstants.isUndefined(node.style.flexBasis); - } - - private static float getFlexGrowFactor(CSSNodeDEPRECATED node) { - return node.style.flexGrow; - } - - private static float getFlexShrinkFactor(CSSNodeDEPRECATED node) { - return node.style.flexShrink; - } - - - private static float boundAxisWithinMinAndMax(CSSNodeDEPRECATED node, int axis, float value) { - float min = CSSConstants.UNDEFINED; - float max = CSSConstants.UNDEFINED; - - if (axis == CSS_FLEX_DIRECTION_COLUMN || - axis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { - min = node.style.minHeight; - max = node.style.maxHeight; - } else if (axis == CSS_FLEX_DIRECTION_ROW || - axis == CSS_FLEX_DIRECTION_ROW_REVERSE) { - min = node.style.minWidth; - max = node.style.maxWidth; - } - - float boundValue = value; - - if (!Float.isNaN(max) && max >= 0.0 && boundValue > max) { - boundValue = max; - } - if (!Float.isNaN(min) && min >= 0.0 && boundValue < min) { - boundValue = min; - } - - return boundValue; - } - - private static float boundAxis(CSSNodeDEPRECATED node, int axis, float value) { - float paddingAndBorderAxis = - node.style.padding.getWithFallback(leadingSpacing[axis], leading[axis]) + - node.style.border.getWithFallback(leadingSpacing[axis], leading[axis]) + - node.style.padding.getWithFallback(trailingSpacing[axis], trailing[axis]) + - node.style.border.getWithFallback(trailingSpacing[axis], trailing[axis]); - return Math.max(boundAxisWithinMinAndMax(node, axis, value), paddingAndBorderAxis); - } - - private static float getRelativePosition(CSSNodeDEPRECATED node, int axis) { - float lead = node.style.position.getWithFallback(leadingSpacing[axis], leading[axis]); - if (!Float.isNaN(lead)) { - return lead; - } - - float trailingPos = node.style.position.getWithFallback(trailingSpacing[axis], trailing[axis]); - return Float.isNaN(trailingPos) ? 0 : -trailingPos; - } - - private static void setPosition(CSSNodeDEPRECATED node, CSSDirection direction) { - int mainAxis = resolveAxis(getFlexDirection(node), direction); - int crossAxis = getCrossFlexDirection(mainAxis, direction); - - node.layout.position[leading[mainAxis]] = node.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + - getRelativePosition(node, mainAxis); - node.layout.position[trailing[mainAxis]] = node.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + - getRelativePosition(node, mainAxis); - node.layout.position[leading[crossAxis]] = node.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + - getRelativePosition(node, crossAxis); - node.layout.position[trailing[crossAxis]] = node.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + - getRelativePosition(node, crossAxis); - } - - private static int resolveAxis( - int axis, - CSSDirection direction) { - if (direction == CSSDirection.RTL) { - if (axis == CSS_FLEX_DIRECTION_ROW) { - return CSS_FLEX_DIRECTION_ROW_REVERSE; - } else if (axis == CSS_FLEX_DIRECTION_ROW_REVERSE) { - return CSS_FLEX_DIRECTION_ROW; - } - } - - return axis; - } - - private static CSSDirection resolveDirection(CSSNodeDEPRECATED node, CSSDirection parentDirection) { - CSSDirection direction = node.style.direction; - if (direction == CSSDirection.INHERIT) { - direction = (parentDirection == null ? CSSDirection.LTR : parentDirection); - } - - return direction; - } - - private static int getFlexDirection(CSSNodeDEPRECATED node) { - return node.style.flexDirection.ordinal(); - } - - private static int getCrossFlexDirection( - int axis, - CSSDirection direction) { - if (axis == CSS_FLEX_DIRECTION_COLUMN || - axis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { - return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction); - } else { - return CSS_FLEX_DIRECTION_COLUMN; - } - } - - private static CSSAlign getAlignItem(CSSNodeDEPRECATED node, CSSNodeDEPRECATED child) { - if (child.style.alignSelf != CSSAlign.AUTO) { - return child.style.alignSelf; - } - return node.style.alignItems; - } - - private static boolean isMeasureDefined(CSSNodeDEPRECATED node) { - return node.isMeasureDefined(); - } - - /*package*/ static void layoutNode( - CSSLayoutContext layoutContext, - CSSNodeDEPRECATED node, - float availableWidth, - float availableHeight, - CSSDirection 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 input - // parameters don't change. - layoutContext.currentGenerationCount++; - - CSSMeasureMode widthMeasureMode = CSSMeasureMode.UNDEFINED; - CSSMeasureMode heightMeasureMode = CSSMeasureMode.UNDEFINED; - - if (!Float.isNaN(availableWidth)) { - widthMeasureMode = CSSMeasureMode.EXACTLY; - } else if (node.style.dimensions[DIMENSION_WIDTH] >= 0.0) { - float marginAxisRow = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - availableWidth = node.style.dimensions[DIMENSION_WIDTH] + marginAxisRow; - widthMeasureMode = CSSMeasureMode.EXACTLY; - } else if (node.style.maxWidth >= 0.0) { - availableWidth = node.style.maxWidth; - widthMeasureMode = CSSMeasureMode.AT_MOST; - } - - if (!Float.isNaN(availableHeight)) { - heightMeasureMode = CSSMeasureMode.EXACTLY; - } else if (node.style.dimensions[DIMENSION_HEIGHT] >= 0.0) { - float marginAxisColumn = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - availableHeight = node.style.dimensions[DIMENSION_HEIGHT] + marginAxisColumn; - heightMeasureMode = CSSMeasureMode.EXACTLY; - } else if (node.style.maxHeight >= 0.0) { - availableHeight = node.style.maxHeight; - heightMeasureMode = CSSMeasureMode.AT_MOST; - } - - if (layoutNodeInternal(layoutContext, node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, true, "initial")) { - setPosition(node, node.layout.direction); - } - } - - /*package*/ static boolean canUseCachedMeasurement( - float availableWidth, - float availableHeight, - float marginRow, - float marginColumn, - CSSMeasureMode widthMeasureMode, - CSSMeasureMode heightMeasureMode, - CSSCachedMeasurement cachedLayout) { - - boolean isHeightSame = - (cachedLayout.heightMeasureMode == CSSMeasureMode.UNDEFINED && heightMeasureMode == CSSMeasureMode.UNDEFINED) || - (cachedLayout.heightMeasureMode == heightMeasureMode && FloatUtil.floatsEqual(cachedLayout.availableHeight, availableHeight)); - - boolean isWidthSame = - (cachedLayout.widthMeasureMode == CSSMeasureMode.UNDEFINED && widthMeasureMode == CSSMeasureMode.UNDEFINED) || - (cachedLayout.widthMeasureMode == widthMeasureMode && FloatUtil.floatsEqual(cachedLayout.availableWidth, availableWidth)); - - if (isHeightSame && isWidthSame) { - return true; - } - - boolean isHeightValid = - (cachedLayout.heightMeasureMode == CSSMeasureMode.UNDEFINED && heightMeasureMode == CSSMeasureMode.AT_MOST && cachedLayout.computedHeight <= (availableHeight - marginColumn)) || - (heightMeasureMode == CSSMeasureMode.EXACTLY && FloatUtil.floatsEqual(cachedLayout.computedHeight, availableHeight - marginColumn)); - - if (isWidthSame && isHeightValid) { - return true; - } - - boolean isWidthValid = - (cachedLayout.widthMeasureMode == CSSMeasureMode.UNDEFINED && widthMeasureMode == CSSMeasureMode.AT_MOST && cachedLayout.computedWidth <= (availableWidth - marginRow)) || - (widthMeasureMode == CSSMeasureMode.EXACTLY && FloatUtil.floatsEqual(cachedLayout.computedWidth, availableWidth - marginRow)); - - if (isHeightSame && isWidthValid) { - return true; - } - - if (isHeightValid && isWidthValid) { - return true; - } - - return false; - } - - // - // This is a wrapper around the layoutNodeImpl function. It determines - // whether the layout request is redundant and can be skipped. - // - // Parameters: - // Input parameters are the same as layoutNodeImpl (see below) - // Return parameter is true if layout was performed, false if skipped - // - private static boolean layoutNodeInternal( - CSSLayoutContext layoutContext, - CSSNodeDEPRECATED node, - float availableWidth, - float availableHeight, - CSSDirection parentDirection, - CSSMeasureMode widthMeasureMode, - CSSMeasureMode heightMeasureMode, - boolean performLayout, - String reason) { - CSSLayout layout = node.layout; - - boolean needToVisitNode = (node.isDirty() && layout.generationCount != layoutContext.currentGenerationCount) || - layout.lastParentDirection != parentDirection; - - if (needToVisitNode) { - // Invalidate the cached results. - layout.nextCachedMeasurementsIndex = 0; - layout.cachedLayout.widthMeasureMode = null; - layout.cachedLayout.heightMeasureMode = null; - } - - CSSCachedMeasurement cachedResults = null; - - // Determine whether the results are already cached. We maintain a separate - // cache for layouts and measurements. A layout operation modifies the positions - // and dimensions for nodes in the subtree. The algorithm assumes that each node - // gets layed out a maximum of one time per tree layout, but multiple measurements - // may be required to resolve all of the flex dimensions. - // We handle nodes with measure functions specially here because they are the most - // expensive to measure, so it's worth avoiding redundant measurements if at all possible. - if (isMeasureDefined(node)) { - float marginAxisRow = - node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + - node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]); - float marginAxisColumn = - node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + - node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]); - - // First, try to use the layout cache. - if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, - widthMeasureMode, heightMeasureMode, layout.cachedLayout)) { - cachedResults = layout.cachedLayout; - } else { - // Try to use the measurement cache. - for (int i = 0; i < layout.nextCachedMeasurementsIndex; i++) { - if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, - widthMeasureMode, heightMeasureMode, layout.cachedMeasurements[i])) { - cachedResults = layout.cachedMeasurements[i]; - break; - } - } - } - } else if (performLayout) { - if (FloatUtil.floatsEqual(layout.cachedLayout.availableWidth, availableWidth) && - FloatUtil.floatsEqual(layout.cachedLayout.availableHeight, availableHeight) && - layout.cachedLayout.widthMeasureMode == widthMeasureMode && - layout.cachedLayout.heightMeasureMode == heightMeasureMode) { - - cachedResults = layout.cachedLayout; - } - } else { - for (int i = 0; i < layout.nextCachedMeasurementsIndex; i++) { - if (FloatUtil.floatsEqual(layout.cachedMeasurements[i].availableWidth, availableWidth) && - FloatUtil.floatsEqual(layout.cachedMeasurements[i].availableHeight, availableHeight) && - layout.cachedMeasurements[i].widthMeasureMode == widthMeasureMode && - layout.cachedMeasurements[i].heightMeasureMode == heightMeasureMode) { - - cachedResults = layout.cachedMeasurements[i]; - break; - } - } - } - - if (!needToVisitNode && cachedResults != null) { - layout.measuredDimensions[DIMENSION_WIDTH] = cachedResults.computedWidth; - layout.measuredDimensions[DIMENSION_HEIGHT] = cachedResults.computedHeight; - } else { - layoutNodeImpl(layoutContext, node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, performLayout); - - layout.lastParentDirection = parentDirection; - - if (cachedResults == null) { - if (layout.nextCachedMeasurementsIndex == CSSLayout.MAX_CACHED_RESULT_COUNT) { - layout.nextCachedMeasurementsIndex = 0; - } - - CSSCachedMeasurement newCacheEntry = null; - if (performLayout) { - // Use the single layout cache entry. - newCacheEntry = layout.cachedLayout; - } else { - // Allocate a new measurement cache entry. - newCacheEntry = layout.cachedMeasurements[layout.nextCachedMeasurementsIndex]; - if (newCacheEntry == null) { - newCacheEntry = new CSSCachedMeasurement(); - layout.cachedMeasurements[layout.nextCachedMeasurementsIndex] = newCacheEntry; - } - layout.nextCachedMeasurementsIndex++; - } - - newCacheEntry.availableWidth = availableWidth; - newCacheEntry.availableHeight = availableHeight; - newCacheEntry.widthMeasureMode = widthMeasureMode; - newCacheEntry.heightMeasureMode = heightMeasureMode; - newCacheEntry.computedWidth = layout.measuredDimensions[DIMENSION_WIDTH]; - newCacheEntry.computedHeight = layout.measuredDimensions[DIMENSION_HEIGHT]; - } - } - - if (performLayout) { - node.layout.dimensions[DIMENSION_WIDTH] = node.layout.measuredDimensions[DIMENSION_WIDTH]; - node.layout.dimensions[DIMENSION_HEIGHT] = node.layout.measuredDimensions[DIMENSION_HEIGHT]; - node.markHasNewLayout(); - } - - layout.generationCount = layoutContext.currentGenerationCount; - return (needToVisitNode || cachedResults == null); - } - - - // - // 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/. - // - // Limitations of this algorithm, compared to the full standard: - // * Display property is always assumed to be 'flex' except for Text nodes, which - // are assumed to be 'inline-flex'. - // * The 'zIndex' property (or any form of z ordering) is not supported. Nodes are - // stacked in document order. - // * The 'order' property is not supported. The order of flex items is always defined - // by document order. - // * The 'visibility' property is always assumed to be 'visible'. Values of 'collapse' - // and 'hidden' are not supported. - // * The 'wrap' property supports only 'nowrap' (which is the default) or 'wrap'. The - // rarely-used 'wrap-reverse' is not supported. - // * Rather than allowing arbitrary combinations of flexGrow, flexShrink and - // flexBasis, this algorithm supports only the three most common combinations: - // flex: 0 is equiavlent to flex: 0 0 auto - // flex: n (where n is a positive value) is equivalent to flex: n 1 auto - // If POSITIVE_FLEX_IS_AUTO is 0, then it is equivalent to flex: n 0 0 - // This is faster because the content doesn't need to be measured, but it's - // less flexible because the basis is always 0 and can't be overriden with - // the width/height attributes. - // flex: -1 (or any negative value) is equivalent to flex: 0 1 auto - // * Margins cannot be specified as 'auto'. They must be specified in terms of pixel - // values, and the default value is 0. - // * The 'baseline' value is not supported for alignItems and alignSelf properties. - // * Values of width, maxWidth, minWidth, height, maxHeight and minHeight must be - // specified as pixel values, not as percentages. - // * There is no support for calculation of dimensions based on intrinsic aspect ratios - // (e.g. images). - // * There is no support for forced breaks. - // * It does not support vertical inline directions (top-to-bottom or bottom-to-top text). - // - // Deviations from standard: - // * Section 4.5 of the spec indicates that all flex items have a default minimum - // main size. For text blocks, for example, this is the width of the widest word. - // Calculating the minimum width is expensive, so we forego it and assume a default - // minimum main size of 0. - // * Min/Max sizes in the main axis are not honored when resolving flexible lengths. - // * The spec indicates that the default value for 'flexDirection' is 'row', but - // the algorithm below assumes a default of 'column'. - // - // Input parameters: - // - node: current node to be sized and layed out - // - availableWidth & availableHeight: available size to be used for sizing the node - // or CSS_UNDEFINED if the size is not available; interpretation depends on layout - // flags - // - parentDirection: the inline (text) direction within the parent (left-to-right or - // right-to-left) - // - widthMeasureMode: indicates the sizing rules for the width (see below for explanation) - // - heightMeasureMode: indicates the sizing rules for the height (see below for explanation) - // - performLayout: specifies whether the caller is interested in just the dimensions - // of the node or it requires the entire node and its subtree to be layed out - // (with final positions) - // - // Details: - // This routine is called recursively to lay out subtrees of flexbox elements. It uses the - // information in node.style, which is treated as a read-only input. It is responsible for - // setting the layout.direction and layout.measured_dimensions fields for the input node as well - // as the layout.position and layout.line_index fields for its child nodes. The - // layout.measured_dimensions field includes any border or padding for the node but does - // not include margins. - // - // The spec describes four different layout modes: "fill available", "max content", "min content", - // and "fit content". Of these, we don't use "min content" because we don't 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): - // - CSS_MEASURE_MODE_UNDEFINED: max content - // - CSS_MEASURE_MODE_EXACTLY: fill available - // - CSS_MEASURE_MODE_AT_MOST: fit content - // - // When calling layoutNodeImpl and layoutNodeInternal, if the caller passes an available size of - // undefined then it must also pass a measure mode of CSS_MEASURE_MODE_UNDEFINED in that dimension. - // - private static void layoutNodeImpl( - CSSLayoutContext layoutContext, - CSSNodeDEPRECATED node, - float availableWidth, - float availableHeight, - CSSDirection parentDirection, - CSSMeasureMode widthMeasureMode, - CSSMeasureMode heightMeasureMode, - boolean performLayout) { - - Assertions.assertCondition(Float.isNaN(availableWidth) ? widthMeasureMode == CSSMeasureMode.UNDEFINED : true, "availableWidth is indefinite so widthMeasureMode must be CSSMeasureMode.UNDEFINED"); - Assertions.assertCondition(Float.isNaN(availableHeight) ? heightMeasureMode == CSSMeasureMode.UNDEFINED : true, "availableHeight is indefinite so heightMeasureMode must be CSSMeasureMode.UNDEFINED"); - - float paddingAndBorderAxisRow = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]))); - float paddingAndBorderAxisColumn = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]))); - float marginAxisRow = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - float marginAxisColumn = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - - // Set the resolved resolution in the node's layout. - CSSDirection direction = resolveDirection(node, parentDirection); - node.layout.direction = direction; - - // For content (text) nodes, determine the dimensions based on the text contents. - if (isMeasureDefined(node)) { - float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - - if (widthMeasureMode == CSSMeasureMode.EXACTLY && heightMeasureMode == CSSMeasureMode.EXACTLY) { - - // Don't bother sizing the text if both dimensions are already defined. - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, availableWidth - marginAxisRow); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, 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[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, 0); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, 0); - } else { - - // Measure the text under the current constraints. - long measureOutput = node.measure( - innerWidth, - widthMeasureMode, - innerHeight, - heightMeasureMode - ); - - int outputWidth = MeasureOutput.getWidth(measureOutput); - int outputHeight = MeasureOutput.getHeight(measureOutput); - - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, - (widthMeasureMode == CSSMeasureMode.UNDEFINED || widthMeasureMode == CSSMeasureMode.AT_MOST) ? - outputWidth + paddingAndBorderAxisRow : - availableWidth - marginAxisRow); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, - (heightMeasureMode == CSSMeasureMode.UNDEFINED || heightMeasureMode == CSSMeasureMode.AT_MOST) ? - outputHeight + paddingAndBorderAxisColumn : - availableHeight - marginAxisColumn); - } - - return; - } - - // 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. - int childCount = node.getChildCount(); - if (childCount == 0) { - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, - (widthMeasureMode == CSSMeasureMode.UNDEFINED || widthMeasureMode == CSSMeasureMode.AT_MOST) ? - paddingAndBorderAxisRow : - availableWidth - marginAxisRow); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, - (heightMeasureMode == CSSMeasureMode.UNDEFINED || heightMeasureMode == CSSMeasureMode.AT_MOST) ? - paddingAndBorderAxisColumn : - availableHeight - marginAxisColumn); - return; - } - - // If we're not being asked to perform a full layout, we can handle a number of common - // cases here without incurring the cost of the remaining function. - if (!performLayout) { - // If we're being asked to size the content with an at most constraint but there is no available width, - // the measurement will always be zero. - if (widthMeasureMode == CSSMeasureMode.AT_MOST && availableWidth <= 0 && - heightMeasureMode == CSSMeasureMode.AT_MOST && availableHeight <= 0) { - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, 0); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, 0); - return; - } - - if (widthMeasureMode == CSSMeasureMode.AT_MOST && availableWidth <= 0) { - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, 0); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, Float.isNaN(availableHeight) ? 0 : (availableHeight - marginAxisColumn)); - return; - } - - if (heightMeasureMode == CSSMeasureMode.AT_MOST && availableHeight <= 0) { - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, Float.isNaN(availableWidth) ? 0 : (availableWidth - marginAxisRow)); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, 0); - return; - } - - // If we're being asked to use an exact width/height, there's no need to measure the children. - if (widthMeasureMode == CSSMeasureMode.EXACTLY && heightMeasureMode == CSSMeasureMode.EXACTLY) { - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, availableWidth - marginAxisRow); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, availableHeight - marginAxisColumn); - return; - } - } - - // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM - int mainAxis = resolveAxis(getFlexDirection(node), direction); - int crossAxis = getCrossFlexDirection(mainAxis, direction); - boolean isMainAxisRow = (mainAxis == CSS_FLEX_DIRECTION_ROW || mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE); - CSSJustify justifyContent = node.style.justifyContent; - boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.WRAP); - - CSSNodeDEPRECATED firstAbsoluteChild = null; - CSSNodeDEPRECATED currentAbsoluteChild = null; - - float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])); - float trailingPaddingAndBorderMain = (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])); - float leadingPaddingAndBorderCross = (node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])); - float paddingAndBorderAxisMain = ((node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]))); - float paddingAndBorderAxisCross = ((node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (node.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + node.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))); - - CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; - CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - - // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS - float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; - float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; - - // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM - CSSNodeDEPRECATED child; - int i; - float childWidth; - float childHeight; - CSSMeasureMode childWidthMeasureMode; - CSSMeasureMode childHeightMeasureMode; - for (i = 0; i < childCount; i++) { - child = node.getChildAt(i); - - if (performLayout) { - // Set the initial position (relative to the parent). - CSSDirection childDirection = resolveDirection(child, direction); - setPosition(child, childDirection); - } - - // Absolute-positioned children don't participate in flex layout. Add them - // to a list that we can process later. - if (child.style.positionType == CSSPositionType.ABSOLUTE) { - - // Store a private linked list of absolutely positioned children - // so that we can efficiently traverse them later. - if (firstAbsoluteChild == null) { - firstAbsoluteChild = child; - } - if (currentAbsoluteChild != null) { - currentAbsoluteChild.nextChild = child; - } - currentAbsoluteChild = child; - child.nextChild = null; - } else { - - if (isMainAxisRow && (child.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0)) { - - // The width is definite, so use that as the flex basis. - child.layout.computedFlexBasis = Math.max(child.style.dimensions[DIMENSION_WIDTH], ((child.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + child.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) + (child.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]) + child.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])))); - } else if (!isMainAxisRow && (child.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) { - - // The height is definite, so use that as the flex basis. - child.layout.computedFlexBasis = Math.max(child.style.dimensions[DIMENSION_HEIGHT], ((child.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + child.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (child.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + child.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])))); - } else if (!isFlexBasisAuto(child) && !Float.isNaN(availableInnerMainDim)) { - if (Float.isNaN(child.layout.computedFlexBasis)) { - child.layout.computedFlexBasis = Math.max(child.style.flexBasis, ((child.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (child.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + child.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])))); - } - } else { - - // Compute the flex basis and hypothetical main size (i.e. the clamped flex basis). - childWidth = CSSConstants.UNDEFINED; - childHeight = CSSConstants.UNDEFINED; - childWidthMeasureMode = CSSMeasureMode.UNDEFINED; - childHeightMeasureMode = CSSMeasureMode.UNDEFINED; - - if ((child.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0)) { - childWidth = child.style.dimensions[DIMENSION_WIDTH] + (child.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + child.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - childWidthMeasureMode = CSSMeasureMode.EXACTLY; - } - if ((child.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) { - childHeight = child.style.dimensions[DIMENSION_HEIGHT] + (child.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + child.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - childHeightMeasureMode = CSSMeasureMode.EXACTLY; - } - - // The W3C spec doesn't say anything about the 'overflow' property, - // but all major browsers appear to implement the following logic. - if ((!isMainAxisRow && node.style.overflow == CSSOverflow.SCROLL) || node.style.overflow != CSSOverflow.SCROLL) { - if (Float.isNaN(childWidth) && !Float.isNaN(availableInnerWidth)) { - childWidth = availableInnerWidth; - childWidthMeasureMode = CSSMeasureMode.AT_MOST; - } - } - - if ((isMainAxisRow && node.style.overflow == CSSOverflow.SCROLL) || node.style.overflow != CSSOverflow.SCROLL) { - if (Float.isNaN(childHeight) && !Float.isNaN(availableInnerHeight)) { - childHeight = availableInnerHeight; - childHeightMeasureMode = CSSMeasureMode.AT_MOST; - } - } - - // 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 && - !Float.isNaN(availableInnerWidth) && - !(child.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0) && - widthMeasureMode == CSSMeasureMode.EXACTLY && - getAlignItem(node, child) == CSSAlign.STRETCH) { - childWidth = availableInnerWidth; - childWidthMeasureMode = CSSMeasureMode.EXACTLY; - } - if (isMainAxisRow && - !Float.isNaN(availableInnerHeight) && - !(child.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) && - heightMeasureMode == CSSMeasureMode.EXACTLY && - getAlignItem(node, child) == CSSAlign.STRETCH) { - childHeight = availableInnerHeight; - childHeightMeasureMode = CSSMeasureMode.EXACTLY; - } - - // Measure the child - layoutNodeInternal(layoutContext, child, childWidth, childHeight, direction, childWidthMeasureMode, childHeightMeasureMode, false, "measure"); - - child.layout.computedFlexBasis = Math.max(isMainAxisRow ? child.layout.measuredDimensions[DIMENSION_WIDTH] : child.layout.measuredDimensions[DIMENSION_HEIGHT], ((child.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (child.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + child.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])))); - } - } - } - - // STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES - - // Indexes of children that represent the first and last items in the line. - int startOfLineIndex = 0; - int endOfLineIndex = 0; - - // Number of lines. - int lineCount = 0; - - // Accumulated cross dimensions of all lines so far. - float totalLineCrossDim = 0; - - // Max main dimension of all the lines. - float maxLineMainDim = 0; - - while (endOfLineIndex < childCount) { - - // Number of items on the currently line. May be different than the difference - // between start and end indicates because we skip over absolute-positioned items. - int itemsOnLine = 0; - - // sizeConsumedOnCurrentLine is accumulation of the dimensions and margin - // of all the children on the current line. This will be used in order to - // either set the dimensions of the node if none already exist or to compute - // the remaining space left for the flexible children. - float sizeConsumedOnCurrentLine = 0; - - float totalFlexGrowFactors = 0; - float totalFlexShrinkScaledFactors = 0; - - i = startOfLineIndex; - - // Maintain a linked list of the child nodes that can shrink and/or grow. - CSSNodeDEPRECATED firstRelativeChild = null; - CSSNodeDEPRECATED currentRelativeChild = null; - - // Add items to the current line until it's full or we run out of items. - while (i < childCount) { - child = node.getChildAt(i); - child.lineIndex = lineCount; - - if (child.style.positionType != CSSPositionType.ABSOLUTE) { - float outerFlexBasis = child.layout.computedFlexBasis + (child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])); - - // If this is a multi-line flow and this item pushes us over the available size, we've - // hit the end of the current line. Break out of the loop and lay out the current line. - if (sizeConsumedOnCurrentLine + outerFlexBasis > availableInnerMainDim && isNodeFlexWrap && itemsOnLine > 0) { - break; - } - - sizeConsumedOnCurrentLine += outerFlexBasis; - itemsOnLine++; - - if ((child.style.positionType == CSSPositionType.RELATIVE && (child.style.flexGrow != 0 || child.style.flexShrink != 0))) { - totalFlexGrowFactors += getFlexGrowFactor(child); - - // Unlike the grow factor, the shrink factor is scaled relative to the child - // dimension. - totalFlexShrinkScaledFactors += getFlexShrinkFactor(child) * child.layout.computedFlexBasis; - } - - // Store a private linked list of children that need to be layed out. - if (firstRelativeChild == null) { - firstRelativeChild = child; - } - if (currentRelativeChild != null) { - currentRelativeChild.nextChild = child; - } - currentRelativeChild = child; - child.nextChild = null; - } - - i++; - endOfLineIndex++; - } - - // If we don't need to measure the cross axis, we can skip the entire flex step. - boolean canSkipFlex = !performLayout && measureModeCrossDim == CSSMeasureMode.EXACTLY; - - // In order to position the elements in the main axis, we have two - // controls. The space between the beginning and the first element - // and the space between each two elements. - float leadingMainDim = 0; - float betweenMainDim = 0; - - // STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS - // Calculate the remaining available space that needs to be allocated. - // 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 (!Float.isNaN(availableInnerMainDim)) { - remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; - } else if (sizeConsumedOnCurrentLine < 0) { - // availableInnerMainDim is indefinite which means the node is being sized based on its content. - // sizeConsumedOnCurrentLine is negative which means the node will allocate 0 pixels for - // its content. Consequently, remainingFreeSpace is 0 - sizeConsumedOnCurrentLine. - remainingFreeSpace = -sizeConsumedOnCurrentLine; - } - - float originalRemainingFreeSpace = remainingFreeSpace; - float deltaFreeSpace = 0; - - if (!canSkipFlex) { - float childFlexBasis; - float flexShrinkScaledFactor; - float flexGrowFactor; - float baseMainSize; - float boundMainSize; - - // Do two passes over the flex items to figure out how to distribute the remaining space. - // The first pass finds the items whose min/max constraints trigger, freezes them at those - // sizes, and excludes those sizes from the remaining space. The second pass sets the size - // of each flexible item. It distributes the remaining space amongst the items whose min/max - // constraints didn't trigger in pass 1. For the other items, it sets their sizes by forcing - // their min/max constraints to trigger again. - // - // 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) describes a process - // that needs to be repeated a variable number of times. The algorithm implemented here - // won't handle all cases but it was simpler to implement and it mitigates performance - // concerns because we know exactly how many passes it'll do. - - // First pass: detect the flex items whose min/max constraints trigger - float deltaFlexShrinkScaledFactors = 0; - float deltaFlexGrowFactors = 0; - currentRelativeChild = firstRelativeChild; - while (currentRelativeChild != null) { - childFlexBasis = currentRelativeChild.layout.computedFlexBasis; - - if (remainingFreeSpace < 0) { - flexShrinkScaledFactor = getFlexShrinkFactor(currentRelativeChild) * childFlexBasis; - - // Is this child able to shrink? - if (flexShrinkScaledFactor != 0) { - baseMainSize = childFlexBasis + - remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor; - boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize); - if (baseMainSize != boundMainSize) { - // By excluding this item's size and flex factor from remaining, this item's - // min/max constraints should also trigger in the second pass resulting in the - // item's size calculation being identical in the first and second passes. - deltaFreeSpace -= boundMainSize - childFlexBasis; - deltaFlexShrinkScaledFactors -= flexShrinkScaledFactor; - } - } - } else if (remainingFreeSpace > 0) { - flexGrowFactor = getFlexGrowFactor(currentRelativeChild); - - // Is this child able to grow? - if (flexGrowFactor != 0) { - baseMainSize = childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor; - boundMainSize = boundAxis(currentRelativeChild, mainAxis, baseMainSize); - if (baseMainSize != boundMainSize) { - // By excluding this item's size and flex factor from remaining, this item's - // min/max constraints should also trigger in the second pass resulting in the - // item's size calculation being identical in the first and second passes. - deltaFreeSpace -= boundMainSize - childFlexBasis; - deltaFlexGrowFactors -= flexGrowFactor; - } - } - } - - currentRelativeChild = currentRelativeChild.nextChild; - } - - totalFlexShrinkScaledFactors += deltaFlexShrinkScaledFactors; - totalFlexGrowFactors += deltaFlexGrowFactors; - remainingFreeSpace += deltaFreeSpace; - - // Second pass: resolve the sizes of the flexible items - deltaFreeSpace = 0; - currentRelativeChild = firstRelativeChild; - while (currentRelativeChild != null) { - childFlexBasis = currentRelativeChild.layout.computedFlexBasis; - float updatedMainSize = childFlexBasis; - - if (remainingFreeSpace < 0) { - flexShrinkScaledFactor = getFlexShrinkFactor(currentRelativeChild) * childFlexBasis; - - // Is this child able to shrink? - if (flexShrinkScaledFactor != 0) { - updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor); - } - } else if (remainingFreeSpace > 0) { - flexGrowFactor = getFlexGrowFactor(currentRelativeChild); - - // Is this child able to grow? - if (flexGrowFactor != 0) { - updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childFlexBasis + - remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor); - } - } - - deltaFreeSpace -= updatedMainSize - childFlexBasis; - - if (isMainAxisRow) { - childWidth = updatedMainSize + (currentRelativeChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + currentRelativeChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - childWidthMeasureMode = CSSMeasureMode.EXACTLY; - - if (!Float.isNaN(availableInnerCrossDim) && - !(currentRelativeChild.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) && - heightMeasureMode == CSSMeasureMode.EXACTLY && - getAlignItem(node, currentRelativeChild) == CSSAlign.STRETCH) { - childHeight = availableInnerCrossDim; - childHeightMeasureMode = CSSMeasureMode.EXACTLY; - } else if (!(currentRelativeChild.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) { - childHeight = availableInnerCrossDim; - childHeightMeasureMode = Float.isNaN(childHeight) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.AT_MOST; - } else { - childHeight = currentRelativeChild.style.dimensions[DIMENSION_HEIGHT] + (currentRelativeChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + currentRelativeChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - childHeightMeasureMode = CSSMeasureMode.EXACTLY; - } - } else { - childHeight = updatedMainSize + (currentRelativeChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + currentRelativeChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - childHeightMeasureMode = CSSMeasureMode.EXACTLY; - - if (!Float.isNaN(availableInnerCrossDim) && - !(currentRelativeChild.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0) && - widthMeasureMode == CSSMeasureMode.EXACTLY && - getAlignItem(node, currentRelativeChild) == CSSAlign.STRETCH) { - childWidth = availableInnerCrossDim; - childWidthMeasureMode = CSSMeasureMode.EXACTLY; - } else if (!(currentRelativeChild.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0)) { - childWidth = availableInnerCrossDim; - childWidthMeasureMode = Float.isNaN(childWidth) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.AT_MOST; - } else { - childWidth = currentRelativeChild.style.dimensions[DIMENSION_WIDTH] + (currentRelativeChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + currentRelativeChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - childWidthMeasureMode = CSSMeasureMode.EXACTLY; - } - } - - boolean requiresStretchLayout = !(currentRelativeChild.style.dimensions[dim[crossAxis]] >= 0.0) && - getAlignItem(node, currentRelativeChild) == CSSAlign.STRETCH; - - // Recursively call the layout algorithm for this child with the updated main size. - layoutNodeInternal(layoutContext, currentRelativeChild, childWidth, childHeight, direction, childWidthMeasureMode, childHeightMeasureMode, performLayout && !requiresStretchLayout, "flex"); - - currentRelativeChild = currentRelativeChild.nextChild; - } - } - - remainingFreeSpace = originalRemainingFreeSpace + deltaFreeSpace; - - // STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION - - // At this point, all the children have their dimensions set in the main axis. - // Their dimensions are also set in the cross axis with the exception of items - // that are aligned "stretch". We need to compute these stretch values and - // set the final positions. - - // If we are using "at most" rules in the main axis, we won't distribute - // any remaining space at this point. - if (measureModeMainDim == CSSMeasureMode.AT_MOST) { - remainingFreeSpace = 0; - } - - // Use justifyContent to figure out how to allocate the remaining space - // available in the main axis. - if (justifyContent != CSSJustify.FLEX_START) { - if (justifyContent == CSSJustify.CENTER) { - leadingMainDim = remainingFreeSpace / 2; - } else if (justifyContent == CSSJustify.FLEX_END) { - leadingMainDim = remainingFreeSpace; - } else if (justifyContent == CSSJustify.SPACE_BETWEEN) { - remainingFreeSpace = Math.max(remainingFreeSpace, 0); - if (itemsOnLine > 1) { - betweenMainDim = remainingFreeSpace / (itemsOnLine - 1); - } else { - betweenMainDim = 0; - } - } else if (justifyContent == CSSJustify.SPACE_AROUND) { - // Space on the edges is half of the space between elements - betweenMainDim = remainingFreeSpace / itemsOnLine; - leadingMainDim = betweenMainDim / 2; - } - } - - float mainDim = leadingPaddingAndBorderMain + leadingMainDim; - float crossDim = 0; - - for (i = startOfLineIndex; i < endOfLineIndex; ++i) { - child = node.getChildAt(i); - - if (child.style.positionType == CSSPositionType.ABSOLUTE && - !Float.isNaN(child.style.position.getWithFallback(leadingSpacing[mainAxis], leading[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]] = - (Float.isNaN(child.style.position.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) ? - 0 : - child.style.position.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + - node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + - child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]); - } - } else { - if (performLayout) { - // If the child is position absolute (without top/left) or relative, - // we put it at the current accumulated offset. - child.layout.position[pos[mainAxis]] += mainDim; - } - - // Now that we placed the element, we need to update the variables. - // We need to do that only for relative elements. Absolute elements - // do not take part in that phase. - if (child.style.positionType == CSSPositionType.RELATIVE) { - 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 + (child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])) + child.layout.computedFlexBasis; - crossDim = availableInnerCrossDim; - } else { - // The main dimension is the sum of all the elements dimension plus - // the spacing. - mainDim += betweenMainDim + (child.layout.measuredDimensions[dim[mainAxis]] + child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])); - - // The cross dimension is the max of the elements dimension since there - // can only be one element in that cross dimension. - crossDim = Math.max(crossDim, (child.layout.measuredDimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))); - } - } - } - } - - mainDim += trailingPaddingAndBorderMain; - - float containerCrossAxis = availableInnerCrossDim; - if (measureModeCrossDim == CSSMeasureMode.UNDEFINED || measureModeCrossDim == CSSMeasureMode.AT_MOST) { - // Compute the cross axis from the max cross dimension of the children. - containerCrossAxis = boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - paddingAndBorderAxisCross; - - if (measureModeCrossDim == CSSMeasureMode.AT_MOST) { - containerCrossAxis = Math.min(containerCrossAxis, availableInnerCrossDim); - } - } - - // If there's no flex wrap, the cross dimension is defined by the container. - if (!isNodeFlexWrap && measureModeCrossDim == CSSMeasureMode.EXACTLY) { - crossDim = availableInnerCrossDim; - } - - // Clamp to the min/max size specified on the container. - crossDim = boundAxis(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 (i = startOfLineIndex; i < endOfLineIndex; ++i) { - child = node.getChildAt(i); - - if (child.style.positionType == CSSPositionType.ABSOLUTE) { - // 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 (!Float.isNaN(child.style.position.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]))) { - child.layout.position[pos[crossAxis]] = - (Float.isNaN(child.style.position.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) ? - 0 : - child.style.position.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + - node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + - child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]); - } else { - child.layout.position[pos[crossAxis]] = leadingPaddingAndBorderCross + - child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]); - } - } else { - float leadingCrossDim = leadingPaddingAndBorderCross; - - // For a relative children, we're either using alignItems (parent) or - // alignSelf (child) in order to determine the position in the cross axis - CSSAlign alignItem = getAlignItem(node, child); - - // If the child uses align stretch, we need to lay it out one more time, this time - // forcing the cross-axis size to be the computed cross size for the current line. - if (alignItem == CSSAlign.STRETCH) { - childWidth = child.layout.measuredDimensions[DIMENSION_WIDTH] + (child.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + child.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - childHeight = child.layout.measuredDimensions[DIMENSION_HEIGHT] + (child.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + child.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - boolean isCrossSizeDefinite = false; - - if (isMainAxisRow) { - isCrossSizeDefinite = (child.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0); - childHeight = crossDim; - } else { - isCrossSizeDefinite = (child.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0); - childWidth = crossDim; - } - - // If the child defines a definite size for its cross axis, there's no need to stretch. - if (!isCrossSizeDefinite) { - childWidthMeasureMode = Float.isNaN(childWidth) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; - childHeightMeasureMode = Float.isNaN(childHeight) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; - layoutNodeInternal(layoutContext, child, childWidth, childHeight, direction, childWidthMeasureMode, childHeightMeasureMode, true, "stretch"); - } - } else if (alignItem != CSSAlign.FLEX_START) { - float remainingCrossDim = containerCrossAxis - (child.layout.measuredDimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])); - - if (alignItem == CSSAlign.CENTER) { - leadingCrossDim += remainingCrossDim / 2; - } else { // CSSAlign.FLEX_END - leadingCrossDim += remainingCrossDim; - } - } - - // And we apply the position - child.layout.position[pos[crossAxis]] += totalLineCrossDim + leadingCrossDim; - } - } - } - - totalLineCrossDim += crossDim; - maxLineMainDim = Math.max(maxLineMainDim, mainDim); - - // Reset variables for new line. - lineCount++; - startOfLineIndex = endOfLineIndex; - endOfLineIndex = startOfLineIndex; - } - - // STEP 8: MULTI-LINE CONTENT ALIGNMENT - if (lineCount > 1 && performLayout && !Float.isNaN(availableInnerCrossDim)) { - float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim; - - float crossDimLead = 0; - float currentLead = leadingPaddingAndBorderCross; - - CSSAlign alignContent = node.style.alignContent; - if (alignContent == CSSAlign.FLEX_END) { - currentLead += remainingAlignContentDim; - } else if (alignContent == CSSAlign.CENTER) { - currentLead += remainingAlignContentDim / 2; - } else if (alignContent == CSSAlign.STRETCH) { - if (availableInnerCrossDim > totalLineCrossDim) { - crossDimLead = (remainingAlignContentDim / lineCount); - } - } - - int endIndex = 0; - for (i = 0; i < lineCount; ++i) { - int startIndex = endIndex; - int j; - - // compute the line's height and find the endIndex - float lineHeight = 0; - for (j = startIndex; j < childCount; ++j) { - child = node.getChildAt(j); - if (child.style.positionType != CSSPositionType.RELATIVE) { - continue; - } - if (child.lineIndex != i) { - break; - } - if ((child.layout.measuredDimensions[dim[crossAxis]] >= 0.0)) { - lineHeight = Math.max(lineHeight, - child.layout.measuredDimensions[dim[crossAxis]] + (child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))); - } - } - endIndex = j; - lineHeight += crossDimLead; - - if (performLayout) { - for (j = startIndex; j < endIndex; ++j) { - child = node.getChildAt(j); - if (child.style.positionType != CSSPositionType.RELATIVE) { - continue; - } - - CSSAlign alignContentAlignItem = getAlignItem(node, child); - if (alignContentAlignItem == CSSAlign.FLEX_START) { - child.layout.position[pos[crossAxis]] = currentLead + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]); - } else if (alignContentAlignItem == CSSAlign.FLEX_END) { - child.layout.position[pos[crossAxis]] = currentLead + lineHeight - child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) - child.layout.measuredDimensions[dim[crossAxis]]; - } else if (alignContentAlignItem == CSSAlign.CENTER) { - childHeight = child.layout.measuredDimensions[dim[crossAxis]]; - child.layout.position[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2; - } else if (alignContentAlignItem == CSSAlign.STRETCH) { - child.layout.position[pos[crossAxis]] = currentLead + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]); - // TODO(prenaux): Correctly set the height of items with indefinite - // (auto) crossAxis dimension. - } - } - } - - currentLead += lineHeight; - } - } - - // STEP 9: COMPUTING FINAL DIMENSIONS - node.layout.measuredDimensions[DIMENSION_WIDTH] = boundAxis(node, CSS_FLEX_DIRECTION_ROW, availableWidth - marginAxisRow); - node.layout.measuredDimensions[DIMENSION_HEIGHT] = boundAxis(node, CSS_FLEX_DIRECTION_COLUMN, availableHeight - marginAxisColumn); - - // If the user didn't specify a width or height for the node, set the - // dimensions based on the children. - if (measureModeMainDim == CSSMeasureMode.UNDEFINED) { - // 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); - } else if (measureModeMainDim == CSSMeasureMode.AT_MOST) { - node.layout.measuredDimensions[dim[mainAxis]] = Math.max( - Math.min(availableInnerMainDim + paddingAndBorderAxisMain, - boundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), - paddingAndBorderAxisMain); - } - - if (measureModeCrossDim == CSSMeasureMode.UNDEFINED) { - // 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); - } else if (measureModeCrossDim == CSSMeasureMode.AT_MOST) { - node.layout.measuredDimensions[dim[crossAxis]] = Math.max( - Math.min(availableInnerCrossDim + paddingAndBorderAxisCross, - boundAxisWithinMinAndMax(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross)), - paddingAndBorderAxisCross); - } - - // STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN - currentAbsoluteChild = firstAbsoluteChild; - while (currentAbsoluteChild != null) { - // Now that we know the bounds of the container, perform layout again on the - // absolutely-positioned children. - if (performLayout) { - - childWidth = CSSConstants.UNDEFINED; - childHeight = CSSConstants.UNDEFINED; - - if ((currentAbsoluteChild.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0)) { - childWidth = currentAbsoluteChild.style.dimensions[DIMENSION_WIDTH] + (currentAbsoluteChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + currentAbsoluteChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - } else { - // If the child doesn't have a specified width, compute the width based on the left/right offsets if they're defined. - if (!Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) && - !Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]))) { - childWidth = node.layout.measuredDimensions[DIMENSION_WIDTH] - - (node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])) - - ((Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) ? - 0 : - currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) + - (Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])) ? - 0 : - currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]))); - childWidth = boundAxis(currentAbsoluteChild, CSS_FLEX_DIRECTION_ROW, childWidth); - } - } - - if ((currentAbsoluteChild.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) { - childHeight = currentAbsoluteChild.style.dimensions[DIMENSION_HEIGHT] + (currentAbsoluteChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + currentAbsoluteChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - } else { - // If the child doesn't have a specified height, compute the height based on the top/bottom offsets if they're defined. - if (!Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) && - !Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]))) { - childHeight = node.layout.measuredDimensions[DIMENSION_HEIGHT] - - (node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) - - ((Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) ? - 0 : - currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + - (Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) ? - 0 : - currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]))); - childHeight = boundAxis(currentAbsoluteChild, CSS_FLEX_DIRECTION_COLUMN, childHeight); - } - } - - // If we're still missing one or the other dimension, measure the content. - if (Float.isNaN(childWidth) || Float.isNaN(childHeight)) { - childWidthMeasureMode = Float.isNaN(childWidth) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; - childHeightMeasureMode = Float.isNaN(childHeight) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; - - // 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 && Float.isNaN(childWidth) && !Float.isNaN(availableInnerWidth)) { - childWidth = availableInnerWidth; - childWidthMeasureMode = CSSMeasureMode.AT_MOST; - } - - layoutNodeInternal(layoutContext, currentAbsoluteChild, childWidth, childHeight, direction, childWidthMeasureMode, childHeightMeasureMode, false, "abs-measure"); - childWidth = currentAbsoluteChild.layout.measuredDimensions[DIMENSION_WIDTH] + (currentAbsoluteChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + currentAbsoluteChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); - childHeight = currentAbsoluteChild.layout.measuredDimensions[DIMENSION_HEIGHT] + (currentAbsoluteChild.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + currentAbsoluteChild.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - } - - layoutNodeInternal(layoutContext, currentAbsoluteChild, childWidth, childHeight, direction, CSSMeasureMode.EXACTLY, CSSMeasureMode.EXACTLY, true, "abs-layout"); - - if (!Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])) && - Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]))) { - currentAbsoluteChild.layout.position[leading[mainAxis]] = - node.layout.measuredDimensions[dim[mainAxis]] - - currentAbsoluteChild.layout.measuredDimensions[dim[mainAxis]] - - (Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])) ? 0 : currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])); - } - - if (!Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])) && - Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]))) { - currentAbsoluteChild.layout.position[leading[crossAxis]] = - node.layout.measuredDimensions[dim[crossAxis]] - - currentAbsoluteChild.layout.measuredDimensions[dim[crossAxis]] - - (Float.isNaN(currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])) ? 0 : currentAbsoluteChild.style.position.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])); - } - } - - currentAbsoluteChild = currentAbsoluteChild.nextChild; - } - - // STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN - if (performLayout) { - boolean needsMainTrailingPos = false; - boolean needsCrossTrailingPos = false; - - if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || - mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { - needsMainTrailingPos = true; - } - - if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || - crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { - needsCrossTrailingPos = true; - } - - // Set trailing position if necessary. - if (needsMainTrailingPos || needsCrossTrailingPos) { - for (i = 0; i < childCount; ++i) { - child = node.getChildAt(i); - - if (needsMainTrailingPos) { - child.layout.position[trailing[mainAxis]] = - node.layout.measuredDimensions[dim[mainAxis]] - - child.layout.measuredDimensions[dim[mainAxis]] - - child.layout.position[pos[mainAxis]]; - } - - if (needsCrossTrailingPos) { - child.layout.position[trailing[crossAxis]] = - node.layout.measuredDimensions[dim[crossAxis]] - - child.layout.measuredDimensions[dim[crossAxis]] - - child.layout.position[pos[crossAxis]]; - } - } - } - } - } -} diff --git a/java/com/facebook/csslayout/Spacing.java b/java/com/facebook/csslayout/Spacing.java deleted file mode 100644 index 017f9f07..00000000 --- a/java/com/facebook/csslayout/Spacing.java +++ /dev/null @@ -1,190 +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. - */ - -package com.facebook.csslayout; - -import java.util.Arrays; - -/** - * Class representing CSS spacing (padding, margin, and borders). This is mostly necessary to - * properly implement interactions and updates for properties like margin, marginLeft, and - * marginHorizontal. - */ -public class Spacing { - - /** - * Spacing type that represents the left direction. E.g. {@code marginLeft}. - */ - public static final int LEFT = 0; - /** - * Spacing type that represents the top direction. E.g. {@code marginTop}. - */ - public static final int TOP = 1; - /** - * Spacing type that represents the right direction. E.g. {@code marginRight}. - */ - public static final int RIGHT = 2; - /** - * Spacing type that represents the bottom direction. E.g. {@code marginBottom}. - */ - public static final int BOTTOM = 3; - /** - * Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left. - */ - public static final int START = 4; - /** - * Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left. - */ - public static final int END = 5; - /** - * Spacing type that represents horizontal direction (left and right). E.g. - * {@code marginHorizontal}. - */ - public static final int HORIZONTAL = 6; - /** - * Spacing type that represents vertical direction (top and bottom). E.g. {@code marginVertical}. - */ - public static final int VERTICAL = 7; - /** - * Spacing type that represents all directions (left, top, right, bottom). E.g. {@code margin}. - */ - public static final int ALL = 8; - - private static final int[] sFlagsMap = { - 1, /*LEFT*/ - 2, /*TOP*/ - 4, /*RIGHT*/ - 8, /*BOTTOM*/ - 16, /*START*/ - 32, /*END*/ - 64, /*HORIZONTAL*/ - 128, /*VERTICAL*/ - 256, /*ALL*/ - }; - - private final float[] mSpacing = newFullSpacingArray(); - private int mValueFlags = 0; - private float mDefaultValue; - private boolean mHasAliasesSet; - - public Spacing() { - this(0); - } - - public Spacing(float defaultValue) { - mDefaultValue = defaultValue; - } - - /** - * Set a spacing value. - * - * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM}, - * {@link #VERTICAL}, {@link #HORIZONTAL}, {@link #ALL} - * @param value the value for this direction - * @return {@code true} if the spacing has changed, or {@code false} if the same value was already - * set - */ - public boolean set(int spacingType, float value) { - if (!FloatUtil.floatsEqual(mSpacing[spacingType], value)) { - mSpacing[spacingType] = value; - - if (CSSConstants.isUndefined(value)) { - mValueFlags &= ~sFlagsMap[spacingType]; - } else { - mValueFlags |= sFlagsMap[spacingType]; - } - - mHasAliasesSet = - (mValueFlags & sFlagsMap[ALL]) != 0 || - (mValueFlags & sFlagsMap[VERTICAL]) != 0 || - (mValueFlags & sFlagsMap[HORIZONTAL]) != 0; - - return true; - } - - return false; - } - - /** - * Get the spacing for a direction. This takes into account any default values that have been set. - * - * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM} - */ - public float get(int spacingType) { - float defaultValue = (spacingType == START || spacingType == END - ? CSSConstants.UNDEFINED - : mDefaultValue); - - if (mValueFlags == 0) { - return defaultValue; - } - - if ((mValueFlags & sFlagsMap[spacingType]) != 0) { - return mSpacing[spacingType]; - } - - if (mHasAliasesSet) { - int secondType = spacingType == TOP || spacingType == BOTTOM ? VERTICAL : HORIZONTAL; - if ((mValueFlags & sFlagsMap[secondType]) != 0) { - return mSpacing[secondType]; - } else if ((mValueFlags & sFlagsMap[ALL]) != 0) { - return mSpacing[ALL]; - } - } - - return defaultValue; - } - - /** - * Get the raw value (that was set using {@link #set(int, float)}), without taking into account - * any default values. - * - * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM}, - * {@link #VERTICAL}, {@link #HORIZONTAL}, {@link #ALL} - */ - public float getRaw(int spacingType) { - return mSpacing[spacingType]; - } - - /** - * Resets the spacing instance to its default state. This method is meant to be used when - * recycling {@link Spacing} instances. - */ - public void reset() { - Arrays.fill(mSpacing, CSSConstants.UNDEFINED); - mHasAliasesSet = false; - mValueFlags = 0; - } - - /** - * Try to get start value and fallback to given type if not defined. This is used privately - * by the layout engine as a more efficient way to fetch direction-aware values by - * avoid extra method invocations. - */ - float getWithFallback(int spacingType, int fallbackType) { - return - (mValueFlags & sFlagsMap[spacingType]) != 0 - ? mSpacing[spacingType] - : get(fallbackType); - } - - private static float[] newFullSpacingArray() { - return new float[] { - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - CSSConstants.UNDEFINED, - }; - } -} diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index 0d10ee41..78f42abc 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -24,13 +24,13 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10f); - root_child0.setPosition(Spacing.TOP, 10f); + root_child0.setPosition(CSSEdge.START, 10f); + root_child0.setPosition(CSSEdge.TOP, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -43,7 +43,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -64,13 +64,13 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.END, 10f); - root_child0.setPosition(Spacing.BOTTOM, 10f); + root_child0.setPosition(CSSEdge.END, 10f); + root_child0.setPosition(CSSEdge.BOTTOM, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -83,7 +83,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -104,13 +104,13 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10f); - root_child0.setPosition(Spacing.TOP, 10f); - root_child0.setPosition(Spacing.END, 10f); - root_child0.setPosition(Spacing.BOTTOM, 10f); + root_child0.setPosition(CSSEdge.START, 10f); + root_child0.setPosition(CSSEdge.TOP, 10f); + root_child0.setPosition(CSSEdge.END, 10f); + root_child0.setPosition(CSSEdge.BOTTOM, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -123,7 +123,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -144,15 +144,15 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 10f); - root_child0.setPosition(Spacing.TOP, 10f); - root_child0.setPosition(Spacing.END, 10f); - root_child0.setPosition(Spacing.BOTTOM, 10f); + root_child0.setPosition(CSSEdge.START, 10f); + root_child0.setPosition(CSSEdge.TOP, 10f); + root_child0.setPosition(CSSEdge.END, 10f); + root_child0.setPosition(CSSEdge.BOTTOM, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -165,7 +165,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -188,8 +188,8 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.START, 0f); - root_child0.setPosition(Spacing.TOP, 0f); + root_child0.setPosition(CSSEdge.START, 0f); + root_child0.setPosition(CSSEdge.TOP, 0f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); @@ -197,7 +197,7 @@ public class CSSLayoutAbsolutePositionTest { root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -215,7 +215,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -236,38 +236,38 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_within_border() { final CSSNode root = new CSSNode(); - root.setMargin(Spacing.LEFT, 10f); - root.setMargin(Spacing.TOP, 10f); - root.setMargin(Spacing.RIGHT, 10f); - root.setMargin(Spacing.BOTTOM, 10f); - root.setPadding(Spacing.LEFT, 10); - root.setPadding(Spacing.TOP, 10); - root.setPadding(Spacing.RIGHT, 10); - root.setPadding(Spacing.BOTTOM, 10); - root.setBorder(Spacing.LEFT, 10f); - root.setBorder(Spacing.TOP, 10f); - root.setBorder(Spacing.RIGHT, 10f); - root.setBorder(Spacing.BOTTOM, 10f); + root.setMargin(CSSEdge.LEFT, 10f); + root.setMargin(CSSEdge.TOP, 10f); + root.setMargin(CSSEdge.RIGHT, 10f); + root.setMargin(CSSEdge.BOTTOM, 10f); + root.setPadding(CSSEdge.LEFT, 10); + root.setPadding(CSSEdge.TOP, 10); + root.setPadding(CSSEdge.RIGHT, 10); + root.setPadding(CSSEdge.BOTTOM, 10); + root.setBorder(CSSEdge.LEFT, 10f); + root.setBorder(CSSEdge.TOP, 10f); + root.setBorder(CSSEdge.RIGHT, 10f); + root.setBorder(CSSEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(Spacing.LEFT, 0f); - root_child0.setPosition(Spacing.TOP, 0f); + root_child0.setPosition(CSSEdge.LEFT, 0f); + root_child0.setPosition(CSSEdge.TOP, 0f); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); root_child1.setPositionType(CSSPositionType.ABSOLUTE); - root_child1.setPosition(Spacing.RIGHT, 0f); - root_child1.setPosition(Spacing.BOTTOM, 0f); + root_child1.setPosition(CSSEdge.RIGHT, 0f); + root_child1.setPosition(CSSEdge.BOTTOM, 0f); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(10f, root.getLayoutX(), 0.0f); assertEquals(10f, root.getLayoutY(), 0.0f); @@ -285,7 +285,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(10f, root.getLayoutX(), 0.0f); assertEquals(10f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java index c4cb8c87..45a6d49e 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java @@ -48,7 +48,7 @@ public class CSSLayoutAlignContentTest { root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -81,7 +81,7 @@ public class CSSLayoutAlignContentTest { assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -147,7 +147,7 @@ public class CSSLayoutAlignContentTest { root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -180,7 +180,7 @@ public class CSSLayoutAlignContentTest { assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -246,7 +246,7 @@ public class CSSLayoutAlignContentTest { root_child4.setHeight(10f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -279,7 +279,7 @@ public class CSSLayoutAlignContentTest { assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -340,7 +340,7 @@ public class CSSLayoutAlignContentTest { root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -373,7 +373,7 @@ public class CSSLayoutAlignContentTest { assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java index 1ddeb33a..ce29f740 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java @@ -26,7 +26,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -39,7 +39,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -64,7 +64,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -77,7 +77,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -102,7 +102,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -115,7 +115,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -140,7 +140,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -153,7 +153,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java index 4a2e8fa3..c2ae50e2 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java @@ -28,7 +28,7 @@ public class CSSLayoutAlignSelfTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -41,7 +41,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -66,7 +66,7 @@ public class CSSLayoutAlignSelfTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -79,7 +79,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -104,7 +104,7 @@ public class CSSLayoutAlignSelfTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -117,7 +117,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -143,7 +143,7 @@ public class CSSLayoutAlignSelfTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -156,7 +156,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java index 95a6a26a..3acd73fa 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java @@ -19,12 +19,12 @@ public class CSSLayoutBorderTest { @Test public void test_border_no_size() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10f); - root.setBorder(Spacing.TOP, 10f); - root.setBorder(Spacing.RIGHT, 10f); - root.setBorder(Spacing.BOTTOM, 10f); + root.setBorder(CSSEdge.LEFT, 10f); + root.setBorder(CSSEdge.TOP, 10f); + root.setBorder(CSSEdge.RIGHT, 10f); + root.setBorder(CSSEdge.BOTTOM, 10f); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -32,7 +32,7 @@ public class CSSLayoutBorderTest { assertEquals(20f, root.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -43,17 +43,17 @@ public class CSSLayoutBorderTest { @Test public void test_border_container_match_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10f); - root.setBorder(Spacing.TOP, 10f); - root.setBorder(Spacing.RIGHT, 10f); - root.setBorder(Spacing.BOTTOM, 10f); + root.setBorder(CSSEdge.LEFT, 10f); + root.setBorder(CSSEdge.TOP, 10f); + root.setBorder(CSSEdge.RIGHT, 10f); + root.setBorder(CSSEdge.BOTTOM, 10f); final CSSNode root_child0 = new CSSNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -66,7 +66,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -82,10 +82,10 @@ public class CSSLayoutBorderTest { @Test public void test_border_flex_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10f); - root.setBorder(Spacing.TOP, 10f); - root.setBorder(Spacing.RIGHT, 10f); - root.setBorder(Spacing.BOTTOM, 10f); + root.setBorder(CSSEdge.LEFT, 10f); + root.setBorder(CSSEdge.TOP, 10f); + root.setBorder(CSSEdge.RIGHT, 10f); + root.setBorder(CSSEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); @@ -94,7 +94,7 @@ public class CSSLayoutBorderTest { root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -107,7 +107,7 @@ public class CSSLayoutBorderTest { assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -123,10 +123,10 @@ public class CSSLayoutBorderTest { @Test public void test_border_stretch_child() { final CSSNode root = new CSSNode(); - root.setBorder(Spacing.LEFT, 10f); - root.setBorder(Spacing.TOP, 10f); - root.setBorder(Spacing.RIGHT, 10f); - root.setBorder(Spacing.BOTTOM, 10f); + root.setBorder(CSSEdge.LEFT, 10f); + root.setBorder(CSSEdge.TOP, 10f); + root.setBorder(CSSEdge.RIGHT, 10f); + root.setBorder(CSSEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); @@ -134,7 +134,7 @@ public class CSSLayoutBorderTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -147,7 +147,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -165,9 +165,9 @@ public class CSSLayoutBorderTest { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); root.setAlignItems(CSSAlign.CENTER); - root.setBorder(Spacing.START, 10f); - root.setBorder(Spacing.END, 20f); - root.setBorder(Spacing.BOTTOM, 20f); + root.setBorder(CSSEdge.START, 10f); + root.setBorder(CSSEdge.END, 20f); + root.setBorder(CSSEdge.BOTTOM, 20f); root.setWidth(100f); root.setHeight(100f); @@ -176,7 +176,7 @@ public class CSSLayoutBorderTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -189,7 +189,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java index fd7ff970..fad52543 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java @@ -33,7 +33,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -56,7 +56,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -97,7 +97,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -120,7 +120,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -161,7 +161,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -184,7 +184,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -226,7 +226,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -249,7 +249,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -291,7 +291,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -314,7 +314,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -356,7 +356,7 @@ public class CSSLayoutFlexDirectionTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -379,7 +379,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java index 4cfd6fb9..a9421f35 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java @@ -31,7 +31,7 @@ public class CSSLayoutFlexTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -49,7 +49,7 @@ public class CSSLayoutFlexTest { assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -83,7 +83,7 @@ public class CSSLayoutFlexTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -101,7 +101,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -134,7 +134,7 @@ public class CSSLayoutFlexTest { root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -152,7 +152,7 @@ public class CSSLayoutFlexTest { assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -186,7 +186,7 @@ public class CSSLayoutFlexTest { root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -204,7 +204,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -243,7 +243,7 @@ public class CSSLayoutFlexTest { root_child2.setHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -266,7 +266,7 @@ public class CSSLayoutFlexTest { assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -311,7 +311,7 @@ public class CSSLayoutFlexTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -334,7 +334,7 @@ public class CSSLayoutFlexTest { assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -371,7 +371,7 @@ public class CSSLayoutFlexTest { root_child0_child0.setFlexShrink(1f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -389,7 +389,7 @@ public class CSSLayoutFlexTest { assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java index a4090a87..c0850c1c 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java @@ -42,7 +42,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -70,7 +70,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -125,7 +125,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -153,7 +153,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -209,7 +209,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -237,7 +237,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -293,7 +293,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setHeight(30f); root.addChildAt(root_child3, 3); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -321,7 +321,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java index 3bb94f6d..310c31c3 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java @@ -35,7 +35,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -58,7 +58,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -101,7 +101,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -124,7 +124,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -167,7 +167,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -190,7 +190,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -233,7 +233,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -256,7 +256,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -299,7 +299,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -322,7 +322,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -362,7 +362,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -385,7 +385,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -427,7 +427,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -450,7 +450,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -492,7 +492,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -515,7 +515,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -557,7 +557,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -580,7 +580,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -622,7 +622,7 @@ public class CSSLayoutJustifyContentTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -645,7 +645,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java index adfd56e1..63a07584 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java @@ -24,11 +24,11 @@ public class CSSLayoutMarginTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.START, 10f); + root_child0.setMargin(CSSEdge.START, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -41,7 +41,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -61,11 +61,11 @@ public class CSSLayoutMarginTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.TOP, 10f); + root_child0.setMargin(CSSEdge.TOP, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -78,7 +78,7 @@ public class CSSLayoutMarginTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -100,11 +100,11 @@ public class CSSLayoutMarginTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.END, 10f); + root_child0.setMargin(CSSEdge.END, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -117,7 +117,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -138,11 +138,11 @@ public class CSSLayoutMarginTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(Spacing.BOTTOM, 10f); + root_child0.setMargin(CSSEdge.BOTTOM, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -155,7 +155,7 @@ public class CSSLayoutMarginTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -177,10 +177,10 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(Spacing.START, 10f); + root_child0.setMargin(CSSEdge.START, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -193,7 +193,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -214,10 +214,10 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(Spacing.TOP, 10f); + root_child0.setMargin(CSSEdge.TOP, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -230,7 +230,7 @@ public class CSSLayoutMarginTest { assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -252,10 +252,10 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(Spacing.TOP, 10f); + root_child0.setMargin(CSSEdge.TOP, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -268,7 +268,7 @@ public class CSSLayoutMarginTest { assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -289,10 +289,10 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(Spacing.START, 10f); + root_child0.setMargin(CSSEdge.START, 10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -305,7 +305,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -333,7 +333,7 @@ public class CSSLayoutMarginTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -351,7 +351,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -383,7 +383,7 @@ public class CSSLayoutMarginTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -401,7 +401,7 @@ public class CSSLayoutMarginTest { assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index e3bd448a..56f34d61 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -27,7 +27,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -40,7 +40,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -65,7 +65,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setMaxHeight(50f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -78,7 +78,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -106,7 +106,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -124,7 +124,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -158,7 +158,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -176,7 +176,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -207,7 +207,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -220,7 +220,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -246,7 +246,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setHeight(60f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -259,7 +259,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -294,7 +294,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child2.setHeight(50f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -317,7 +317,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -356,7 +356,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -374,7 +374,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -408,7 +408,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -426,7 +426,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java index f1031b97..42126794 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java @@ -19,12 +19,12 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_no_size() { final CSSNode root = new CSSNode(); - root.setPadding(Spacing.LEFT, 10); - root.setPadding(Spacing.TOP, 10); - root.setPadding(Spacing.RIGHT, 10); - root.setPadding(Spacing.BOTTOM, 10); + root.setPadding(CSSEdge.LEFT, 10); + root.setPadding(CSSEdge.TOP, 10); + root.setPadding(CSSEdge.RIGHT, 10); + root.setPadding(CSSEdge.BOTTOM, 10); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -32,7 +32,7 @@ public class CSSLayoutPaddingTest { assertEquals(20f, root.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -43,17 +43,17 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_container_match_child() { final CSSNode root = new CSSNode(); - root.setPadding(Spacing.LEFT, 10); - root.setPadding(Spacing.TOP, 10); - root.setPadding(Spacing.RIGHT, 10); - root.setPadding(Spacing.BOTTOM, 10); + root.setPadding(CSSEdge.LEFT, 10); + root.setPadding(CSSEdge.TOP, 10); + root.setPadding(CSSEdge.RIGHT, 10); + root.setPadding(CSSEdge.BOTTOM, 10); final CSSNode root_child0 = new CSSNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -66,7 +66,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -82,10 +82,10 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_flex_child() { final CSSNode root = new CSSNode(); - root.setPadding(Spacing.LEFT, 10); - root.setPadding(Spacing.TOP, 10); - root.setPadding(Spacing.RIGHT, 10); - root.setPadding(Spacing.BOTTOM, 10); + root.setPadding(CSSEdge.LEFT, 10); + root.setPadding(CSSEdge.TOP, 10); + root.setPadding(CSSEdge.RIGHT, 10); + root.setPadding(CSSEdge.BOTTOM, 10); root.setWidth(100f); root.setHeight(100f); @@ -94,7 +94,7 @@ public class CSSLayoutPaddingTest { root_child0.setWidth(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -107,7 +107,7 @@ public class CSSLayoutPaddingTest { assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -123,10 +123,10 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_stretch_child() { final CSSNode root = new CSSNode(); - root.setPadding(Spacing.LEFT, 10); - root.setPadding(Spacing.TOP, 10); - root.setPadding(Spacing.RIGHT, 10); - root.setPadding(Spacing.BOTTOM, 10); + root.setPadding(CSSEdge.LEFT, 10); + root.setPadding(CSSEdge.TOP, 10); + root.setPadding(CSSEdge.RIGHT, 10); + root.setPadding(CSSEdge.BOTTOM, 10); root.setWidth(100f); root.setHeight(100f); @@ -134,7 +134,7 @@ public class CSSLayoutPaddingTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -147,7 +147,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -165,9 +165,9 @@ public class CSSLayoutPaddingTest { final CSSNode root = new CSSNode(); root.setJustifyContent(CSSJustify.CENTER); root.setAlignItems(CSSAlign.CENTER); - root.setPadding(Spacing.START, 10); - root.setPadding(Spacing.END, 20); - root.setPadding(Spacing.BOTTOM, 20); + root.setPadding(CSSEdge.START, 10); + root.setPadding(CSSEdge.END, 20); + root.setPadding(CSSEdge.BOTTOM, 20); root.setWidth(100f); root.setHeight(100f); @@ -176,7 +176,7 @@ public class CSSLayoutPaddingTest { root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -189,7 +189,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java index e32e70c2..17587908 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java @@ -37,7 +37,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -60,7 +60,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -114,7 +114,7 @@ public class CSSLayoutRoundingTest { root_child4.setFlexGrow(1f); root.addChildAt(root_child4, 4); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -147,7 +147,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -204,7 +204,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexBasis(25f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -227,7 +227,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -276,7 +276,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -299,7 +299,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -348,7 +348,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -371,7 +371,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -413,14 +413,14 @@ public class CSSLayoutRoundingTest { final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0.3f); - root_child0_child0.setPosition(Spacing.BOTTOM, 13.3f); + root_child0_child0.setPosition(CSSEdge.BOTTOM, 13.3f); root_child0_child0.setHeight(9.9f); root_child0.addChildAt(root_child0_child0, 0); final CSSNode root_child0_child1 = new CSSNode(); root_child0_child1.setFlexGrow(4f); root_child0_child1.setFlexBasis(0.3f); - root_child0_child1.setPosition(Spacing.TOP, 13.3f); + root_child0_child1.setPosition(CSSEdge.TOP, 13.3f); root_child0_child1.setHeight(1.1f); root_child0.addChildAt(root_child0_child1, 1); @@ -434,7 +434,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -467,7 +467,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -526,7 +526,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -549,7 +549,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -598,7 +598,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -621,7 +621,7 @@ public class CSSLayoutRoundingTest { assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -651,7 +651,7 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setPosition(Spacing.TOP, 0.3f); + root.setPosition(CSSEdge.TOP, 0.3f); root.setWidth(100f); root.setHeight(113.4f); @@ -671,7 +671,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -694,7 +694,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f); @@ -724,7 +724,7 @@ public class CSSLayoutRoundingTest { CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setPosition(Spacing.TOP, 0.7f); + root.setPosition(CSSEdge.TOP, 0.7f); root.setWidth(100f); root.setHeight(113.4f); @@ -744,7 +744,7 @@ public class CSSLayoutRoundingTest { root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(CSSDirection.LTR); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(1f, root.getLayoutY(), 0.0f); @@ -767,7 +767,7 @@ public class CSSLayoutRoundingTest { assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); root.setDirection(CSSDirection.RTL); - root.calculateLayout(null); + root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); assertEquals(1f, root.getLayoutY(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index 7e65a301..48abed92 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -36,7 +36,7 @@ public class CSSNodeTest { return MeasureOutput.make(100, 100); } }); - node.calculateLayout(null); + node.calculateLayout(); assertEquals(100, (int) node.getLayoutWidth()); assertEquals(100, (int) node.getLayoutHeight()); } From 7d74e1cb66fe823d990d1f1c508dbd6459d9c260 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 29 Nov 2016 16:11:41 -0800 Subject: [PATCH 082/108] Add test case covering padding on child Summary: Add coverage exposed by https://github.com/facebook/css-layout/pull/262 Reviewed By: splhack Differential Revision: D4247282 fbshipit-source-id: 25500bcfced58a8095665b73eeebca8d1c266a17 --- .../CSSLayoutPaddingTest.cs | 44 +++++++++++++++++++ gentest/fixtures/CSSLayoutPaddingTest.html | 4 ++ .../csslayout/CSSLayoutPaddingTest.java | 43 ++++++++++++++++++ tests/CSSLayoutPaddingTest.cpp | 42 ++++++++++++++++++ 4 files changed, 133 insertions(+) diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs index 7712b8af..02a5fa15 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs @@ -208,5 +208,49 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutHeight); } + [Test] + public void Test_child_with_padding_align_end() + { + CSSNode root = new CSSNode(); + root.JustifyContent = CSSJustify.FlexEnd; + root.AlignItems = CSSAlign.FlexEnd; + root.Width = 200f; + root.Height = 200f; + + CSSNode root_child0 = new CSSNode(); + root_child0.SetPadding(CSSEdge.Left, 20f); + root_child0.SetPadding(CSSEdge.Top, 20f); + root_child0.SetPadding(CSSEdge.Right, 20f); + root_child0.SetPadding(CSSEdge.Bottom, 20f); + root_child0.Width = 100f; + root_child0.Height = 100f; + root.Insert(0, root_child0); + root.StyleDirection = CSSDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(100f, root_child0.LayoutX); + Assert.AreEqual(100f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + root.StyleDirection = CSSDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(100f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + } + } } diff --git a/gentest/fixtures/CSSLayoutPaddingTest.html b/gentest/fixtures/CSSLayoutPaddingTest.html index 1f679780..f1616fe4 100644 --- a/gentest/fixtures/CSSLayoutPaddingTest.html +++ b/gentest/fixtures/CSSLayoutPaddingTest.html @@ -16,3 +16,7 @@
+ +
+
+
diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java index 42126794..f837953f 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java @@ -202,4 +202,47 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_child_with_padding_align_end() { + final CSSNode root = new CSSNode(); + root.setJustifyContent(CSSJustify.FLEX_END); + root.setAlignItems(CSSAlign.FLEX_END); + root.setWidth(200f); + root.setHeight(200f); + + final CSSNode root_child0 = new CSSNode(); + root_child0.setPadding(CSSEdge.LEFT, 20); + root_child0.setPadding(CSSEdge.TOP, 20); + root_child0.setPadding(CSSEdge.RIGHT, 20); + root_child0.setPadding(CSSEdge.BOTTOM, 20); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + root.setDirection(CSSDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(CSSDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + } diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 808d8186..355c7d3c 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -192,3 +192,45 @@ TEST(CSSLayoutTest, padding_center_child) { CSSNodeFreeRecursive(root); } + +TEST(CSSLayoutTest, child_with_padding_align_end) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); + CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); + CSSNodeStyleSetWidth(root, 200); + CSSNodeStyleSetHeight(root, 200); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetPadding(root_child0, CSSEdgeLeft, 20); + CSSNodeStyleSetPadding(root_child0, CSSEdgeTop, 20); + CSSNodeStyleSetPadding(root_child0, CSSEdgeRight, 20); + CSSNodeStyleSetPadding(root_child0, CSSEdgeBottom, 20); + CSSNodeStyleSetWidth(root_child0, 100); + CSSNodeStyleSetHeight(root_child0, 100); + CSSNodeInsertChild(root, root_child0, 0); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + 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(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)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + 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, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeFreeRecursive(root); +} From 684a36d6cf5b5db504b4a8e64688bc656f4c8bef Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 03:22:09 -0800 Subject: [PATCH 083/108] Add -fPIC to jni target Summary: Add compile flag from CSSLayout to jni target as well Reviewed By: passy Differential Revision: D4248473 fbshipit-source-id: 18a163a3daedc56e98c7bdc38e10fc8626999f94 --- java/BUCK | 1 + 1 file changed, 1 insertion(+) diff --git a/java/BUCK b/java/BUCK index 25f55852..6cd85703 100644 --- a/java/BUCK +++ b/java/BUCK @@ -15,6 +15,7 @@ cxx_library( compiler_flags = [ '-fno-omit-frame-pointer', '-fexceptions', + '-fPIC', '-Wall', '-Werror', '-O3', From ff3d2e16913dbe2d5116ae8f7c2939bd6dbc0516 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 08:00:12 -0800 Subject: [PATCH 084/108] Rename defs file Summary: new name Reviewed By: gkassabli Differential Revision: D4245638 fbshipit-source-id: 14050d02c4298014a5fcadd75c4f364537ec2396 --- BUCK | 2 +- CSSLayoutKit/BUCK | 2 +- CSSLAYOUT_DEFS => YOGA_DEFS | 0 benchmark/BUCK | 2 +- java/BUCK | 2 +- java/com/facebook/proguard/annotations/BUCK | 2 +- lib/fb/BUCK | 2 +- lib/gtest/BUCK | 2 +- lib/infer-annotations/BUCK | 2 +- lib/jsr-305/BUCK | 2 +- lib/junit/BUCK | 2 +- lib/soloader/BUCK | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename CSSLAYOUT_DEFS => YOGA_DEFS (100%) diff --git a/BUCK b/BUCK index 78dd806d..d6a6b246 100644 --- a/BUCK +++ b/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') BASE_COMPILER_FLAGS = [ '-fno-omit-frame-pointer', diff --git a/CSSLayoutKit/BUCK b/CSSLayoutKit/BUCK index 2f9f570c..224d68b7 100644 --- a/CSSLayoutKit/BUCK +++ b/CSSLayoutKit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ '-fobjc-arc', diff --git a/CSSLAYOUT_DEFS b/YOGA_DEFS similarity index 100% rename from CSSLAYOUT_DEFS rename to YOGA_DEFS diff --git a/benchmark/BUCK b/benchmark/BUCK index 918600b2..4fafe0df 100644 --- a/benchmark/BUCK +++ b/benchmark/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') cxx_binary( name = 'benchmark', diff --git a/java/BUCK b/java/BUCK index 6cd85703..1588edd4 100644 --- a/java/BUCK +++ b/java/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') cxx_library( name = 'jni', diff --git a/java/com/facebook/proguard/annotations/BUCK b/java/com/facebook/proguard/annotations/BUCK index f9bfb1a5..86f1b22f 100644 --- a/java/com/facebook/proguard/annotations/BUCK +++ b/java/com/facebook/proguard/annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') java_library( name = 'annotations', diff --git a/lib/fb/BUCK b/lib/fb/BUCK index ea3fa8c3..dfec53fc 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_cxx_library( name = 'ndklog', diff --git a/lib/gtest/BUCK b/lib/gtest/BUCK index d2e136b9..c5a6d790 100644 --- a/lib/gtest/BUCK +++ b/lib/gtest/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') COMPILER_FLAGS = [ '-std=c++11', diff --git a/lib/infer-annotations/BUCK b/lib/infer-annotations/BUCK index 313f9e5c..c826e879 100644 --- a/lib/infer-annotations/BUCK +++ b/lib/infer-annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'infer-annotations-jar', diff --git a/lib/jsr-305/BUCK b/lib/jsr-305/BUCK index c3f74727..ae663727 100644 --- a/lib/jsr-305/BUCK +++ b/lib/jsr-305/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'jsr305-jar', diff --git a/lib/junit/BUCK b/lib/junit/BUCK index e35b0533..9b26fd30 100644 --- a/lib/junit/BUCK +++ b/lib/junit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'junit-jar', diff --git a/lib/soloader/BUCK b/lib/soloader/BUCK index 8a9ce0a8..077b4fca 100644 --- a/lib/soloader/BUCK +++ b/lib/soloader/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') android_prebuilt_aar( name = 'soloader', From 4fbe0495b474da44d9eca7d33a36ad516863af03 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 08:16:42 -0800 Subject: [PATCH 085/108] Remove force_static Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true Reviewed By: gkassabli Differential Revision: D4248487 fbshipit-source-id: e5127a02561b145745cf5393a0188661469ec79b --- BUCK | 5 +++-- YOGA_DEFS | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BUCK b/BUCK index d6a6b246..e74a0a6e 100644 --- a/BUCK +++ b/BUCK @@ -29,9 +29,10 @@ cxx_library( tests=[':tests'], exported_headers = subdir_glob([('', 'CSSLayout/*.h')]), header_namespace = '', - force_static = True, compiler_flags = COMPILER_FLAGS, - deps = [], + deps = [] if THIS_IS_FBOBJC else [ + csslayout_dep('lib/fb:ndklog'), + ], visibility = ['PUBLIC'], ) diff --git a/YOGA_DEFS b/YOGA_DEFS index 91d372ab..2b4a62c5 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -9,7 +9,10 @@ GTEST_TARGET = '//lib/gtest:gtest' JNI_TARGET = '//lib/jni:jni' FBJNI_TARGET = '//lib/fb:fbjni' +THIS_IS_FBOBJC = False + CXX_LIBRARY_WHITELIST = [ + '//:CSSLayout', '//lib/fb:fbjni', '//java:jni', ] From c5bbcd78ae602be480be468a923bb0b7ee8eb7d6 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 10:07:53 -0800 Subject: [PATCH 086/108] Fix usage of weak references to check for null Summary: In case the java object has been GCed during layout calculation we will crash if we try to call a method on the now invalid weak pointer. Use fbjni weak_ref to skip calling to java when the java object does not exist any more. Reviewed By: lexs Differential Revision: D4251133 fbshipit-source-id: 2d8949252b31447ce54bc16a35cb25fabe72230b --- java/jni/CSSJNI.cpp | 78 ++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index b5543390..67946869 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -14,35 +14,42 @@ 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) { - auto javaNode = adopt_local( - Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(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"); - static auto widthField = javaNode->getClass()->getField("mWidth"); - static auto heightField = javaNode->getClass()->getField("mHeight"); - static auto leftField = javaNode->getClass()->getField("mLeft"); - static auto topField = javaNode->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); - javaNode->setFieldValue(widthField, CSSNodeLayoutGetWidth(root)); - javaNode->setFieldValue(heightField, CSSNodeLayoutGetHeight(root)); - javaNode->setFieldValue(leftField, CSSNodeLayoutGetLeft(root)); - javaNode->setFieldValue(topField, CSSNodeLayoutGetTop(root)); - _jniTransferLayoutDirection(root, javaNode); - - for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) { - _jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i)); + for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) { + _jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i)); + } + } else { + CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); } } static void _jniPrint(CSSNodeRef node) { - auto obj = adopt_local( - Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); - cout << obj->toString() << endl; + if (auto obj = jobjectContext(node)->lockLocal()) { + cout << obj->toString() << endl; + } else { + CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); + } } static CSSSize _jniMeasureFunc(CSSNodeRef node, @@ -50,22 +57,27 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - auto obj = adopt_local( - Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); + if (auto obj = jobjectContext(node)->lockLocal()) { + static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") + ->getMethod("measure"); - static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") - ->getMethod("measure"); + _jniTransferLayoutDirection(node, obj); + const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); - _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"); - 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); - const float measuredWidth = static_cast(0xFFFFFFFF & (measureResult >> 32)); - const float measuredHeight = static_cast(0xFFFFFFFF & measureResult); - - return CSSSize{measuredWidth, measuredHeight}; + return CSSSize{measuredWidth, measuredHeight}; + } else { + CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); + return CSSSize{ + widthMode == CSSMeasureModeUndefined ? 0 : width, + heightMode == CSSMeasureModeUndefined ? 0 : height, + }; + } } struct JCSSLogLevel : public JavaClass { @@ -131,15 +143,15 @@ jint jni_CSSNodeGetInstanceCount(alias_ref clazz) { jlong jni_CSSNodeNew(alias_ref thiz) { const CSSNodeRef node = CSSNodeNew(); - CSSNodeSetContext(node, Environment::current()->NewWeakGlobalRef(thiz.get())); + CSSNodeSetContext(node, new weak_ref(make_weak(thiz))); CSSNodeSetPrintFunc(node, _jniPrint); return reinterpret_cast(node); } void jni_CSSNodeFree(alias_ref thiz, jlong nativePointer) { - Environment::current()->DeleteWeakGlobalRef( - reinterpret_cast(CSSNodeGetContext(_jlong2CSSNodeRef(nativePointer)))); - CSSNodeFree(_jlong2CSSNodeRef(nativePointer)); + const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer); + delete jobjectContext(node); + CSSNodeFree(node); } void jni_CSSNodeReset(alias_ref thiz, jlong nativePointer) { From 4a578284a558909c73def80f5fe19328a5be3905 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 12:17:12 -0800 Subject: [PATCH 087/108] Revert D4248487: [yoga] Remove force_static Summary: This reverts commit e5127a02561b145745cf5393a0188661469ec79b Differential Revision: D4248487 fbshipit-source-id: c826eb6543ff6b8d512bf688fbd395e9766df2fb --- BUCK | 5 ++--- YOGA_DEFS | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/BUCK b/BUCK index e74a0a6e..d6a6b246 100644 --- a/BUCK +++ b/BUCK @@ -29,10 +29,9 @@ cxx_library( tests=[':tests'], exported_headers = subdir_glob([('', 'CSSLayout/*.h')]), header_namespace = '', + force_static = True, compiler_flags = COMPILER_FLAGS, - deps = [] if THIS_IS_FBOBJC else [ - csslayout_dep('lib/fb:ndklog'), - ], + deps = [], visibility = ['PUBLIC'], ) diff --git a/YOGA_DEFS b/YOGA_DEFS index 2b4a62c5..91d372ab 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -9,10 +9,7 @@ GTEST_TARGET = '//lib/gtest:gtest' JNI_TARGET = '//lib/jni:jni' FBJNI_TARGET = '//lib/fb:fbjni' -THIS_IS_FBOBJC = False - CXX_LIBRARY_WHITELIST = [ - '//:CSSLayout', '//lib/fb:fbjni', '//java:jni', ] From 31b961d8b3895eb791d57999ae378a533169f679 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 30 Nov 2016 12:23:09 -0800 Subject: [PATCH 088/108] Revert D4245638: [yoga] Rename defs file Summary: This reverts commit 14050d02c4298014a5fcadd75c4f364537ec2396 Differential Revision: D4245638 fbshipit-source-id: 5eba4f87cbf5a64e235dd16e038326e916cdda77 --- BUCK | 2 +- YOGA_DEFS => CSSLAYOUT_DEFS | 0 CSSLayoutKit/BUCK | 2 +- benchmark/BUCK | 2 +- java/BUCK | 2 +- java/com/facebook/proguard/annotations/BUCK | 2 +- lib/fb/BUCK | 2 +- lib/gtest/BUCK | 2 +- lib/infer-annotations/BUCK | 2 +- lib/jsr-305/BUCK | 2 +- lib/junit/BUCK | 2 +- lib/soloader/BUCK | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename YOGA_DEFS => CSSLAYOUT_DEFS (100%) diff --git a/BUCK b/BUCK index d6a6b246..78dd806d 100644 --- a/BUCK +++ b/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') BASE_COMPILER_FLAGS = [ '-fno-omit-frame-pointer', diff --git a/YOGA_DEFS b/CSSLAYOUT_DEFS similarity index 100% rename from YOGA_DEFS rename to CSSLAYOUT_DEFS diff --git a/CSSLayoutKit/BUCK b/CSSLayoutKit/BUCK index 224d68b7..2f9f570c 100644 --- a/CSSLayoutKit/BUCK +++ b/CSSLayoutKit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ '-fobjc-arc', diff --git a/benchmark/BUCK b/benchmark/BUCK index 4fafe0df..918600b2 100644 --- a/benchmark/BUCK +++ b/benchmark/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') cxx_binary( name = 'benchmark', diff --git a/java/BUCK b/java/BUCK index 1588edd4..6cd85703 100644 --- a/java/BUCK +++ b/java/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') cxx_library( name = 'jni', diff --git a/java/com/facebook/proguard/annotations/BUCK b/java/com/facebook/proguard/annotations/BUCK index 86f1b22f..f9bfb1a5 100644 --- a/java/com/facebook/proguard/annotations/BUCK +++ b/java/com/facebook/proguard/annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') java_library( name = 'annotations', diff --git a/lib/fb/BUCK b/lib/fb/BUCK index dfec53fc..ea3fa8c3 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') prebuilt_cxx_library( name = 'ndklog', diff --git a/lib/gtest/BUCK b/lib/gtest/BUCK index c5a6d790..d2e136b9 100644 --- a/lib/gtest/BUCK +++ b/lib/gtest/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') COMPILER_FLAGS = [ '-std=c++11', diff --git a/lib/infer-annotations/BUCK b/lib/infer-annotations/BUCK index c826e879..313f9e5c 100644 --- a/lib/infer-annotations/BUCK +++ b/lib/infer-annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') prebuilt_jar( name = 'infer-annotations-jar', diff --git a/lib/jsr-305/BUCK b/lib/jsr-305/BUCK index ae663727..c3f74727 100644 --- a/lib/jsr-305/BUCK +++ b/lib/jsr-305/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') prebuilt_jar( name = 'jsr305-jar', diff --git a/lib/junit/BUCK b/lib/junit/BUCK index 9b26fd30..e35b0533 100644 --- a/lib/junit/BUCK +++ b/lib/junit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') prebuilt_jar( name = 'junit-jar', diff --git a/lib/soloader/BUCK b/lib/soloader/BUCK index 077b4fca..8a9ce0a8 100644 --- a/lib/soloader/BUCK +++ b/lib/soloader/BUCK @@ -5,7 +5,7 @@ # 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_defs('//YOGA_DEFS') +include_defs('//CSSLAYOUT_DEFS') android_prebuilt_aar( name = 'soloader', From bb37e65ab156afc3dd59e88af7d9ae7342b15492 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 1 Dec 2016 07:24:55 -0800 Subject: [PATCH 089/108] Fix error from refactor of setMeasuredDimensionsIfEmptyOrFixedSize Summary: D4213339 refactored some code and some logic was missed where negative values should only be ignored for at most measurements. Reviewed By: gkassabli Differential Revision: D4258254 fbshipit-source-id: e22e36e67260114081e483527fc7ce378f7f0df9 --- CSSLayout/CSSLayout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 5b102509..7067827a 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1290,14 +1290,14 @@ static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, - CSSValueIsUndefined(availableWidth) || availableWidth < 0 + CSSValueIsUndefined(availableWidth) || (widthMeasureMode == CSSMeasureModeAtMost && availableWidth < 0) ? 0 : availableWidth - marginAxisRow); node->layout.measuredDimensions[CSSDimensionHeight] = boundAxis(node, CSSFlexDirectionColumn, - CSSValueIsUndefined(availableHeight) || availableHeight < 0 + CSSValueIsUndefined(availableHeight) || (heightMeasureMode == CSSMeasureModeAtMost && availableHeight < 0) ? 0 : availableHeight - marginAxisColumn); From 686289814d94d297284310b0a07693622a7b3dc4 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 05:08:55 -0800 Subject: [PATCH 090/108] Rename defs file Summary: new name Reviewed By: gkassabli Differential Revision: D4258291 fbshipit-source-id: 4b9ad8773c68aed25afba57fcfa92721e6acc1a6 --- BUCK | 2 +- CSSLayoutKit/BUCK | 2 +- CSSLAYOUT_DEFS => YOGA_DEFS | 0 benchmark/BUCK | 2 +- java/BUCK | 2 +- java/com/facebook/proguard/annotations/BUCK | 2 +- lib/fb/BUCK | 2 +- lib/gtest/BUCK | 2 +- lib/infer-annotations/BUCK | 2 +- lib/jsr-305/BUCK | 2 +- lib/junit/BUCK | 2 +- lib/soloader/BUCK | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename CSSLAYOUT_DEFS => YOGA_DEFS (100%) diff --git a/BUCK b/BUCK index 78dd806d..d6a6b246 100644 --- a/BUCK +++ b/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') BASE_COMPILER_FLAGS = [ '-fno-omit-frame-pointer', diff --git a/CSSLayoutKit/BUCK b/CSSLayoutKit/BUCK index 2f9f570c..224d68b7 100644 --- a/CSSLayoutKit/BUCK +++ b/CSSLayoutKit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ '-fobjc-arc', diff --git a/CSSLAYOUT_DEFS b/YOGA_DEFS similarity index 100% rename from CSSLAYOUT_DEFS rename to YOGA_DEFS diff --git a/benchmark/BUCK b/benchmark/BUCK index 918600b2..4fafe0df 100644 --- a/benchmark/BUCK +++ b/benchmark/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') cxx_binary( name = 'benchmark', diff --git a/java/BUCK b/java/BUCK index 6cd85703..1588edd4 100644 --- a/java/BUCK +++ b/java/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') cxx_library( name = 'jni', diff --git a/java/com/facebook/proguard/annotations/BUCK b/java/com/facebook/proguard/annotations/BUCK index f9bfb1a5..86f1b22f 100644 --- a/java/com/facebook/proguard/annotations/BUCK +++ b/java/com/facebook/proguard/annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') java_library( name = 'annotations', diff --git a/lib/fb/BUCK b/lib/fb/BUCK index ea3fa8c3..dfec53fc 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_cxx_library( name = 'ndklog', diff --git a/lib/gtest/BUCK b/lib/gtest/BUCK index d2e136b9..c5a6d790 100644 --- a/lib/gtest/BUCK +++ b/lib/gtest/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') COMPILER_FLAGS = [ '-std=c++11', diff --git a/lib/infer-annotations/BUCK b/lib/infer-annotations/BUCK index 313f9e5c..c826e879 100644 --- a/lib/infer-annotations/BUCK +++ b/lib/infer-annotations/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'infer-annotations-jar', diff --git a/lib/jsr-305/BUCK b/lib/jsr-305/BUCK index c3f74727..ae663727 100644 --- a/lib/jsr-305/BUCK +++ b/lib/jsr-305/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'jsr305-jar', diff --git a/lib/junit/BUCK b/lib/junit/BUCK index e35b0533..9b26fd30 100644 --- a/lib/junit/BUCK +++ b/lib/junit/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') prebuilt_jar( name = 'junit-jar', diff --git a/lib/soloader/BUCK b/lib/soloader/BUCK index 8a9ce0a8..077b4fca 100644 --- a/lib/soloader/BUCK +++ b/lib/soloader/BUCK @@ -5,7 +5,7 @@ # 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_defs('//CSSLAYOUT_DEFS') +include_defs('//YOGA_DEFS') android_prebuilt_aar( name = 'soloader', From 07cf47baadecda0f5f8c43b6463c9756befae217 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 05:08:57 -0800 Subject: [PATCH 091/108] Remove force_static Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true Reviewed By: gkassabli Differential Revision: D4258293 fbshipit-source-id: 053f9e607503707830e3766b1f268ab31d3081ff --- BUCK | 5 +++-- YOGA_DEFS | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BUCK b/BUCK index d6a6b246..e74a0a6e 100644 --- a/BUCK +++ b/BUCK @@ -29,9 +29,10 @@ cxx_library( tests=[':tests'], exported_headers = subdir_glob([('', 'CSSLayout/*.h')]), header_namespace = '', - force_static = True, compiler_flags = COMPILER_FLAGS, - deps = [], + deps = [] if THIS_IS_FBOBJC else [ + csslayout_dep('lib/fb:ndklog'), + ], visibility = ['PUBLIC'], ) diff --git a/YOGA_DEFS b/YOGA_DEFS index 91d372ab..2b4a62c5 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -9,7 +9,10 @@ GTEST_TARGET = '//lib/gtest:gtest' JNI_TARGET = '//lib/jni:jni' FBJNI_TARGET = '//lib/fb:fbjni' +THIS_IS_FBOBJC = False + CXX_LIBRARY_WHITELIST = [ + '//:CSSLayout', '//lib/fb:fbjni', '//java:jni', ] From 42b6f6b6e59006ad06c6842d062a413779343fee Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 05:47:43 -0800 Subject: [PATCH 092/108] Rename enums Summary: new name, start by renaming enums Differential Revision: D4244360 fbshipit-source-id: c9fcbdd231098c9ff230a6055676bbc7cbd11001 --- CSSLayout/CSSEnums.h | 174 +-- CSSLayout/CSSLayout.c | 1249 ++++++++--------- CSSLayout/CSSLayout.h | 51 +- CSSLayout/CSSMacros.h | 8 +- CSSLayoutKit/Tests/CSSLayoutKitTests.m | 16 +- CSSLayoutKit/UIView+CSSLayout.h | 26 +- CSSLayoutKit/UIView+CSSLayout.m | 44 +- README.md | 2 +- benchmark/CSSBenchmark.c | 20 +- csharp/CSSLayout/CSSInterop.cpp | 2 +- csharp/CSSLayout/CSSInterop.h | 2 +- csharp/Facebook.CSSLayout/CSSDIrection.cs | 22 - csharp/Facebook.CSSLayout/CSSLogger.cs | 4 +- csharp/Facebook.CSSLayout/CSSMeasureFunc.cs | 6 +- csharp/Facebook.CSSLayout/CSSNode.Create.cs | 50 +- csharp/Facebook.CSSLayout/CSSNode.cs | 52 +- csharp/Facebook.CSSLayout/MeasureFunction.cs | 4 +- csharp/Facebook.CSSLayout/Native.cs | 62 +- .../{CSSAlign.cs => YogaAlign.cs} | 2 +- .../{CSSConstants.cs => YogaConstants.cs} | 2 +- .../{CSSDimension.cs => YogaDimension.cs} | 2 +- csharp/Facebook.CSSLayout/YogaDirection.cs | 18 + .../{CSSEdge.cs => YogaEdge.cs} | 2 +- ...lFeature.cs => YogaExperimentalFeature.cs} | 2 +- ...SFlexDirection.cs => YogaFlexDirection.cs} | 2 +- .../{CSSJustify.cs => YogaJustify.cs} | 2 +- .../{CSSLogLevel.cs => YogaLogLevel.cs} | 2 +- .../{CSSMeasureMode.cs => YogaMeasureMode.cs} | 2 +- .../{CSSOverflow.cs => YogaOverflow.cs} | 2 +- ...CSSPositionType.cs => YogaPositionType.cs} | 2 +- ...CSSPrintOptions.cs => YogaPrintOptions.cs} | 2 +- .../{CSSWrap.cs => YogaWrap.cs} | 2 +- .../CSSLayoutAbsolutePositionTest.cs | 102 +- .../CSSLayoutAlignContentTest.cs | 30 +- .../CSSLayoutAlignItemsTest.cs | 22 +- .../CSSLayoutAlignSelfTest.cs | 26 +- .../Facebook.CSSLayout/CSSLayoutBorderTest.cs | 62 +- .../CSSLayoutFlexDirectionTest.cs | 32 +- .../Facebook.CSSLayout/CSSLayoutFlexTest.cs | 32 +- .../CSSLayoutFlexWrapTest.cs | 34 +- .../CSSLayoutJustifyContentTest.cs | 66 +- .../Facebook.CSSLayout/CSSLayoutMarginTest.cs | 70 +- .../CSSLayoutMinMaxDimensionTest.cs | 50 +- .../CSSLayoutPaddingTest.cs | 78 +- .../CSSLayoutRoundingTest.cs | 94 +- .../Facebook.CSSLayout/CSSNodeCreateTest.cs | 100 +- .../tests/Facebook.CSSLayout/CSSNodeTest.cs | 2 +- enums.py | 48 +- gentest/gentest-cpp.js | 66 +- gentest/gentest-cs.js | 64 +- gentest/gentest-java.js | 64 +- gentest/gentest.js | 104 +- java/com/facebook/csslayout/CSSLogger.java | 4 +- java/com/facebook/csslayout/CSSNode.java | 102 +- java/com/facebook/csslayout/CSSNodeAPI.java | 56 +- .../{CSSAlign.java => YogaAlign.java} | 6 +- .../{CSSConstants.java => YogaConstants.java} | 2 +- .../{CSSDimension.java => YogaDimension.java} | 6 +- .../{CSSDirection.java => YogaDirection.java} | 6 +- .../csslayout/{CSSEdge.java => YogaEdge.java} | 6 +- ...ture.java => YogaExperimentalFeature.java} | 6 +- ...xDirection.java => YogaFlexDirection.java} | 6 +- .../{CSSJustify.java => YogaJustify.java} | 6 +- .../{CSSLogLevel.java => YogaLogLevel.java} | 6 +- ...SMeasureMode.java => YogaMeasureMode.java} | 6 +- .../{CSSOverflow.java => YogaOverflow.java} | 6 +- ...ositionType.java => YogaPositionType.java} | 6 +- ...rintOptions.java => YogaPrintOptions.java} | 6 +- .../csslayout/{CSSWrap.java => YogaWrap.java} | 6 +- java/jni/CSSJNI.cpp | 58 +- .../CSSLayoutAbsolutePositionTest.java | 102 +- .../csslayout/CSSLayoutAlignContentTest.java | 30 +- .../csslayout/CSSLayoutAlignItemsTest.java | 22 +- .../csslayout/CSSLayoutAlignSelfTest.java | 26 +- .../csslayout/CSSLayoutBorderTest.java | 62 +- .../csslayout/CSSLayoutFlexDirectionTest.java | 32 +- .../facebook/csslayout/CSSLayoutFlexTest.java | 32 +- .../csslayout/CSSLayoutFlexWrapTest.java | 34 +- .../CSSLayoutJustifyContentTest.java | 66 +- .../csslayout/CSSLayoutMarginTest.java | 70 +- .../CSSLayoutMinMaxDimensionTest.java | 50 +- .../csslayout/CSSLayoutPaddingTest.java | 78 +- .../csslayout/CSSLayoutRoundingTest.java | 94 +- .../com/facebook/csslayout/CSSNodeTest.java | 22 +- tests/CSSLayoutAbsolutePositionTest.cpp | 102 +- tests/CSSLayoutAlignContentTest.cpp | 30 +- tests/CSSLayoutAlignItemsTest.cpp | 22 +- tests/CSSLayoutAlignSelfTest.cpp | 26 +- tests/CSSLayoutAspectRatioTest.cpp | 84 +- tests/CSSLayoutBorderTest.cpp | 62 +- tests/CSSLayoutDefaultValuesTest.cpp | 68 +- tests/CSSLayoutDirtyMarkingTest.cpp | 14 +- tests/CSSLayoutEdgeTest.cpp | 70 +- tests/CSSLayoutFlexDirectionTest.cpp | 32 +- tests/CSSLayoutFlexTest.cpp | 32 +- tests/CSSLayoutFlexWrapTest.cpp | 34 +- tests/CSSLayoutJustifyContentTest.cpp | 66 +- tests/CSSLayoutMarginTest.cpp | 70 +- tests/CSSLayoutMeasureCacheTest.cpp | 46 +- tests/CSSLayoutMeasureModeTest.cpp | 78 +- tests/CSSLayoutMeasureTest.cpp | 6 +- tests/CSSLayoutMinMaxDimensionTest.cpp | 50 +- tests/CSSLayoutPaddingTest.cpp | 78 +- tests/CSSLayoutRelayoutTest.cpp | 8 +- tests/CSSLayoutRoundingMeasureFuncTest.cpp | 20 +- tests/CSSLayoutRoundingTest.cpp | 94 +- tests/CSSLayoutStyleTest.cpp | 12 +- 107 files changed, 2546 insertions(+), 2562 deletions(-) delete mode 100644 csharp/Facebook.CSSLayout/CSSDIrection.cs rename csharp/Facebook.CSSLayout/{CSSAlign.cs => YogaAlign.cs} (94%) rename csharp/Facebook.CSSLayout/{CSSConstants.cs => YogaConstants.cs} (93%) rename csharp/Facebook.CSSLayout/{CSSDimension.cs => YogaDimension.cs} (92%) create mode 100644 csharp/Facebook.CSSLayout/YogaDirection.cs rename csharp/Facebook.CSSLayout/{CSSEdge.cs => YogaEdge.cs} (95%) rename csharp/Facebook.CSSLayout/{CSSExperimentalFeature.cs => YogaExperimentalFeature.cs} (90%) rename csharp/Facebook.CSSLayout/{CSSFlexDirection.cs => YogaFlexDirection.cs} (92%) rename csharp/Facebook.CSSLayout/{CSSJustify.cs => YogaJustify.cs} (94%) rename csharp/Facebook.CSSLayout/{CSSLogLevel.cs => YogaLogLevel.cs} (93%) rename csharp/Facebook.CSSLayout/{CSSMeasureMode.cs => YogaMeasureMode.cs} (92%) rename csharp/Facebook.CSSLayout/{CSSOverflow.cs => YogaOverflow.cs} (93%) rename csharp/Facebook.CSSLayout/{CSSPositionType.cs => YogaPositionType.cs} (92%) rename csharp/Facebook.CSSLayout/{CSSPrintOptions.cs => YogaPrintOptions.cs} (92%) rename csharp/Facebook.CSSLayout/{CSSWrap.cs => YogaWrap.cs} (93%) rename java/com/facebook/csslayout/{CSSAlign.java => YogaAlign.java} (89%) rename java/com/facebook/csslayout/{CSSConstants.java => YogaConstants.java} (94%) rename java/com/facebook/csslayout/{CSSDimension.java => YogaDimension.java} (86%) rename java/com/facebook/csslayout/{CSSDirection.java => YogaDirection.java} (87%) rename java/com/facebook/csslayout/{CSSEdge.java => YogaEdge.java} (91%) rename java/com/facebook/csslayout/{CSSExperimentalFeature.java => YogaExperimentalFeature.java} (83%) rename java/com/facebook/csslayout/{CSSFlexDirection.java => YogaFlexDirection.java} (86%) rename java/com/facebook/csslayout/{CSSJustify.java => YogaJustify.java} (89%) rename java/com/facebook/csslayout/{CSSLogLevel.java => YogaLogLevel.java} (88%) rename java/com/facebook/csslayout/{CSSMeasureMode.java => YogaMeasureMode.java} (86%) rename java/com/facebook/csslayout/{CSSOverflow.java => YogaOverflow.java} (87%) rename java/com/facebook/csslayout/{CSSPositionType.java => YogaPositionType.java} (85%) rename java/com/facebook/csslayout/{CSSPrintOptions.java => YogaPrintOptions.java} (86%) rename java/com/facebook/csslayout/{CSSWrap.java => YogaWrap.java} (88%) diff --git a/CSSLayout/CSSEnums.h b/CSSLayout/CSSEnums.h index 94a6ba1b..2a87abf9 100644 --- a/CSSLayout/CSSEnums.h +++ b/CSSLayout/CSSEnums.h @@ -7,102 +7,102 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -typedef enum CSSOverflow { - CSSOverflowVisible, - CSSOverflowHidden, - CSSOverflowScroll, - CSSOverflowCount, -} CSSOverflow; +typedef enum YGFlexDirection { + YGFlexDirectionColumn, + YGFlexDirectionColumnReverse, + YGFlexDirectionRow, + YGFlexDirectionRowReverse, + YGFlexDirectionCount, +} YGFlexDirection; -typedef enum CSSJustify { - CSSJustifyFlexStart, - CSSJustifyCenter, - CSSJustifyFlexEnd, - CSSJustifySpaceBetween, - CSSJustifySpaceAround, - CSSJustifyCount, -} CSSJustify; +typedef enum YGMeasureMode { + YGMeasureModeUndefined, + YGMeasureModeExactly, + YGMeasureModeAtMost, + YGMeasureModeCount, +} YGMeasureMode; -typedef enum CSSFlexDirection { - CSSFlexDirectionColumn, - CSSFlexDirectionColumnReverse, - CSSFlexDirectionRow, - CSSFlexDirectionRowReverse, - CSSFlexDirectionCount, -} CSSFlexDirection; +typedef enum YGPrintOptions { + YGPrintOptionsLayout = 1, + YGPrintOptionsStyle = 2, + YGPrintOptionsChildren = 4, + YGPrintOptionsCount, +} YGPrintOptions; -typedef enum CSSAlign { - CSSAlignAuto, - CSSAlignFlexStart, - CSSAlignCenter, - CSSAlignFlexEnd, - CSSAlignStretch, - CSSAlignCount, -} CSSAlign; +typedef enum YGEdge { + YGEdgeLeft, + YGEdgeTop, + YGEdgeRight, + YGEdgeBottom, + YGEdgeStart, + YGEdgeEnd, + YGEdgeHorizontal, + YGEdgeVertical, + YGEdgeAll, + YGEdgeCount, +} YGEdge; -typedef enum CSSEdge { - CSSEdgeLeft, - CSSEdgeTop, - CSSEdgeRight, - CSSEdgeBottom, - CSSEdgeStart, - CSSEdgeEnd, - CSSEdgeHorizontal, - CSSEdgeVertical, - CSSEdgeAll, - CSSEdgeCount, -} CSSEdge; +typedef enum YGPositionType { + YGPositionTypeRelative, + YGPositionTypeAbsolute, + YGPositionTypeCount, +} YGPositionType; -typedef enum CSSWrap { - CSSWrapNoWrap, - CSSWrapWrap, - CSSWrapCount, -} CSSWrap; +typedef enum YGDimension { + YGDimensionWidth, + YGDimensionHeight, + YGDimensionCount, +} YGDimension; -typedef enum CSSDirection { - CSSDirectionInherit, - CSSDirectionLTR, - CSSDirectionRTL, - CSSDirectionCount, -} CSSDirection; +typedef enum YGJustify { + YGJustifyFlexStart, + YGJustifyCenter, + YGJustifyFlexEnd, + YGJustifySpaceBetween, + YGJustifySpaceAround, + YGJustifyCount, +} YGJustify; -typedef enum CSSExperimentalFeature { - CSSExperimentalFeatureRounding, - CSSExperimentalFeatureWebFlexBasis, - CSSExperimentalFeatureCount, -} CSSExperimentalFeature; +typedef enum YGDirection { + YGDirectionInherit, + YGDirectionLTR, + YGDirectionRTL, + YGDirectionCount, +} YGDirection; -typedef enum CSSLogLevel { - CSSLogLevelError, - CSSLogLevelWarn, - CSSLogLevelInfo, - CSSLogLevelDebug, - CSSLogLevelVerbose, - CSSLogLevelCount, -} CSSLogLevel; +typedef enum YGLogLevel { + YGLogLevelError, + YGLogLevelWarn, + YGLogLevelInfo, + YGLogLevelDebug, + YGLogLevelVerbose, + YGLogLevelCount, +} YGLogLevel; -typedef enum CSSDimension { - CSSDimensionWidth, - CSSDimensionHeight, - CSSDimensionCount, -} CSSDimension; +typedef enum YGWrap { + YGWrapNoWrap, + YGWrapWrap, + YGWrapCount, +} YGWrap; -typedef enum CSSMeasureMode { - CSSMeasureModeUndefined, - CSSMeasureModeExactly, - CSSMeasureModeAtMost, - CSSMeasureModeCount, -} CSSMeasureMode; +typedef enum YGOverflow { + YGOverflowVisible, + YGOverflowHidden, + YGOverflowScroll, + YGOverflowCount, +} YGOverflow; -typedef enum CSSPositionType { - CSSPositionTypeRelative, - CSSPositionTypeAbsolute, - CSSPositionTypeCount, -} CSSPositionType; +typedef enum YGExperimentalFeature { + YGExperimentalFeatureRounding, + YGExperimentalFeatureWebFlexBasis, + YGExperimentalFeatureCount, +} YGExperimentalFeature; -typedef enum CSSPrintOptions { - CSSPrintOptionsLayout = 1, - CSSPrintOptionsStyle = 2, - CSSPrintOptionsChildren = 4, - CSSPrintOptionsCount, -} CSSPrintOptions; +typedef enum YGAlign { + YGAlignAuto, + YGAlignFlexStart, + YGAlignCenter, + YGAlignFlexEnd, + YGAlignStretch, + YGAlignCount, +} YGAlign; diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 7067827a..c41194a1 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -33,8 +33,8 @@ __forceinline const float fmaxf(const float a, const float b) { typedef struct CSSCachedMeasurement { float availableWidth; float availableHeight; - CSSMeasureMode widthMeasureMode; - CSSMeasureMode heightMeasureMode; + YGMeasureMode widthMeasureMode; + YGMeasureMode heightMeasureMode; float computedWidth; float computedHeight; @@ -47,7 +47,7 @@ enum { CSS_MAX_CACHED_RESULT_COUNT = 16 }; typedef struct CSSLayout { float position[4]; float dimensions[2]; - CSSDirection direction; + YGDirection direction; uint32_t computedFlexBasisGeneration; float computedFlexBasis; @@ -55,7 +55,7 @@ typedef struct CSSLayout { // Instead of recomputing the entire layout every single time, we // cache some information to break early when nothing changed uint32_t generationCount; - CSSDirection lastParentDirection; + YGDirection lastParentDirection; uint32_t nextCachedMeasurementsIndex; CSSCachedMeasurement cachedMeasurements[CSS_MAX_CACHED_RESULT_COUNT]; @@ -65,23 +65,23 @@ typedef struct CSSLayout { } CSSLayout; typedef struct CSSStyle { - CSSDirection direction; - CSSFlexDirection flexDirection; - CSSJustify justifyContent; - CSSAlign alignContent; - CSSAlign alignItems; - CSSAlign alignSelf; - CSSPositionType positionType; - CSSWrap flexWrap; - CSSOverflow overflow; + YGDirection direction; + YGFlexDirection flexDirection; + YGJustify justifyContent; + YGAlign alignContent; + YGAlign alignItems; + YGAlign alignSelf; + YGPositionType positionType; + YGWrap flexWrap; + YGOverflow overflow; float flex; float flexGrow; float flexShrink; float flexBasis; - float margin[CSSEdgeCount]; - float position[CSSEdgeCount]; - float padding[CSSEdgeCount]; - float border[CSSEdgeCount]; + float margin[YGEdgeCount]; + float position[YGEdgeCount]; + float padding[YGEdgeCount]; + float border[YGEdgeCount]; float dimensions[2]; float minDimensions[2]; float maxDimensions[2]; @@ -115,25 +115,25 @@ CSSFree gCSSFree = &free; #ifdef ANDROID #include -static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) { - int androidLevel = CSSLogLevelDebug; +static int _csslayoutAndroidLog(YGLogLevel level, const char *format, va_list args) { + int androidLevel = YGLogLevelDebug; switch (level) { - case CSSLogLevelError: + case YGLogLevelError: androidLevel = ANDROID_LOG_ERROR; break; - case CSSLogLevelWarn: + case YGLogLevelWarn: androidLevel = ANDROID_LOG_WARN; break; - case CSSLogLevelInfo: + case YGLogLevelInfo: androidLevel = ANDROID_LOG_INFO; break; - case CSSLogLevelDebug: + case YGLogLevelDebug: androidLevel = ANDROID_LOG_DEBUG; break; - case CSSLogLevelVerbose: + case YGLogLevelVerbose: androidLevel = ANDROID_LOG_VERBOSE; break; - case CSSLogLevelCount: + case YGLogLevelCount: break; } const int result = __android_log_vprint(androidLevel, "css-layout", format, args); @@ -141,14 +141,14 @@ static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list a } static CSSLogger gLogger = &_csslayoutAndroidLog; #else -static int _csslayoutDefaultLog(CSSLogLevel level, const char *format, va_list args) { +static int _csslayoutDefaultLog(YGLogLevel level, const char *format, va_list args) { switch (level) { - case CSSLogLevelError: + case YGLogLevelError: return vfprintf(stderr, format, args); - case CSSLogLevelWarn: - case CSSLogLevelInfo: - case CSSLogLevelDebug: - case CSSLogLevelVerbose: + case YGLogLevelWarn: + case YGLogLevelInfo: + case YGLogLevelDebug: + case YGLogLevelVerbose: default: return vprintf(format, args); } @@ -156,31 +156,30 @@ static int _csslayoutDefaultLog(CSSLogLevel level, const char *format, va_list a static CSSLogger gLogger = &_csslayoutDefaultLog; #endif -static inline float computedEdgeValue(const float edges[CSSEdgeCount], - const CSSEdge edge, +static inline float computedEdgeValue(const float edges[YGEdgeCount], + const YGEdge edge, const float defaultValue) { - CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get computed value of multi-edge shorthands"); + CSS_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); if (!CSSValueIsUndefined(edges[edge])) { return edges[edge]; } - if ((edge == CSSEdgeTop || edge == CSSEdgeBottom) && - !CSSValueIsUndefined(edges[CSSEdgeVertical])) { - return edges[CSSEdgeVertical]; + if ((edge == YGEdgeTop || edge == YGEdgeBottom) && !CSSValueIsUndefined(edges[YGEdgeVertical])) { + return edges[YGEdgeVertical]; } - if ((edge == CSSEdgeLeft || edge == CSSEdgeRight || edge == CSSEdgeStart || edge == CSSEdgeEnd) && - !CSSValueIsUndefined(edges[CSSEdgeHorizontal])) { - return edges[CSSEdgeHorizontal]; + if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) && + !CSSValueIsUndefined(edges[YGEdgeHorizontal])) { + return edges[YGEdgeHorizontal]; } - if (!CSSValueIsUndefined(edges[CSSEdgeAll])) { - return edges[CSSEdgeAll]; + if (!CSSValueIsUndefined(edges[YGEdgeAll])) { + return edges[YGEdgeAll]; } - if (edge == CSSEdgeStart || edge == CSSEdgeEnd) { - return CSSUndefined; + if (edge == YGEdgeStart || edge == YGEdgeEnd) { + return YGUndefined; } return defaultValue; @@ -242,50 +241,50 @@ void CSSNodeInit(const CSSNodeRef node) { node->hasNewLayout = true; node->isDirty = false; - node->style.flex = CSSUndefined; - node->style.flexGrow = CSSUndefined; - node->style.flexShrink = CSSUndefined; - node->style.flexBasis = CSSUndefined; + node->style.flex = YGUndefined; + node->style.flexGrow = YGUndefined; + node->style.flexShrink = YGUndefined; + node->style.flexBasis = YGUndefined; - node->style.alignItems = CSSAlignStretch; - node->style.alignContent = CSSAlignFlexStart; + node->style.alignItems = YGAlignStretch; + node->style.alignContent = YGAlignFlexStart; - node->style.direction = CSSDirectionInherit; - node->style.flexDirection = CSSFlexDirectionColumn; + node->style.direction = YGDirectionInherit; + node->style.flexDirection = YGFlexDirectionColumn; - node->style.overflow = CSSOverflowVisible; + node->style.overflow = YGOverflowVisible; // Some of the fields default to undefined and not 0 - node->style.dimensions[CSSDimensionWidth] = CSSUndefined; - node->style.dimensions[CSSDimensionHeight] = CSSUndefined; + node->style.dimensions[YGDimensionWidth] = YGUndefined; + node->style.dimensions[YGDimensionHeight] = YGUndefined; - node->style.minDimensions[CSSDimensionWidth] = CSSUndefined; - node->style.minDimensions[CSSDimensionHeight] = CSSUndefined; + node->style.minDimensions[YGDimensionWidth] = YGUndefined; + node->style.minDimensions[YGDimensionHeight] = YGUndefined; - node->style.maxDimensions[CSSDimensionWidth] = CSSUndefined; - node->style.maxDimensions[CSSDimensionHeight] = CSSUndefined; + node->style.maxDimensions[YGDimensionWidth] = YGUndefined; + node->style.maxDimensions[YGDimensionHeight] = YGUndefined; - for (CSSEdge edge = CSSEdgeLeft; edge < CSSEdgeCount; edge++) { - node->style.position[edge] = CSSUndefined; - node->style.margin[edge] = CSSUndefined; - node->style.padding[edge] = CSSUndefined; - node->style.border[edge] = CSSUndefined; + for (YGEdge edge = YGEdgeLeft; edge < YGEdgeCount; edge++) { + node->style.position[edge] = YGUndefined; + node->style.margin[edge] = YGUndefined; + node->style.padding[edge] = YGUndefined; + node->style.border[edge] = YGUndefined; } - node->style.aspectRatio = CSSUndefined; + node->style.aspectRatio = YGUndefined; - node->layout.dimensions[CSSDimensionWidth] = CSSUndefined; - node->layout.dimensions[CSSDimensionHeight] = CSSUndefined; + node->layout.dimensions[YGDimensionWidth] = YGUndefined; + node->layout.dimensions[YGDimensionHeight] = YGUndefined; // Such that the comparison is always going to be false - node->layout.lastParentDirection = (CSSDirection) -1; + node->layout.lastParentDirection = (YGDirection) -1; node->layout.nextCachedMeasurementsIndex = 0; - node->layout.computedFlexBasis = CSSUndefined; + node->layout.computedFlexBasis = YGUndefined; - node->layout.measuredDimensions[CSSDimensionWidth] = CSSUndefined; - node->layout.measuredDimensions[CSSDimensionHeight] = CSSUndefined; - node->layout.cachedLayout.widthMeasureMode = (CSSMeasureMode) -1; - node->layout.cachedLayout.heightMeasureMode = (CSSMeasureMode) -1; + node->layout.measuredDimensions[YGDimensionWidth] = YGUndefined; + node->layout.measuredDimensions[YGDimensionHeight] = YGUndefined; + node->layout.cachedLayout.widthMeasureMode = (YGMeasureMode) -1; + node->layout.cachedLayout.heightMeasureMode = (YGMeasureMode) -1; node->layout.cachedLayout.computedWidth = -1; node->layout.cachedLayout.computedHeight = -1; } @@ -293,7 +292,7 @@ void CSSNodeInit(const CSSNodeRef node) { static void _CSSNodeMarkDirty(const CSSNodeRef node) { if (!node->isDirty) { node->isDirty = true; - node->layout.computedFlexBasis = CSSUndefined; + node->layout.computedFlexBasis = YGUndefined; if (node->parent) { _CSSNodeMarkDirty(node->parent); } @@ -381,9 +380,9 @@ inline float CSSNodeStyleGetFlexBasis(const CSSNodeRef node) { return node->style.flexBasis; } if (!CSSValueIsUndefined(node->style.flex)) { - return node->style.flex > 0 ? 0 : CSSUndefined; + return node->style.flex > 0 ? 0 : YGUndefined; } - return CSSUndefined; + return YGUndefined; } void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { @@ -417,16 +416,16 @@ void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { return node->style.instanceName; \ } -#define CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName, defaultValue) \ - void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName) { \ - if (node->style.instanceName[edge] != paramName) { \ - node->style.instanceName[edge] = paramName; \ - _CSSNodeMarkDirty(node); \ - } \ - } \ - \ - type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge) { \ - return computedEdgeValue(node->style.instanceName, edge, defaultValue); \ +#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 CSS_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ @@ -438,51 +437,51 @@ CSS_NODE_PROPERTY_IMPL(void *, Context, context, context); CSS_NODE_PROPERTY_IMPL(CSSPrintFunc, PrintFunc, printFunc, print); CSS_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSDirection, Direction, direction, direction); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSFlexDirection, FlexDirection, flexDirection, flexDirection); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSJustify, JustifyContent, justifyContent, justifyContent); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignContent, alignContent, alignContent); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignItems, alignItems, alignItems); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignSelf, alignSelf, alignSelf); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSPositionType, PositionType, positionType, positionType); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrap, FlexWrap, flexWrap, flexWrap); -CSS_NODE_STYLE_PROPERTY_IMPL(CSSOverflow, Overflow, overflow, overflow); +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); 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); -CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Position, position, position, CSSUndefined); +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); -CSS_NODE_STYLE_PROPERTY_IMPL(float, Width, width, dimensions[CSSDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, Height, height, dimensions[CSSDimensionHeight]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MinWidth, minWidth, minDimensions[CSSDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MinHeight, minHeight, minDimensions[CSSDimensionHeight]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[CSSDimensionWidth]); -CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[CSSDimensionHeight]); +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]); // Yoga specific properties, not compatible with flexbox specification CSS_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[CSSEdgeLeft]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[CSSEdgeTop]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[CSSEdgeRight]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[CSSEdgeBottom]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[CSSDimensionWidth]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[CSSDimensionHeight]); -CSS_NODE_LAYOUT_PROPERTY_IMPL(CSSDirection, Direction, direction); +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); uint32_t gCurrentGenerationCount = 0; bool layoutNodeInternal(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSDirection parentDirection, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, const bool performLayout, const char *reason); @@ -499,19 +498,19 @@ static inline bool eq(const float a, const float b) { static void indent(const uint32_t n) { for (uint32_t i = 0; i < n; i++) { - CSSLog(CSSLogLevelDebug, " "); + CSSLog(YGLogLevelDebug, " "); } } static void printNumberIfNotZero(const char *str, const float number) { if (!eq(number, 0)) { - CSSLog(CSSLogLevelDebug, "%s: %g, ", str, number); + CSSLog(YGLogLevelDebug, "%s: %g, ", str, number); } } static void printNumberIfNotUndefined(const char *str, const float number) { if (!CSSValueIsUndefined(number)) { - CSSLog(CSSLogLevelDebug, "%s: %g, ", str, number); + CSSLog(YGLogLevelDebug, "%s: %g, ", str, number); } } @@ -520,370 +519,363 @@ static bool eqFour(const float four[4]) { } static void _CSSNodePrint(const CSSNodeRef node, - const CSSPrintOptions options, + const YGPrintOptions options, const uint32_t level) { indent(level); - CSSLog(CSSLogLevelDebug, "{"); + CSSLog(YGLogLevelDebug, "{"); if (node->print) { node->print(node); } - if (options & CSSPrintOptionsLayout) { - CSSLog(CSSLogLevelDebug, "layout: {"); - CSSLog(CSSLogLevelDebug, "width: %g, ", node->layout.dimensions[CSSDimensionWidth]); - CSSLog(CSSLogLevelDebug, "height: %g, ", node->layout.dimensions[CSSDimensionHeight]); - CSSLog(CSSLogLevelDebug, "top: %g, ", node->layout.position[CSSEdgeTop]); - CSSLog(CSSLogLevelDebug, "left: %g", node->layout.position[CSSEdgeLeft]); - CSSLog(CSSLogLevelDebug, "}, "); + 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, "}, "); } - if (options & CSSPrintOptionsStyle) { - if (node->style.flexDirection == CSSFlexDirectionColumn) { - CSSLog(CSSLogLevelDebug, "flexDirection: 'column', "); - } else if (node->style.flexDirection == CSSFlexDirectionColumnReverse) { - CSSLog(CSSLogLevelDebug, "flexDirection: 'column-reverse', "); - } else if (node->style.flexDirection == CSSFlexDirectionRow) { - CSSLog(CSSLogLevelDebug, "flexDirection: 'row', "); - } else if (node->style.flexDirection == CSSFlexDirectionRowReverse) { - CSSLog(CSSLogLevelDebug, "flexDirection: 'row-reverse', "); + if (options & YGPrintOptionsStyle) { + if (node->style.flexDirection == YGFlexDirectionColumn) { + CSSLog(YGLogLevelDebug, "flexDirection: 'column', "); + } else if (node->style.flexDirection == YGFlexDirectionColumnReverse) { + CSSLog(YGLogLevelDebug, "flexDirection: 'column-reverse', "); + } else if (node->style.flexDirection == YGFlexDirectionRow) { + CSSLog(YGLogLevelDebug, "flexDirection: 'row', "); + } else if (node->style.flexDirection == YGFlexDirectionRowReverse) { + CSSLog(YGLogLevelDebug, "flexDirection: 'row-reverse', "); } - if (node->style.justifyContent == CSSJustifyCenter) { - CSSLog(CSSLogLevelDebug, "justifyContent: 'center', "); - } else if (node->style.justifyContent == CSSJustifyFlexEnd) { - CSSLog(CSSLogLevelDebug, "justifyContent: 'flex-end', "); - } else if (node->style.justifyContent == CSSJustifySpaceAround) { - CSSLog(CSSLogLevelDebug, "justifyContent: 'space-around', "); - } else if (node->style.justifyContent == CSSJustifySpaceBetween) { - CSSLog(CSSLogLevelDebug, "justifyContent: 'space-between', "); + if (node->style.justifyContent == YGJustifyCenter) { + CSSLog(YGLogLevelDebug, "justifyContent: 'center', "); + } else if (node->style.justifyContent == YGJustifyFlexEnd) { + CSSLog(YGLogLevelDebug, "justifyContent: 'flex-end', "); + } else if (node->style.justifyContent == YGJustifySpaceAround) { + CSSLog(YGLogLevelDebug, "justifyContent: 'space-around', "); + } else if (node->style.justifyContent == YGJustifySpaceBetween) { + CSSLog(YGLogLevelDebug, "justifyContent: 'space-between', "); } - if (node->style.alignItems == CSSAlignCenter) { - CSSLog(CSSLogLevelDebug, "alignItems: 'center', "); - } else if (node->style.alignItems == CSSAlignFlexEnd) { - CSSLog(CSSLogLevelDebug, "alignItems: 'flex-end', "); - } else if (node->style.alignItems == CSSAlignStretch) { - CSSLog(CSSLogLevelDebug, "alignItems: 'stretch', "); + if (node->style.alignItems == YGAlignCenter) { + CSSLog(YGLogLevelDebug, "alignItems: 'center', "); + } else if (node->style.alignItems == YGAlignFlexEnd) { + CSSLog(YGLogLevelDebug, "alignItems: 'flex-end', "); + } else if (node->style.alignItems == YGAlignStretch) { + CSSLog(YGLogLevelDebug, "alignItems: 'stretch', "); } - if (node->style.alignContent == CSSAlignCenter) { - CSSLog(CSSLogLevelDebug, "alignContent: 'center', "); - } else if (node->style.alignContent == CSSAlignFlexEnd) { - CSSLog(CSSLogLevelDebug, "alignContent: 'flex-end', "); - } else if (node->style.alignContent == CSSAlignStretch) { - CSSLog(CSSLogLevelDebug, "alignContent: 'stretch', "); + if (node->style.alignContent == YGAlignCenter) { + CSSLog(YGLogLevelDebug, "alignContent: 'center', "); + } else if (node->style.alignContent == YGAlignFlexEnd) { + CSSLog(YGLogLevelDebug, "alignContent: 'flex-end', "); + } else if (node->style.alignContent == YGAlignStretch) { + CSSLog(YGLogLevelDebug, "alignContent: 'stretch', "); } - if (node->style.alignSelf == CSSAlignFlexStart) { - CSSLog(CSSLogLevelDebug, "alignSelf: 'flex-start', "); - } else if (node->style.alignSelf == CSSAlignCenter) { - CSSLog(CSSLogLevelDebug, "alignSelf: 'center', "); - } else if (node->style.alignSelf == CSSAlignFlexEnd) { - CSSLog(CSSLogLevelDebug, "alignSelf: 'flex-end', "); - } else if (node->style.alignSelf == CSSAlignStretch) { - CSSLog(CSSLogLevelDebug, "alignSelf: 'stretch', "); + if (node->style.alignSelf == YGAlignFlexStart) { + CSSLog(YGLogLevelDebug, "alignSelf: 'flex-start', "); + } else if (node->style.alignSelf == YGAlignCenter) { + CSSLog(YGLogLevelDebug, "alignSelf: 'center', "); + } else if (node->style.alignSelf == YGAlignFlexEnd) { + CSSLog(YGLogLevelDebug, "alignSelf: 'flex-end', "); + } else if (node->style.alignSelf == YGAlignStretch) { + CSSLog(YGLogLevelDebug, "alignSelf: 'stretch', "); } printNumberIfNotUndefined("flexGrow", CSSNodeStyleGetFlexGrow(node)); printNumberIfNotUndefined("flexShrink", CSSNodeStyleGetFlexShrink(node)); printNumberIfNotUndefined("flexBasis", CSSNodeStyleGetFlexBasis(node)); - if (node->style.overflow == CSSOverflowHidden) { - CSSLog(CSSLogLevelDebug, "overflow: 'hidden', "); - } else if (node->style.overflow == CSSOverflowVisible) { - CSSLog(CSSLogLevelDebug, "overflow: 'visible', "); - } else if (node->style.overflow == CSSOverflowScroll) { - CSSLog(CSSLogLevelDebug, "overflow: 'scroll', "); + if (node->style.overflow == YGOverflowHidden) { + CSSLog(YGLogLevelDebug, "overflow: 'hidden', "); + } else if (node->style.overflow == YGOverflowVisible) { + CSSLog(YGLogLevelDebug, "overflow: 'visible', "); + } else if (node->style.overflow == YGOverflowScroll) { + CSSLog(YGLogLevelDebug, "overflow: 'scroll', "); } if (eqFour(node->style.margin)) { - printNumberIfNotZero("margin", computedEdgeValue(node->style.margin, CSSEdgeLeft, 0)); + printNumberIfNotZero("margin", computedEdgeValue(node->style.margin, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("marginLeft", computedEdgeValue(node->style.margin, CSSEdgeLeft, 0)); - printNumberIfNotZero("marginRight", computedEdgeValue(node->style.margin, CSSEdgeRight, 0)); - printNumberIfNotZero("marginTop", computedEdgeValue(node->style.margin, CSSEdgeTop, 0)); - printNumberIfNotZero("marginBottom", computedEdgeValue(node->style.margin, CSSEdgeBottom, 0)); - printNumberIfNotZero("marginStart", computedEdgeValue(node->style.margin, CSSEdgeStart, 0)); - printNumberIfNotZero("marginEnd", computedEdgeValue(node->style.margin, CSSEdgeEnd, 0)); + 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)); } if (eqFour(node->style.padding)) { - printNumberIfNotZero("padding", computedEdgeValue(node->style.padding, CSSEdgeLeft, 0)); + printNumberIfNotZero("padding", computedEdgeValue(node->style.padding, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("paddingLeft", computedEdgeValue(node->style.padding, CSSEdgeLeft, 0)); - printNumberIfNotZero("paddingRight", computedEdgeValue(node->style.padding, CSSEdgeRight, 0)); - printNumberIfNotZero("paddingTop", computedEdgeValue(node->style.padding, CSSEdgeTop, 0)); + 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, CSSEdgeBottom, 0)); - printNumberIfNotZero("paddingStart", computedEdgeValue(node->style.padding, CSSEdgeStart, 0)); - printNumberIfNotZero("paddingEnd", computedEdgeValue(node->style.padding, CSSEdgeEnd, 0)); + computedEdgeValue(node->style.padding, YGEdgeBottom, 0)); + printNumberIfNotZero("paddingStart", computedEdgeValue(node->style.padding, YGEdgeStart, 0)); + printNumberIfNotZero("paddingEnd", computedEdgeValue(node->style.padding, YGEdgeEnd, 0)); } if (eqFour(node->style.border)) { - printNumberIfNotZero("borderWidth", computedEdgeValue(node->style.border, CSSEdgeLeft, 0)); + printNumberIfNotZero("borderWidth", computedEdgeValue(node->style.border, YGEdgeLeft, 0)); } else { - printNumberIfNotZero("borderLeftWidth", - computedEdgeValue(node->style.border, CSSEdgeLeft, 0)); + printNumberIfNotZero("borderLeftWidth", computedEdgeValue(node->style.border, YGEdgeLeft, 0)); printNumberIfNotZero("borderRightWidth", - computedEdgeValue(node->style.border, CSSEdgeRight, 0)); - printNumberIfNotZero("borderTopWidth", computedEdgeValue(node->style.border, CSSEdgeTop, 0)); + computedEdgeValue(node->style.border, YGEdgeRight, 0)); + printNumberIfNotZero("borderTopWidth", computedEdgeValue(node->style.border, YGEdgeTop, 0)); printNumberIfNotZero("borderBottomWidth", - computedEdgeValue(node->style.border, CSSEdgeBottom, 0)); + computedEdgeValue(node->style.border, YGEdgeBottom, 0)); printNumberIfNotZero("borderStartWidth", - computedEdgeValue(node->style.border, CSSEdgeStart, 0)); - printNumberIfNotZero("borderEndWidth", computedEdgeValue(node->style.border, CSSEdgeEnd, 0)); + computedEdgeValue(node->style.border, YGEdgeStart, 0)); + printNumberIfNotZero("borderEndWidth", computedEdgeValue(node->style.border, YGEdgeEnd, 0)); } - printNumberIfNotUndefined("width", node->style.dimensions[CSSDimensionWidth]); - printNumberIfNotUndefined("height", node->style.dimensions[CSSDimensionHeight]); - printNumberIfNotUndefined("maxWidth", node->style.maxDimensions[CSSDimensionWidth]); - printNumberIfNotUndefined("maxHeight", node->style.maxDimensions[CSSDimensionHeight]); - printNumberIfNotUndefined("minWidth", node->style.minDimensions[CSSDimensionWidth]); - printNumberIfNotUndefined("minHeight", node->style.minDimensions[CSSDimensionHeight]); + 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]); - if (node->style.positionType == CSSPositionTypeAbsolute) { - CSSLog(CSSLogLevelDebug, "position: 'absolute', "); + if (node->style.positionType == YGPositionTypeAbsolute) { + CSSLog(YGLogLevelDebug, "position: 'absolute', "); } printNumberIfNotUndefined("left", - computedEdgeValue(node->style.position, CSSEdgeLeft, CSSUndefined)); + computedEdgeValue(node->style.position, YGEdgeLeft, YGUndefined)); printNumberIfNotUndefined("right", - computedEdgeValue(node->style.position, CSSEdgeRight, CSSUndefined)); + computedEdgeValue(node->style.position, YGEdgeRight, YGUndefined)); printNumberIfNotUndefined("top", - computedEdgeValue(node->style.position, CSSEdgeTop, CSSUndefined)); + computedEdgeValue(node->style.position, YGEdgeTop, YGUndefined)); printNumberIfNotUndefined("bottom", - computedEdgeValue(node->style.position, CSSEdgeBottom, CSSUndefined)); + computedEdgeValue(node->style.position, YGEdgeBottom, YGUndefined)); } const uint32_t childCount = CSSNodeListCount(node->children); - if (options & CSSPrintOptionsChildren && childCount > 0) { - CSSLog(CSSLogLevelDebug, "children: [\n"); + if (options & YGPrintOptionsChildren && childCount > 0) { + CSSLog(YGLogLevelDebug, "children: [\n"); for (uint32_t i = 0; i < childCount; i++) { _CSSNodePrint(CSSNodeGetChild(node, i), options, level + 1); } indent(level); - CSSLog(CSSLogLevelDebug, "]},\n"); + CSSLog(YGLogLevelDebug, "]},\n"); } else { - CSSLog(CSSLogLevelDebug, "},\n"); + CSSLog(YGLogLevelDebug, "},\n"); } } -void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options) { +void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options) { _CSSNodePrint(node, options, 0); } -static const CSSEdge leading[4] = { - [CSSFlexDirectionColumn] = CSSEdgeTop, - [CSSFlexDirectionColumnReverse] = CSSEdgeBottom, - [CSSFlexDirectionRow] = CSSEdgeLeft, - [CSSFlexDirectionRowReverse] = CSSEdgeRight, +static const YGEdge leading[4] = { + [YGFlexDirectionColumn] = YGEdgeTop, + [YGFlexDirectionColumnReverse] = YGEdgeBottom, + [YGFlexDirectionRow] = YGEdgeLeft, + [YGFlexDirectionRowReverse] = YGEdgeRight, }; -static const CSSEdge trailing[4] = { - [CSSFlexDirectionColumn] = CSSEdgeBottom, - [CSSFlexDirectionColumnReverse] = CSSEdgeTop, - [CSSFlexDirectionRow] = CSSEdgeRight, - [CSSFlexDirectionRowReverse] = CSSEdgeLeft, +static const YGEdge trailing[4] = { + [YGFlexDirectionColumn] = YGEdgeBottom, + [YGFlexDirectionColumnReverse] = YGEdgeTop, + [YGFlexDirectionRow] = YGEdgeRight, + [YGFlexDirectionRowReverse] = YGEdgeLeft, }; -static const CSSEdge pos[4] = { - [CSSFlexDirectionColumn] = CSSEdgeTop, - [CSSFlexDirectionColumnReverse] = CSSEdgeBottom, - [CSSFlexDirectionRow] = CSSEdgeLeft, - [CSSFlexDirectionRowReverse] = CSSEdgeRight, +static const YGEdge pos[4] = { + [YGFlexDirectionColumn] = YGEdgeTop, + [YGFlexDirectionColumnReverse] = YGEdgeBottom, + [YGFlexDirectionRow] = YGEdgeLeft, + [YGFlexDirectionRowReverse] = YGEdgeRight, }; -static const CSSDimension dim[4] = { - [CSSFlexDirectionColumn] = CSSDimensionHeight, - [CSSFlexDirectionColumnReverse] = CSSDimensionHeight, - [CSSFlexDirectionRow] = CSSDimensionWidth, - [CSSFlexDirectionRowReverse] = CSSDimensionWidth, +static const YGDimension dim[4] = { + [YGFlexDirectionColumn] = YGDimensionHeight, + [YGFlexDirectionColumnReverse] = YGDimensionHeight, + [YGFlexDirectionRow] = YGDimensionWidth, + [YGFlexDirectionRowReverse] = YGDimensionWidth, }; -static inline bool isRowDirection(const CSSFlexDirection flexDirection) { - return flexDirection == CSSFlexDirectionRow || flexDirection == CSSFlexDirectionRowReverse; +static inline bool isRowDirection(const YGFlexDirection flexDirection) { + return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse; } -static inline bool isColumnDirection(const CSSFlexDirection flexDirection) { - return flexDirection == CSSFlexDirectionColumn || flexDirection == CSSFlexDirectionColumnReverse; +static inline bool isColumnDirection(const YGFlexDirection flexDirection) { + return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse; } -static inline float getLeadingMargin(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSEdgeStart])) { - return node->style.margin[CSSEdgeStart]; +static inline float getLeadingMargin(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[YGEdgeStart])) { + return node->style.margin[YGEdgeStart]; } return computedEdgeValue(node->style.margin, leading[axis], 0); } -static float getTrailingMargin(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSEdgeEnd])) { - return node->style.margin[CSSEdgeEnd]; +static float getTrailingMargin(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[YGEdgeEnd])) { + return node->style.margin[YGEdgeEnd]; } return computedEdgeValue(node->style.margin, trailing[axis], 0); } -static float getLeadingPadding(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[CSSEdgeStart]) && - node->style.padding[CSSEdgeStart] >= 0) { - return node->style.padding[CSSEdgeStart]; +static float getLeadingPadding(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[YGEdgeStart]) && + node->style.padding[YGEdgeStart] >= 0) { + return node->style.padding[YGEdgeStart]; } return fmaxf(computedEdgeValue(node->style.padding, leading[axis], 0), 0); } -static float getTrailingPadding(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[CSSEdgeEnd]) && - node->style.padding[CSSEdgeEnd] >= 0) { - return node->style.padding[CSSEdgeEnd]; +static float getTrailingPadding(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[YGEdgeEnd]) && + node->style.padding[YGEdgeEnd] >= 0) { + return node->style.padding[YGEdgeEnd]; } return fmaxf(computedEdgeValue(node->style.padding, trailing[axis], 0), 0); } -static float getLeadingBorder(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[CSSEdgeStart]) && - node->style.border[CSSEdgeStart] >= 0) { - return node->style.border[CSSEdgeStart]; +static float getLeadingBorder(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[YGEdgeStart]) && + node->style.border[YGEdgeStart] >= 0) { + return node->style.border[YGEdgeStart]; } return fmaxf(computedEdgeValue(node->style.border, leading[axis], 0), 0); } -static float getTrailingBorder(const CSSNodeRef node, const CSSFlexDirection axis) { - if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[CSSEdgeEnd]) && - node->style.border[CSSEdgeEnd] >= 0) { - return node->style.border[CSSEdgeEnd]; +static float getTrailingBorder(const CSSNodeRef node, const YGFlexDirection axis) { + if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[YGEdgeEnd]) && + node->style.border[YGEdgeEnd] >= 0) { + return node->style.border[YGEdgeEnd]; } return fmaxf(computedEdgeValue(node->style.border, trailing[axis], 0), 0); } -static inline float getLeadingPaddingAndBorder(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline float getLeadingPaddingAndBorder(const CSSNodeRef node, const YGFlexDirection axis) { return getLeadingPadding(node, axis) + getLeadingBorder(node, axis); } -static inline float getTrailingPaddingAndBorder(const CSSNodeRef node, - const CSSFlexDirection axis) { +static inline float getTrailingPaddingAndBorder(const CSSNodeRef node, const YGFlexDirection axis) { return getTrailingPadding(node, axis) + getTrailingBorder(node, axis); } -static inline float getMarginAxis(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline float getMarginAxis(const CSSNodeRef node, const YGFlexDirection axis) { return getLeadingMargin(node, axis) + getTrailingMargin(node, axis); } -static inline float getPaddingAndBorderAxis(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline float getPaddingAndBorderAxis(const CSSNodeRef node, const YGFlexDirection axis) { return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis); } -static inline CSSAlign getAlignItem(const CSSNodeRef node, const CSSNodeRef child) { - return child->style.alignSelf == CSSAlignAuto ? node->style.alignItems : child->style.alignSelf; +static inline YGAlign getAlignItem(const CSSNodeRef node, const CSSNodeRef child) { + return child->style.alignSelf == YGAlignAuto ? node->style.alignItems : child->style.alignSelf; } -static inline CSSDirection resolveDirection(const CSSNodeRef node, - const CSSDirection parentDirection) { - if (node->style.direction == CSSDirectionInherit) { - return parentDirection > CSSDirectionInherit ? parentDirection : CSSDirectionLTR; +static inline YGDirection resolveDirection(const CSSNodeRef node, + const YGDirection parentDirection) { + if (node->style.direction == YGDirectionInherit) { + return parentDirection > YGDirectionInherit ? parentDirection : YGDirectionLTR; } else { return node->style.direction; } } -static inline CSSFlexDirection resolveAxis(const CSSFlexDirection flexDirection, - const CSSDirection direction) { - if (direction == CSSDirectionRTL) { - if (flexDirection == CSSFlexDirectionRow) { - return CSSFlexDirectionRowReverse; - } else if (flexDirection == CSSFlexDirectionRowReverse) { - return CSSFlexDirectionRow; +static inline YGFlexDirection resolveAxis(const YGFlexDirection flexDirection, + const YGDirection direction) { + if (direction == YGDirectionRTL) { + if (flexDirection == YGFlexDirectionRow) { + return YGFlexDirectionRowReverse; + } else if (flexDirection == YGFlexDirectionRowReverse) { + return YGFlexDirectionRow; } } return flexDirection; } -static CSSFlexDirection getCrossFlexDirection(const CSSFlexDirection flexDirection, - const CSSDirection direction) { - return isColumnDirection(flexDirection) ? resolveAxis(CSSFlexDirectionRow, direction) - : CSSFlexDirectionColumn; +static YGFlexDirection getCrossFlexDirection(const YGFlexDirection flexDirection, + const YGDirection direction) { + return isColumnDirection(flexDirection) ? resolveAxis(YGFlexDirectionRow, direction) + : YGFlexDirectionColumn; } static inline bool isFlex(const CSSNodeRef node) { - return (node->style.positionType == CSSPositionTypeRelative && + 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 CSSFlexDirection axis) { +static inline float getDimWithMargin(const CSSNodeRef node, const YGFlexDirection axis) { return node->layout.measuredDimensions[dim[axis]] + getLeadingMargin(node, axis) + getTrailingMargin(node, axis); } -static inline bool isStyleDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline bool isStyleDimDefined(const CSSNodeRef node, const YGFlexDirection axis) { const float value = node->style.dimensions[dim[axis]]; return !CSSValueIsUndefined(value) && value >= 0.0; } -static inline bool isLayoutDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline bool isLayoutDimDefined(const CSSNodeRef node, const YGFlexDirection axis) { const float value = node->layout.measuredDimensions[dim[axis]]; return !CSSValueIsUndefined(value) && value >= 0.0; } -static inline bool isLeadingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline bool isLeadingPosDefined(const CSSNodeRef node, const YGFlexDirection axis) { return (isRowDirection(axis) && !CSSValueIsUndefined( - computedEdgeValue(node->style.position, CSSEdgeStart, CSSUndefined))) || - !CSSValueIsUndefined(computedEdgeValue(node->style.position, leading[axis], CSSUndefined)); + computedEdgeValue(node->style.position, YGEdgeStart, YGUndefined))) || + !CSSValueIsUndefined(computedEdgeValue(node->style.position, leading[axis], YGUndefined)); } -static inline bool isTrailingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) { +static inline bool isTrailingPosDefined(const CSSNodeRef node, const YGFlexDirection axis) { return (isRowDirection(axis) && - !CSSValueIsUndefined( - computedEdgeValue(node->style.position, CSSEdgeEnd, CSSUndefined))) || - !CSSValueIsUndefined( - computedEdgeValue(node->style.position, trailing[axis], CSSUndefined)); + !CSSValueIsUndefined(computedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined))) || + !CSSValueIsUndefined(computedEdgeValue(node->style.position, trailing[axis], YGUndefined)); } -static float getLeadingPosition(const CSSNodeRef node, const CSSFlexDirection axis) { +static float getLeadingPosition(const CSSNodeRef node, const YGFlexDirection axis) { if (isRowDirection(axis)) { - const float leadingPosition = - computedEdgeValue(node->style.position, CSSEdgeStart, CSSUndefined); + const float leadingPosition = computedEdgeValue(node->style.position, YGEdgeStart, YGUndefined); if (!CSSValueIsUndefined(leadingPosition)) { return leadingPosition; } } - const float leadingPosition = - computedEdgeValue(node->style.position, leading[axis], CSSUndefined); + const float leadingPosition = computedEdgeValue(node->style.position, leading[axis], YGUndefined); return CSSValueIsUndefined(leadingPosition) ? 0 : leadingPosition; } -static float getTrailingPosition(const CSSNodeRef node, const CSSFlexDirection axis) { +static float getTrailingPosition(const CSSNodeRef node, const YGFlexDirection axis) { if (isRowDirection(axis)) { - const float trailingPosition = - computedEdgeValue(node->style.position, CSSEdgeEnd, CSSUndefined); + const float trailingPosition = computedEdgeValue(node->style.position, YGEdgeEnd, YGUndefined); if (!CSSValueIsUndefined(trailingPosition)) { return trailingPosition; } } const float trailingPosition = - computedEdgeValue(node->style.position, trailing[axis], CSSUndefined); + computedEdgeValue(node->style.position, trailing[axis], YGUndefined); return CSSValueIsUndefined(trailingPosition) ? 0 : trailingPosition; } static float boundAxisWithinMinAndMax(const CSSNodeRef node, - const CSSFlexDirection axis, + const YGFlexDirection axis, const float value) { - float min = CSSUndefined; - float max = CSSUndefined; + float min = YGUndefined; + float max = YGUndefined; if (isColumnDirection(axis)) { - min = node->style.minDimensions[CSSDimensionHeight]; - max = node->style.maxDimensions[CSSDimensionHeight]; + min = node->style.minDimensions[YGDimensionHeight]; + max = node->style.maxDimensions[YGDimensionHeight]; } else if (isRowDirection(axis)) { - min = node->style.minDimensions[CSSDimensionWidth]; - max = node->style.maxDimensions[CSSDimensionWidth]; + min = node->style.minDimensions[YGDimensionWidth]; + max = node->style.maxDimensions[YGDimensionWidth]; } float boundValue = value; @@ -903,14 +895,14 @@ static float boundAxisWithinMinAndMax(const CSSNodeRef node, // below the // padding and border amount. static inline float boundAxis(const CSSNodeRef node, - const CSSFlexDirection axis, + const YGFlexDirection axis, const float value) { return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis)); } static void setTrailingPosition(const CSSNodeRef node, const CSSNodeRef child, - const CSSFlexDirection axis) { + 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]]; @@ -918,31 +910,31 @@ 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 CSSFlexDirection axis) { +static float getRelativePosition(const CSSNodeRef node, const YGFlexDirection axis) { return isLeadingPosDefined(node, axis) ? getLeadingPosition(node, axis) : -getTrailingPosition(node, axis); } -static void constrainMaxSizeForMode(const float maxSize, CSSMeasureMode *mode, float *size) { +static void constrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, float *size) { switch (*mode) { - case CSSMeasureModeExactly: - case CSSMeasureModeAtMost: + case YGMeasureModeExactly: + case YGMeasureModeAtMost: *size = (CSSValueIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize; break; - case CSSMeasureModeUndefined: + case YGMeasureModeUndefined: if (!CSSValueIsUndefined(maxSize)) { - *mode = CSSMeasureModeAtMost; + *mode = YGMeasureModeAtMost; *size = maxSize; } break; - case CSSMeasureModeCount: + case YGMeasureModeCount: break; } } -static void setPosition(const CSSNodeRef node, const CSSDirection direction) { - const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); +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); @@ -959,71 +951,71 @@ static void setPosition(const CSSNodeRef node, const CSSDirection direction) { static void computeChildFlexBasis(const CSSNodeRef node, const CSSNodeRef child, const float width, - const CSSMeasureMode widthMode, + const YGMeasureMode widthMode, const float height, - const CSSMeasureMode heightMode, - const CSSDirection direction) { - const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); + const YGMeasureMode heightMode, + const YGDirection direction) { + const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); const bool isMainAxisRow = isRowDirection(mainAxis); float childWidth; float childHeight; - CSSMeasureMode childWidthMeasureMode; - CSSMeasureMode childHeightMeasureMode; + YGMeasureMode childWidthMeasureMode; + YGMeasureMode childHeightMeasureMode; - const bool isRowStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionRow); - const bool isColumnStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionColumn); + const bool isRowStyleDimDefined = isStyleDimDefined(child, YGFlexDirectionRow); + const bool isColumnStyleDimDefined = isStyleDimDefined(child, YGFlexDirectionColumn); if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && !CSSValueIsUndefined(isMainAxisRow ? width : height)) { if (CSSValueIsUndefined(child->layout.computedFlexBasis) || - (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) && + (CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis) && child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); } } else if (isMainAxisRow && isRowStyleDimDefined) { // The width is definite, so use that as the flex basis. - child->layout.computedFlexBasis = fmaxf(child->style.dimensions[CSSDimensionWidth], - getPaddingAndBorderAxis(child, CSSFlexDirectionRow)); + child->layout.computedFlexBasis = fmaxf(child->style.dimensions[YGDimensionWidth], + getPaddingAndBorderAxis(child, YGFlexDirectionRow)); } else if (!isMainAxisRow && isColumnStyleDimDefined) { // The height is definite, so use that as the flex basis. - child->layout.computedFlexBasis = fmaxf(child->style.dimensions[CSSDimensionHeight], - getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); + child->layout.computedFlexBasis = fmaxf(child->style.dimensions[YGDimensionHeight], + getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); } else { // Compute the flex basis and hypothetical main size (i.e. the clamped // flex basis). - childWidth = CSSUndefined; - childHeight = CSSUndefined; - childWidthMeasureMode = CSSMeasureModeUndefined; - childHeightMeasureMode = CSSMeasureModeUndefined; + childWidth = YGUndefined; + childHeight = YGUndefined; + childWidthMeasureMode = YGMeasureModeUndefined; + childHeightMeasureMode = YGMeasureModeUndefined; if (isRowStyleDimDefined) { childWidth = - child->style.dimensions[CSSDimensionWidth] + getMarginAxis(child, CSSFlexDirectionRow); - childWidthMeasureMode = CSSMeasureModeExactly; + child->style.dimensions[YGDimensionWidth] + getMarginAxis(child, YGFlexDirectionRow); + childWidthMeasureMode = YGMeasureModeExactly; } if (isColumnStyleDimDefined) { - childHeight = child->style.dimensions[CSSDimensionHeight] + - getMarginAxis(child, CSSFlexDirectionColumn); - childHeightMeasureMode = CSSMeasureModeExactly; + childHeight = + child->style.dimensions[YGDimensionHeight] + getMarginAxis(child, YGFlexDirectionColumn); + childHeightMeasureMode = YGMeasureModeExactly; } // The W3C spec doesn't say anything about the 'overflow' property, // but all major browsers appear to implement the following logic. - if ((!isMainAxisRow && node->style.overflow == CSSOverflowScroll) || - node->style.overflow != CSSOverflowScroll) { + if ((!isMainAxisRow && node->style.overflow == YGOverflowScroll) || + node->style.overflow != YGOverflowScroll) { if (CSSValueIsUndefined(childWidth) && !CSSValueIsUndefined(width)) { childWidth = width; - childWidthMeasureMode = CSSMeasureModeAtMost; + childWidthMeasureMode = YGMeasureModeAtMost; } } - if ((isMainAxisRow && node->style.overflow == CSSOverflowScroll) || - node->style.overflow != CSSOverflowScroll) { + if ((isMainAxisRow && node->style.overflow == YGOverflowScroll) || + node->style.overflow != YGOverflowScroll) { if (CSSValueIsUndefined(childHeight) && !CSSValueIsUndefined(height)) { childHeight = height; - childHeightMeasureMode = CSSMeasureModeAtMost; + childHeightMeasureMode = YGMeasureModeAtMost; } } @@ -1031,34 +1023,33 @@ static void computeChildFlexBasis(const CSSNodeRef node, // set the cross // axis to be measured exactly with the available inner width if (!isMainAxisRow && !CSSValueIsUndefined(width) && !isRowStyleDimDefined && - widthMode == CSSMeasureModeExactly && getAlignItem(node, child) == CSSAlignStretch) { + widthMode == YGMeasureModeExactly && getAlignItem(node, child) == YGAlignStretch) { childWidth = width; - childWidthMeasureMode = CSSMeasureModeExactly; + childWidthMeasureMode = YGMeasureModeExactly; } if (isMainAxisRow && !CSSValueIsUndefined(height) && !isColumnStyleDimDefined && - heightMode == CSSMeasureModeExactly && getAlignItem(node, child) == CSSAlignStretch) { + heightMode == YGMeasureModeExactly && getAlignItem(node, child) == YGAlignStretch) { childHeight = height; - childHeightMeasureMode = CSSMeasureModeExactly; + childHeightMeasureMode = YGMeasureModeExactly; } if (!CSSValueIsUndefined(child->style.aspectRatio)) { - if (!isMainAxisRow && childWidthMeasureMode == CSSMeasureModeExactly) { + if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = fmaxf(childWidth * child->style.aspectRatio, - getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); + getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); return; - } else if (isMainAxisRow && childHeightMeasureMode == CSSMeasureModeExactly) { - child->layout.computedFlexBasis = - fmaxf(childHeight * child->style.aspectRatio, - getPaddingAndBorderAxis(child, CSSFlexDirectionRow)); + } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { + child->layout.computedFlexBasis = fmaxf(childHeight * child->style.aspectRatio, + getPaddingAndBorderAxis(child, YGFlexDirectionRow)); return; } } - constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], + constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], &childWidthMeasureMode, &childWidth); - constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionHeight], + constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], &childHeightMeasureMode, &childHeight); @@ -1073,8 +1064,8 @@ static void computeChildFlexBasis(const CSSNodeRef node, "measure"); child->layout.computedFlexBasis = - fmaxf(isMainAxisRow ? child->layout.measuredDimensions[CSSDimensionWidth] - : child->layout.measuredDimensions[CSSDimensionHeight], + fmaxf(isMainAxisRow ? child->layout.measuredDimensions[YGDimensionWidth] + : child->layout.measuredDimensions[YGDimensionHeight], getPaddingAndBorderAxis(child, mainAxis)); } @@ -1084,50 +1075,50 @@ static void computeChildFlexBasis(const CSSNodeRef node, static void absoluteLayoutChild(const CSSNodeRef node, const CSSNodeRef child, const float width, - const CSSMeasureMode widthMode, - const CSSDirection direction) { - const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); + 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); - float childWidth = CSSUndefined; - float childHeight = CSSUndefined; - CSSMeasureMode childWidthMeasureMode = CSSMeasureModeUndefined; - CSSMeasureMode childHeightMeasureMode = CSSMeasureModeUndefined; + float childWidth = YGUndefined; + float childHeight = YGUndefined; + YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined; + YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; - if (isStyleDimDefined(child, CSSFlexDirectionRow)) { + if (isStyleDimDefined(child, YGFlexDirectionRow)) { childWidth = - child->style.dimensions[CSSDimensionWidth] + getMarginAxis(child, CSSFlexDirectionRow); + child->style.dimensions[YGDimensionWidth] + getMarginAxis(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, CSSFlexDirectionRow) && - isTrailingPosDefined(child, CSSFlexDirectionRow)) { - childWidth = node->layout.measuredDimensions[CSSDimensionWidth] - - (getLeadingBorder(node, CSSFlexDirectionRow) + - getTrailingBorder(node, CSSFlexDirectionRow)) - - (getLeadingPosition(child, CSSFlexDirectionRow) + - getTrailingPosition(child, CSSFlexDirectionRow)); - childWidth = boundAxis(child, CSSFlexDirectionRow, childWidth); + if (isLeadingPosDefined(child, YGFlexDirectionRow) && + isTrailingPosDefined(child, YGFlexDirectionRow)) { + childWidth = node->layout.measuredDimensions[YGDimensionWidth] - + (getLeadingBorder(node, YGFlexDirectionRow) + + getTrailingBorder(node, YGFlexDirectionRow)) - + (getLeadingPosition(child, YGFlexDirectionRow) + + getTrailingPosition(child, YGFlexDirectionRow)); + childWidth = boundAxis(child, YGFlexDirectionRow, childWidth); } } - if (isStyleDimDefined(child, CSSFlexDirectionColumn)) { + if (isStyleDimDefined(child, YGFlexDirectionColumn)) { childHeight = - child->style.dimensions[CSSDimensionHeight] + getMarginAxis(child, CSSFlexDirectionColumn); + child->style.dimensions[YGDimensionHeight] + getMarginAxis(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, CSSFlexDirectionColumn) && - isTrailingPosDefined(child, CSSFlexDirectionColumn)) { - childHeight = node->layout.measuredDimensions[CSSDimensionHeight] - - (getLeadingBorder(node, CSSFlexDirectionColumn) + - getTrailingBorder(node, CSSFlexDirectionColumn)) - - (getLeadingPosition(child, CSSFlexDirectionColumn) + - getTrailingPosition(child, CSSFlexDirectionColumn)); - childHeight = boundAxis(child, CSSFlexDirectionColumn, childHeight); + if (isLeadingPosDefined(child, YGFlexDirectionColumn) && + isTrailingPosDefined(child, YGFlexDirectionColumn)) { + childHeight = node->layout.measuredDimensions[YGDimensionHeight] - + (getLeadingBorder(node, YGFlexDirectionColumn) + + getTrailingBorder(node, YGFlexDirectionColumn)) - + (getLeadingPosition(child, YGFlexDirectionColumn) + + getTrailingPosition(child, YGFlexDirectionColumn)); + childHeight = boundAxis(child, YGFlexDirectionColumn, childHeight); } } @@ -1137,10 +1128,10 @@ static void absoluteLayoutChild(const CSSNodeRef node, if (!CSSValueIsUndefined(child->style.aspectRatio)) { if (CSSValueIsUndefined(childWidth)) { childWidth = fmaxf(childHeight * child->style.aspectRatio, - getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); + getPaddingAndBorderAxis(child, YGFlexDirectionColumn)); } else if (CSSValueIsUndefined(childHeight)) { childHeight = fmaxf(childWidth * child->style.aspectRatio, - getPaddingAndBorderAxis(child, CSSFlexDirectionRow)); + getPaddingAndBorderAxis(child, YGFlexDirectionRow)); } } } @@ -1148,17 +1139,17 @@ static void absoluteLayoutChild(const CSSNodeRef node, // If we're still missing one or the other dimension, measure the content. if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) { childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; + CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; childHeightMeasureMode = - CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; + CSSValueIsUndefined(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 != CSSMeasureModeUndefined) { + if (!isMainAxisRow && CSSValueIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) { childWidth = width; - childWidthMeasureMode = CSSMeasureModeAtMost; + childWidthMeasureMode = YGMeasureModeAtMost; } layoutNodeInternal(child, @@ -1169,18 +1160,18 @@ static void absoluteLayoutChild(const CSSNodeRef node, childHeightMeasureMode, false, "abs-measure"); - childWidth = child->layout.measuredDimensions[CSSDimensionWidth] + - getMarginAxis(child, CSSFlexDirectionRow); - childHeight = child->layout.measuredDimensions[CSSDimensionHeight] + - getMarginAxis(child, CSSFlexDirectionColumn); + childWidth = child->layout.measuredDimensions[YGDimensionWidth] + + getMarginAxis(child, YGFlexDirectionRow); + childHeight = child->layout.measuredDimensions[YGDimensionHeight] + + getMarginAxis(child, YGFlexDirectionColumn); } layoutNodeInternal(child, childWidth, childHeight, direction, - CSSMeasureModeExactly, - CSSMeasureModeExactly, + YGMeasureModeExactly, + YGMeasureModeExactly, true, "abs-layout"); @@ -1202,47 +1193,46 @@ static void absoluteLayoutChild(const CSSNodeRef node, static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode) { + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode) { CSS_ASSERT(node->measure, "Expected node to have custom measure function"); - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + 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 innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) { + if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) { // Don't bother sizing the text if both dimensions are already defined. - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn); + node->layout.measuredDimensions[YGDimensionWidth] = + boundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + node->layout.measuredDimensions[YGDimensionHeight] = + boundAxis(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[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, 0); + node->layout.measuredDimensions[YGDimensionWidth] = boundAxis(node, YGFlexDirectionRow, 0); + node->layout.measuredDimensions[YGDimensionHeight] = boundAxis(node, YGFlexDirectionColumn, 0); } else { // Measure the text under the current constraints. const CSSSize measuredSize = node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); - node->layout.measuredDimensions[CSSDimensionWidth] = + node->layout.measuredDimensions[YGDimensionWidth] = boundAxis(node, - CSSFlexDirectionRow, - (widthMeasureMode == CSSMeasureModeUndefined || - widthMeasureMode == CSSMeasureModeAtMost) + YGFlexDirectionRow, + (widthMeasureMode == YGMeasureModeUndefined || + widthMeasureMode == YGMeasureModeAtMost) ? measuredSize.width + paddingAndBorderAxisRow : availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = + node->layout.measuredDimensions[YGDimensionHeight] = boundAxis(node, - CSSFlexDirectionColumn, - (heightMeasureMode == CSSMeasureModeUndefined || - heightMeasureMode == CSSMeasureModeAtMost) + YGFlexDirectionColumn, + (heightMeasureMode == YGMeasureModeUndefined || + heightMeasureMode == YGMeasureModeAtMost) ? measuredSize.height + paddingAndBorderAxisColumn : availableHeight - marginAxisColumn); } @@ -1253,25 +1243,25 @@ static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node, static void setMeasuredDimensionsForEmptyContainer(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode) { - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + 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); - node->layout.measuredDimensions[CSSDimensionWidth] = + node->layout.measuredDimensions[YGDimensionWidth] = boundAxis(node, - CSSFlexDirectionRow, - (widthMeasureMode == CSSMeasureModeUndefined || - widthMeasureMode == CSSMeasureModeAtMost) + YGFlexDirectionRow, + (widthMeasureMode == YGMeasureModeUndefined || + widthMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisRow : availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = + node->layout.measuredDimensions[YGDimensionHeight] = boundAxis(node, - CSSFlexDirectionColumn, - (heightMeasureMode == CSSMeasureModeUndefined || - heightMeasureMode == CSSMeasureModeAtMost) + YGFlexDirectionColumn, + (heightMeasureMode == YGMeasureModeUndefined || + heightMeasureMode == YGMeasureModeAtMost) ? paddingAndBorderAxisColumn : availableHeight - marginAxisColumn); } @@ -1279,25 +1269,25 @@ static void setMeasuredDimensionsForEmptyContainer(const CSSNodeRef node, static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode) { - if ((widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) || - (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) || - (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly)) { - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); + 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); - node->layout.measuredDimensions[CSSDimensionWidth] = + node->layout.measuredDimensions[YGDimensionWidth] = boundAxis(node, - CSSFlexDirectionRow, - CSSValueIsUndefined(availableWidth) || (widthMeasureMode == CSSMeasureModeAtMost && availableWidth < 0) + YGFlexDirectionRow, + CSSValueIsUndefined(availableWidth) || (widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0) ? 0 : availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = + node->layout.measuredDimensions[YGDimensionHeight] = boundAxis(node, - CSSFlexDirectionColumn, - CSSValueIsUndefined(availableHeight) || (heightMeasureMode == CSSMeasureModeAtMost && availableHeight < 0) + YGFlexDirectionColumn, + CSSValueIsUndefined(availableHeight) || (heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0) ? 0 : availableHeight - marginAxisColumn); @@ -1373,7 +1363,7 @@ static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, // - node: current node to be sized and layed out // - availableWidth & availableHeight: available size to be used for sizing // the node -// or CSSUndefined if the size is not available; interpretation depends on +// or YGUndefined if the size is not available; interpretation depends on // layout // flags // - parentDirection: the inline (text) direction within the parent @@ -1410,33 +1400,33 @@ static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node, // 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): -// - CSSMeasureModeUndefined: max content -// - CSSMeasureModeExactly: fill available -// - CSSMeasureModeAtMost: fit content +// - YGMeasureModeUndefined: max content +// - YGMeasureModeExactly: fill available +// - YGMeasureModeAtMost: fit content // // When calling layoutNodeImpl and layoutNodeInternal, if the caller passes // an available size of -// undefined then it must also pass a measure mode of CSSMeasureModeUndefined +// 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 CSSDirection parentDirection, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, const bool performLayout) { - CSS_ASSERT(CSSValueIsUndefined(availableWidth) ? widthMeasureMode == CSSMeasureModeUndefined + CSS_ASSERT(CSSValueIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true, "availableWidth is indefinite so widthMeasureMode must be " - "CSSMeasureModeUndefined"); - CSS_ASSERT(CSSValueIsUndefined(availableHeight) ? heightMeasureMode == CSSMeasureModeUndefined + "YGMeasureModeUndefined"); + CSS_ASSERT(CSSValueIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined : true, "availableHeight is indefinite so heightMeasureMode must be " - "CSSMeasureModeUndefined"); + "YGMeasureModeUndefined"); // Set the resolved resolution in the node's layout. - const CSSDirection direction = resolveDirection(node, parentDirection); + const YGDirection direction = resolveDirection(node, parentDirection); node->layout.direction = direction; if (node->measure) { @@ -1461,11 +1451,11 @@ static void layoutNodeImpl(const CSSNodeRef node, } // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM - const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); - const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); + const YGFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction); + const YGFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); const bool isMainAxisRow = isRowDirection(mainAxis); - const CSSJustify justifyContent = node->style.justifyContent; - const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapWrap; + const YGJustify justifyContent = node->style.justifyContent; + const bool isNodeFlexWrap = node->style.flexWrap == YGWrapWrap; CSSNodeRef firstAbsoluteChild = NULL; CSSNodeRef currentAbsoluteChild = NULL; @@ -1476,13 +1466,13 @@ static void layoutNodeImpl(const CSSNodeRef node, const float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); const float paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis); - const CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; - const CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; + const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; + const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow); - const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn); - const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, YGFlexDirectionRow); + const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, YGFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; @@ -1495,8 +1485,8 @@ static void layoutNodeImpl(const CSSNodeRef node, // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly // match the remaining space CSSNodeRef singleFlexChild = NULL; - if ((isMainAxisRow && widthMeasureMode == CSSMeasureModeExactly) || - (!isMainAxisRow && heightMeasureMode == CSSMeasureModeExactly)) { + if ((isMainAxisRow && widthMeasureMode == YGMeasureModeExactly) || + (!isMainAxisRow && heightMeasureMode == YGMeasureModeExactly)) { for (uint32_t i = 0; i < childCount; i++) { const CSSNodeRef child = CSSNodeGetChild(node, i); if (singleFlexChild) { @@ -1517,13 +1507,13 @@ static void layoutNodeImpl(const CSSNodeRef node, if (performLayout) { // Set the initial position (relative to the parent). - const CSSDirection childDirection = resolveDirection(child, direction); + const YGDirection childDirection = resolveDirection(child, direction); setPosition(child, childDirection); } // Absolute-positioned children don't participate in flex layout. Add them // to a list that we can process later. - if (child->style.positionType == CSSPositionTypeAbsolute) { + if (child->style.positionType == YGPositionTypeAbsolute) { // Store a private linked list of absolutely positioned children // so that we can efficiently traverse them later. if (firstAbsoluteChild == NULL) { @@ -1590,7 +1580,7 @@ static void layoutNodeImpl(const CSSNodeRef node, const CSSNodeRef child = CSSNodeListGet(node->children, i); child->lineIndex = lineCount; - if (child->style.positionType != CSSPositionTypeAbsolute) { + if (child->style.positionType != YGPositionTypeAbsolute) { const float outerFlexBasis = child->layout.computedFlexBasis + getMarginAxis(child, mainAxis); @@ -1630,7 +1620,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // If we don't need to measure the cross axis, we can skip the entire flex // step. - const bool canSkipFlex = !performLayout && measureModeCrossDim == CSSMeasureModeExactly; + const bool canSkipFlex = !performLayout && measureModeCrossDim == YGMeasureModeExactly; // In order to position the elements in the main axis, we have two // controls. The space between the beginning and the first element @@ -1785,73 +1775,73 @@ static void layoutNodeImpl(const CSSNodeRef node, float childWidth; float childHeight; - CSSMeasureMode childWidthMeasureMode; - CSSMeasureMode childHeightMeasureMode; + YGMeasureMode childWidthMeasureMode; + YGMeasureMode childHeightMeasureMode; if (isMainAxisRow) { - childWidth = updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionRow); - childWidthMeasureMode = CSSMeasureModeExactly; + childWidth = updatedMainSize + getMarginAxis(currentRelativeChild, YGFlexDirectionRow); + childWidthMeasureMode = YGMeasureModeExactly; if (!CSSValueIsUndefined(availableInnerCrossDim) && - !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn) && - heightMeasureMode == CSSMeasureModeExactly && - getAlignItem(node, currentRelativeChild) == CSSAlignStretch) { + !isStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn) && + heightMeasureMode == YGMeasureModeExactly && + getAlignItem(node, currentRelativeChild) == YGAlignStretch) { childHeight = availableInnerCrossDim; - childHeightMeasureMode = CSSMeasureModeExactly; - } else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn)) { + childHeightMeasureMode = YGMeasureModeExactly; + } else if (!isStyleDimDefined(currentRelativeChild, YGFlexDirectionColumn)) { childHeight = availableInnerCrossDim; childHeightMeasureMode = - CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost; + CSSValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childHeight = currentRelativeChild->style.dimensions[CSSDimensionHeight] + - getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn); - childHeightMeasureMode = CSSMeasureModeExactly; + childHeight = currentRelativeChild->style.dimensions[YGDimensionHeight] + + getMarginAxis(currentRelativeChild, YGFlexDirectionColumn); + childHeightMeasureMode = YGMeasureModeExactly; } } else { childHeight = - updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn); - childHeightMeasureMode = CSSMeasureModeExactly; + updatedMainSize + getMarginAxis(currentRelativeChild, YGFlexDirectionColumn); + childHeightMeasureMode = YGMeasureModeExactly; if (!CSSValueIsUndefined(availableInnerCrossDim) && - !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow) && - widthMeasureMode == CSSMeasureModeExactly && - getAlignItem(node, currentRelativeChild) == CSSAlignStretch) { + !isStyleDimDefined(currentRelativeChild, YGFlexDirectionRow) && + widthMeasureMode == YGMeasureModeExactly && + getAlignItem(node, currentRelativeChild) == YGAlignStretch) { childWidth = availableInnerCrossDim; - childWidthMeasureMode = CSSMeasureModeExactly; - } else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow)) { + childWidthMeasureMode = YGMeasureModeExactly; + } else if (!isStyleDimDefined(currentRelativeChild, YGFlexDirectionRow)) { childWidth = availableInnerCrossDim; childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost; + CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost; } else { - childWidth = currentRelativeChild->style.dimensions[CSSDimensionWidth] + - getMarginAxis(currentRelativeChild, CSSFlexDirectionRow); - childWidthMeasureMode = CSSMeasureModeExactly; + childWidth = currentRelativeChild->style.dimensions[YGDimensionWidth] + + getMarginAxis(currentRelativeChild, YGFlexDirectionRow); + childWidthMeasureMode = YGMeasureModeExactly; } } if (!CSSValueIsUndefined(currentRelativeChild->style.aspectRatio)) { - if (isMainAxisRow && childHeightMeasureMode != CSSMeasureModeExactly) { + if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = fmaxf(childWidth * currentRelativeChild->style.aspectRatio, - getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionColumn)); - childHeightMeasureMode = CSSMeasureModeExactly; - } else if (!isMainAxisRow && childWidthMeasureMode != CSSMeasureModeExactly) { + getPaddingAndBorderAxis(currentRelativeChild, YGFlexDirectionColumn)); + childHeightMeasureMode = YGMeasureModeExactly; + } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, - getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionRow)); - childWidthMeasureMode = CSSMeasureModeExactly; + getPaddingAndBorderAxis(currentRelativeChild, YGFlexDirectionRow)); + childWidthMeasureMode = YGMeasureModeExactly; } } - constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionWidth], + constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionWidth], &childWidthMeasureMode, &childWidth); - constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionHeight], + constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[YGDimensionHeight], &childHeightMeasureMode, &childHeight); const bool requiresStretchLayout = !isStyleDimDefined(currentRelativeChild, crossAxis) && - getAlignItem(node, currentRelativeChild) == CSSAlignStretch; + getAlignItem(node, currentRelativeChild) == YGAlignStretch; // Recursively call the layout algorithm for this child with the updated // main size. @@ -1882,7 +1872,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // If we are using "at most" rules in the main axis. Calculate the remaining space when // constraint by the min size defined for the main axis. - if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) { + if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) { if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && node->style.minDimensions[dim[mainAxis]] >= 0) { remainingFreeSpace = fmaxf(0, @@ -1894,26 +1884,26 @@ static void layoutNodeImpl(const CSSNodeRef node, } switch (justifyContent) { - case CSSJustifyCenter: + case YGJustifyCenter: leadingMainDim = remainingFreeSpace / 2; break; - case CSSJustifyFlexEnd: + case YGJustifyFlexEnd: leadingMainDim = remainingFreeSpace; break; - case CSSJustifySpaceBetween: + case YGJustifySpaceBetween: if (itemsOnLine > 1) { betweenMainDim = fmaxf(remainingFreeSpace, 0) / (itemsOnLine - 1); } else { betweenMainDim = 0; } break; - case CSSJustifySpaceAround: + case YGJustifySpaceAround: // Space on the edges is half of the space between elements betweenMainDim = remainingFreeSpace / itemsOnLine; leadingMainDim = betweenMainDim / 2; break; - case CSSJustifyFlexStart: - case CSSJustifyCount: + case YGJustifyFlexStart: + case YGJustifyCount: break; } @@ -1923,7 +1913,7 @@ static void layoutNodeImpl(const CSSNodeRef node, for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); - if (child->style.positionType == CSSPositionTypeAbsolute && + if (child->style.positionType == YGPositionTypeAbsolute && isLeadingPosDefined(child, mainAxis)) { if (performLayout) { // In case the child is position absolute and has left/top being @@ -1937,7 +1927,7 @@ static void layoutNodeImpl(const CSSNodeRef node, // Now that we placed the element, we need to update the variables. // We need to do that only for relative elements. Absolute elements // do not take part in that phase. - if (child->style.positionType == CSSPositionTypeRelative) { + if (child->style.positionType == YGPositionTypeRelative) { if (performLayout) { child->layout.position[pos[mainAxis]] += mainDim; } @@ -1969,19 +1959,19 @@ static void layoutNodeImpl(const CSSNodeRef node, mainDim += trailingPaddingAndBorderMain; float containerCrossAxis = availableInnerCrossDim; - if (measureModeCrossDim == CSSMeasureModeUndefined || - measureModeCrossDim == CSSMeasureModeAtMost) { + if (measureModeCrossDim == YGMeasureModeUndefined || + measureModeCrossDim == YGMeasureModeAtMost) { // Compute the cross axis from the max cross dimension of the children. containerCrossAxis = boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross) - paddingAndBorderAxisCross; - if (measureModeCrossDim == CSSMeasureModeAtMost) { + if (measureModeCrossDim == YGMeasureModeAtMost) { containerCrossAxis = fminf(containerCrossAxis, availableInnerCrossDim); } } // If there's no flex wrap, the cross dimension is defined by the container. - if (!isNodeFlexWrap && measureModeCrossDim == CSSMeasureModeExactly) { + if (!isNodeFlexWrap && measureModeCrossDim == YGMeasureModeExactly) { crossDim = availableInnerCrossDim; } @@ -1995,7 +1985,7 @@ static void layoutNodeImpl(const CSSNodeRef node, for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); - if (child->style.positionType == CSSPositionTypeAbsolute) { + 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 @@ -2014,36 +2004,36 @@ 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 CSSAlign alignItem = getAlignItem(node, child); + const YGAlign alignItem = getAlignItem(node, child); // If the child uses align stretch, we need to lay it out one more // time, this time // forcing the cross-axis size to be the computed cross size for the // current line. - if (alignItem == CSSAlignStretch) { + if (alignItem == YGAlignStretch) { const bool isCrossSizeDefinite = - (isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionColumn)) || - (!isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionRow)); + (isMainAxisRow && isStyleDimDefined(child, YGFlexDirectionColumn)) || + (!isMainAxisRow && isStyleDimDefined(child, YGFlexDirectionRow)); float childWidth; float childHeight; - CSSMeasureMode childWidthMeasureMode = CSSMeasureModeExactly; - CSSMeasureMode childHeightMeasureMode = CSSMeasureModeExactly; + YGMeasureMode childWidthMeasureMode = YGMeasureModeExactly; + YGMeasureMode childHeightMeasureMode = YGMeasureModeExactly; if (isMainAxisRow) { childHeight = crossDim; - childWidth = child->layout.measuredDimensions[CSSDimensionWidth] + - getMarginAxis(child, CSSFlexDirectionRow); + childWidth = child->layout.measuredDimensions[YGDimensionWidth] + + getMarginAxis(child, YGFlexDirectionRow); } else { childWidth = crossDim; - childHeight = child->layout.measuredDimensions[CSSDimensionHeight] + - getMarginAxis(child, CSSFlexDirectionColumn); + childHeight = child->layout.measuredDimensions[YGDimensionHeight] + + getMarginAxis(child, YGFlexDirectionColumn); } - constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], + constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], &childWidthMeasureMode, &childWidth); - constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionHeight], + constrainMaxSizeForMode(child->style.maxDimensions[YGDimensionHeight], &childHeightMeasureMode, &childHeight); @@ -2051,9 +2041,9 @@ static void layoutNodeImpl(const CSSNodeRef node, // no need to stretch. if (!isCrossSizeDefinite) { childWidthMeasureMode = - CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; - childHeightMeasureMode = CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined - : CSSMeasureModeExactly; + CSSValueIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly; + childHeightMeasureMode = + CSSValueIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly; layoutNodeInternal(child, childWidth, @@ -2064,12 +2054,12 @@ static void layoutNodeImpl(const CSSNodeRef node, true, "stretch"); } - } else if (alignItem != CSSAlignFlexStart) { + } else if (alignItem != YGAlignFlexStart) { const float remainingCrossDim = containerCrossAxis - getDimWithMargin(child, crossAxis); - if (alignItem == CSSAlignCenter) { + if (alignItem == YGAlignCenter) { leadingCrossDim += remainingCrossDim / 2; - } else { // CSSAlignFlexEnd + } else { // YGAlignFlexEnd leadingCrossDim += remainingCrossDim; } } @@ -2092,20 +2082,20 @@ static void layoutNodeImpl(const CSSNodeRef node, float currentLead = leadingPaddingAndBorderCross; switch (node->style.alignContent) { - case CSSAlignFlexEnd: + case YGAlignFlexEnd: currentLead += remainingAlignContentDim; break; - case CSSAlignCenter: + case YGAlignCenter: currentLead += remainingAlignContentDim / 2; break; - case CSSAlignStretch: + case YGAlignStretch: if (availableInnerCrossDim > totalLineCrossDim) { crossDimLead = (remainingAlignContentDim / lineCount); } break; - case CSSAlignAuto: - case CSSAlignFlexStart: - case CSSAlignCount: + case YGAlignAuto: + case YGAlignFlexStart: + case YGAlignCount: break; } @@ -2119,7 +2109,7 @@ static void layoutNodeImpl(const CSSNodeRef node, for (ii = startIndex; ii < childCount; ii++) { const CSSNodeRef child = CSSNodeListGet(node->children, ii); - if (child->style.positionType == CSSPositionTypeRelative) { + if (child->style.positionType == YGPositionTypeRelative) { if (child->lineIndex != i) { break; } @@ -2138,34 +2128,34 @@ static void layoutNodeImpl(const CSSNodeRef node, for (ii = startIndex; ii < endIndex; ii++) { const CSSNodeRef child = CSSNodeListGet(node->children, ii); - if (child->style.positionType == CSSPositionTypeRelative) { + if (child->style.positionType == YGPositionTypeRelative) { switch (getAlignItem(node, child)) { - case CSSAlignFlexStart: { + case YGAlignFlexStart: { child->layout.position[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis); break; } - case CSSAlignFlexEnd: { + case YGAlignFlexEnd: { child->layout.position[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child->layout.measuredDimensions[dim[crossAxis]]; break; } - case CSSAlignCenter: { + case YGAlignCenter: { float childHeight = child->layout.measuredDimensions[dim[crossAxis]]; child->layout.position[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2; break; } - case CSSAlignStretch: { + case YGAlignStretch: { child->layout.position[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis); // TODO(prenaux): Correctly set the height of items with indefinite // (auto) crossAxis dimension. break; } - case CSSAlignAuto: - case CSSAlignCount: + case YGAlignAuto: + case YGAlignCount: break; } } @@ -2177,30 +2167,30 @@ static void layoutNodeImpl(const CSSNodeRef node, } // STEP 9: COMPUTING FINAL DIMENSIONS - node->layout.measuredDimensions[CSSDimensionWidth] = - boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow); - node->layout.measuredDimensions[CSSDimensionHeight] = - boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn); + node->layout.measuredDimensions[YGDimensionWidth] = + boundAxis(node, YGFlexDirectionRow, availableWidth - marginAxisRow); + node->layout.measuredDimensions[YGDimensionHeight] = + boundAxis(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 == CSSMeasureModeUndefined) { + 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); - } else if (measureModeMainDim == CSSMeasureModeAtMost) { + } else if (measureModeMainDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(fminf(availableInnerMainDim + paddingAndBorderAxisMain, boundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim)), paddingAndBorderAxisMain); } - if (measureModeCrossDim == CSSMeasureModeUndefined) { + if (measureModeCrossDim == 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[crossAxis]] = boundAxis(node, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross); - } else if (measureModeCrossDim == CSSMeasureModeAtMost) { + } else if (measureModeCrossDim == YGMeasureModeAtMost) { node->layout.measuredDimensions[dim[crossAxis]] = fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross, boundAxisWithinMinAndMax(node, @@ -2219,9 +2209,9 @@ static void layoutNodeImpl(const CSSNodeRef node, // STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN const bool needsMainTrailingPos = - mainAxis == CSSFlexDirectionRowReverse || mainAxis == CSSFlexDirectionColumnReverse; + mainAxis == YGFlexDirectionRowReverse || mainAxis == YGFlexDirectionColumnReverse; const bool needsCrossTrailingPos = - CSSFlexDirectionRowReverse || crossAxis == CSSFlexDirectionColumnReverse; + YGFlexDirectionRowReverse || crossAxis == YGFlexDirectionColumnReverse; // Set trailing position if necessary. if (needsMainTrailingPos || needsCrossTrailingPos) { @@ -2256,50 +2246,50 @@ static const char *getSpacer(const unsigned long level) { } } -static const char *getModeName(const CSSMeasureMode mode, const bool performLayout) { - const char *kMeasureModeNames[CSSMeasureModeCount] = {"UNDEFINED", "EXACTLY", "AT_MOST"}; - const char *kLayoutModeNames[CSSMeasureModeCount] = {"LAY_UNDEFINED", - "LAY_EXACTLY", - "LAY_AT_" - "MOST"}; +static const char *getModeName(const YGMeasureMode mode, const bool performLayout) { + const char *kMeasureModeNames[YGMeasureModeCount] = {"UNDEFINED", "EXACTLY", "AT_MOST"}; + const char *kLayoutModeNames[YGMeasureModeCount] = {"LAY_UNDEFINED", + "LAY_EXACTLY", + "LAY_AT_" + "MOST"}; - if (mode >= CSSMeasureModeCount) { + if (mode >= YGMeasureModeCount) { return ""; } return performLayout ? kLayoutModeNames[mode] : kMeasureModeNames[mode]; } -static inline bool newSizeIsExactAndMatchesOldMeasuredSize(CSSMeasureMode sizeMode, +static inline bool newSizeIsExactAndMatchesOldMeasuredSize(YGMeasureMode sizeMode, float size, float lastComputedSize) { - return sizeMode == CSSMeasureModeExactly && eq(size, lastComputedSize); + return sizeMode == YGMeasureModeExactly && eq(size, lastComputedSize); } -static inline bool oldSizeIsUnspecifiedAndStillFits(CSSMeasureMode sizeMode, +static inline bool oldSizeIsUnspecifiedAndStillFits(YGMeasureMode sizeMode, float size, - CSSMeasureMode lastSizeMode, + YGMeasureMode lastSizeMode, float lastComputedSize) { - return sizeMode == CSSMeasureModeAtMost && lastSizeMode == CSSMeasureModeUndefined && + return sizeMode == YGMeasureModeAtMost && lastSizeMode == YGMeasureModeUndefined && size >= lastComputedSize; } -static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode, +static inline bool newMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode, float size, - CSSMeasureMode lastSizeMode, + YGMeasureMode lastSizeMode, float lastSize, float lastComputedSize) { - return lastSizeMode == CSSMeasureModeAtMost && sizeMode == CSSMeasureModeAtMost && + return lastSizeMode == YGMeasureModeAtMost && sizeMode == YGMeasureModeAtMost && lastSize > size && lastComputedSize <= size; } -bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, +bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, const float width, - const CSSMeasureMode heightMode, + const YGMeasureMode heightMode, const float height, - const CSSMeasureMode lastWidthMode, + const YGMeasureMode lastWidthMode, const float lastWidth, - const CSSMeasureMode lastHeightMode, + const YGMeasureMode lastHeightMode, const float lastHeight, const float lastComputedWidth, const float lastComputedHeight, @@ -2347,9 +2337,9 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, bool layoutNodeInternal(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSDirection parentDirection, - const CSSMeasureMode widthMeasureMode, - const CSSMeasureMode heightMeasureMode, + const YGDirection parentDirection, + const YGMeasureMode widthMeasureMode, + const YGMeasureMode heightMeasureMode, const bool performLayout, const char *reason) { CSSLayout *layout = &node->layout; @@ -2363,8 +2353,8 @@ bool layoutNodeInternal(const CSSNodeRef node, if (needToVisitNode) { // Invalidate the cached results. layout->nextCachedMeasurementsIndex = 0; - layout->cachedLayout.widthMeasureMode = (CSSMeasureMode) -1; - layout->cachedLayout.heightMeasureMode = (CSSMeasureMode) -1; + layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1; + layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1; layout->cachedLayout.computedWidth = -1; layout->cachedLayout.computedHeight = -1; } @@ -2384,8 +2374,8 @@ 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, CSSFlexDirectionRow); - const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); + const float marginAxisRow = getMarginAxis(node, YGFlexDirectionRow); + const float marginAxisColumn = getMarginAxis(node, YGFlexDirectionColumn); // First, try to use the layout cache. if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, @@ -2441,8 +2431,8 @@ bool layoutNodeInternal(const CSSNodeRef node, } if (!needToVisitNode && cachedResults != NULL) { - layout->measuredDimensions[CSSDimensionWidth] = cachedResults->computedWidth; - layout->measuredDimensions[CSSDimensionHeight] = cachedResults->computedHeight; + layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth; + layout->measuredDimensions[YGDimensionHeight] = cachedResults->computedHeight; if (gPrintChanges && gPrintSkips) { printf("%s%d.{[skipped] ", getSpacer(gDepth), gDepth); @@ -2488,8 +2478,8 @@ bool layoutNodeInternal(const CSSNodeRef node, printf("wm: %s, hm: %s, d: (%f, %f) %s\n", getModeName(widthMeasureMode, performLayout), getModeName(heightMeasureMode, performLayout), - layout->measuredDimensions[CSSDimensionWidth], - layout->measuredDimensions[CSSDimensionHeight], + layout->measuredDimensions[YGDimensionWidth], + layout->measuredDimensions[YGDimensionHeight], reason); } @@ -2517,15 +2507,14 @@ bool layoutNodeInternal(const CSSNodeRef node, newCacheEntry->availableHeight = availableHeight; newCacheEntry->widthMeasureMode = widthMeasureMode; newCacheEntry->heightMeasureMode = heightMeasureMode; - newCacheEntry->computedWidth = layout->measuredDimensions[CSSDimensionWidth]; - newCacheEntry->computedHeight = layout->measuredDimensions[CSSDimensionHeight]; + newCacheEntry->computedWidth = layout->measuredDimensions[YGDimensionWidth]; + newCacheEntry->computedHeight = layout->measuredDimensions[YGDimensionHeight]; } } if (performLayout) { - node->layout.dimensions[CSSDimensionWidth] = node->layout.measuredDimensions[CSSDimensionWidth]; - node->layout.dimensions[CSSDimensionHeight] = - node->layout.measuredDimensions[CSSDimensionHeight]; + node->layout.dimensions[YGDimensionWidth] = node->layout.measuredDimensions[YGDimensionWidth]; + node->layout.dimensions[YGDimensionHeight] = node->layout.measuredDimensions[YGDimensionHeight]; node->hasNewLayout = true; node->isDirty = false; } @@ -2537,16 +2526,16 @@ bool layoutNodeInternal(const CSSNodeRef node, static void roundToPixelGrid(const CSSNodeRef node) { const float fractialLeft = - node->layout.position[CSSEdgeLeft] - floorf(node->layout.position[CSSEdgeLeft]); + node->layout.position[YGEdgeLeft] - floorf(node->layout.position[YGEdgeLeft]); const float fractialTop = - node->layout.position[CSSEdgeTop] - floorf(node->layout.position[CSSEdgeTop]); - node->layout.dimensions[CSSDimensionWidth] = - roundf(fractialLeft + node->layout.dimensions[CSSDimensionWidth]) - roundf(fractialLeft); - node->layout.dimensions[CSSDimensionHeight] = - roundf(fractialTop + node->layout.dimensions[CSSDimensionHeight]) - roundf(fractialTop); + node->layout.position[YGEdgeTop] - floorf(node->layout.position[YGEdgeTop]); + node->layout.dimensions[YGDimensionWidth] = + roundf(fractialLeft + node->layout.dimensions[YGDimensionWidth]) - roundf(fractialLeft); + node->layout.dimensions[YGDimensionHeight] = + roundf(fractialTop + node->layout.dimensions[YGDimensionHeight]) - roundf(fractialTop); - node->layout.position[CSSEdgeLeft] = roundf(node->layout.position[CSSEdgeLeft]); - node->layout.position[CSSEdgeTop] = roundf(node->layout.position[CSSEdgeTop]); + 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); for (uint32_t i = 0; i < childCount; i++) { @@ -2557,7 +2546,7 @@ static void roundToPixelGrid(const CSSNodeRef node) { void CSSNodeCalculateLayout(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSDirection parentDirection) { + 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 @@ -2567,29 +2556,29 @@ void CSSNodeCalculateLayout(const CSSNodeRef node, float width = availableWidth; float height = availableHeight; - CSSMeasureMode widthMeasureMode = CSSMeasureModeUndefined; - CSSMeasureMode heightMeasureMode = CSSMeasureModeUndefined; + YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; + YGMeasureMode heightMeasureMode = YGMeasureModeUndefined; if (!CSSValueIsUndefined(width)) { - widthMeasureMode = CSSMeasureModeExactly; - } else if (isStyleDimDefined(node, CSSFlexDirectionRow)) { + widthMeasureMode = YGMeasureModeExactly; + } else if (isStyleDimDefined(node, YGFlexDirectionRow)) { width = - node->style.dimensions[dim[CSSFlexDirectionRow]] + getMarginAxis(node, CSSFlexDirectionRow); - widthMeasureMode = CSSMeasureModeExactly; - } else if (node->style.maxDimensions[CSSDimensionWidth] >= 0.0) { - width = node->style.maxDimensions[CSSDimensionWidth]; - widthMeasureMode = CSSMeasureModeAtMost; + node->style.dimensions[dim[YGFlexDirectionRow]] + getMarginAxis(node, YGFlexDirectionRow); + widthMeasureMode = YGMeasureModeExactly; + } else if (node->style.maxDimensions[YGDimensionWidth] >= 0.0) { + width = node->style.maxDimensions[YGDimensionWidth]; + widthMeasureMode = YGMeasureModeAtMost; } if (!CSSValueIsUndefined(height)) { - heightMeasureMode = CSSMeasureModeExactly; - } else if (isStyleDimDefined(node, CSSFlexDirectionColumn)) { - height = node->style.dimensions[dim[CSSFlexDirectionColumn]] + - getMarginAxis(node, CSSFlexDirectionColumn); - heightMeasureMode = CSSMeasureModeExactly; - } else if (node->style.maxDimensions[CSSDimensionHeight] >= 0.0) { - height = node->style.maxDimensions[CSSDimensionHeight]; - heightMeasureMode = CSSMeasureModeAtMost; + heightMeasureMode = YGMeasureModeExactly; + } else if (isStyleDimDefined(node, YGFlexDirectionColumn)) { + height = node->style.dimensions[dim[YGFlexDirectionColumn]] + + getMarginAxis(node, YGFlexDirectionColumn); + heightMeasureMode = YGMeasureModeExactly; + } else if (node->style.maxDimensions[YGDimensionHeight] >= 0.0) { + height = node->style.maxDimensions[YGDimensionHeight]; + heightMeasureMode = YGMeasureModeAtMost; } if (layoutNodeInternal(node, @@ -2603,12 +2592,12 @@ void CSSNodeCalculateLayout(const CSSNodeRef node, "l")) { setPosition(node, node->layout.direction); - if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureRounding)) { + if (CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { roundToPixelGrid(node); } if (gPrintTree) { - CSSNodePrint(node, CSSPrintOptionsLayout | CSSPrintOptionsChildren | CSSPrintOptionsStyle); + CSSNodePrint(node, YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle); } } } @@ -2617,20 +2606,20 @@ void CSSLayoutSetLogger(CSSLogger logger) { gLogger = logger; } -void CSSLog(CSSLogLevel level, const char *format, ...) { +void CSSLog(YGLogLevel level, const char *format, ...) { va_list args; va_start(args, format); gLogger(level, format, args); va_end(args); } -static bool experimentalFeatures[CSSExperimentalFeatureCount + 1]; +static bool experimentalFeatures[YGExperimentalFeatureCount + 1]; -void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) { +void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled) { experimentalFeatures[feature] = enabled; } -inline bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) { +inline bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature) { return experimentalFeatures[feature]; } diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index e2dca0a7..62f5b16c 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -26,7 +26,7 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; #define NAN (*(const float *) __nan) #endif -#define CSSUndefined NAN +#define YGUndefined NAN #include "CSSEnums.h" #include "CSSMacros.h" @@ -41,11 +41,11 @@ typedef struct CSSSize { typedef struct CSSNode *CSSNodeRef; typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode); + YGMeasureMode heightMode); typedef void (*CSSPrintFunc)(CSSNodeRef node); -typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args); +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); @@ -70,7 +70,7 @@ WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node); WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node, const float availableWidth, const float availableHeight, - const CSSDirection parentDirection); + const YGDirection parentDirection); // Mark a node as dirty. Only valid for nodes with a custom measure function // set. @@ -81,17 +81,17 @@ WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node, WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node); WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); -WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); +WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options); WIN_EXPORT bool CSSValueIsUndefined(const float value); -WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, +WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, const float width, - const CSSMeasureMode heightMode, + const YGMeasureMode heightMode, const float height, - const CSSMeasureMode lastWidthMode, + const YGMeasureMode lastWidthMode, const float lastWidth, - const CSSMeasureMode lastHeightMode, + const YGMeasureMode lastHeightMode, const float lastHeight, const float lastComputedWidth, const float lastComputedHeight, @@ -110,9 +110,9 @@ WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcN #define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \ - const CSSEdge edge, \ + const YGEdge edge, \ const type paramName); \ - WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge); + 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); @@ -122,15 +122,15 @@ CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc); CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout); -CSS_NODE_STYLE_PROPERTY(CSSDirection, Direction, direction); -CSS_NODE_STYLE_PROPERTY(CSSFlexDirection, FlexDirection, flexDirection); -CSS_NODE_STYLE_PROPERTY(CSSJustify, JustifyContent, justifyContent); -CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignContent, alignContent); -CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems); -CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf); -CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType); -CSS_NODE_STYLE_PROPERTY(CSSWrap, FlexWrap, flexWrap); -CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow); +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); @@ -167,14 +167,13 @@ 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(CSSDirection, Direction); +CSS_NODE_LAYOUT_PROPERTY(YGDirection, Direction); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); -WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); +WIN_EXPORT void CSSLog(YGLogLevel level, const char *message, ...); -WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, - bool enabled); -WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature); +WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled); +WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature); WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc, CSSCalloc cssCalloc, diff --git a/CSSLayout/CSSMacros.h b/CSSLayout/CSSMacros.h index 8d2375e5..f54a5b87 100644 --- a/CSSLayout/CSSMacros.h +++ b/CSSLayout/CSSMacros.h @@ -34,9 +34,9 @@ #endif #ifndef CSS_ASSERT -#define CSS_ASSERT(X, message) \ - if (!(X)) { \ - CSSLog(CSSLogLevelError, "%s", message); \ - CSS_ABORT(); \ +#define CSS_ASSERT(X, message) \ + if (!(X)) { \ + CSSLog(YGLogLevelError, "%s", message); \ + CSS_ABORT(); \ } #endif diff --git a/CSSLayoutKit/Tests/CSSLayoutKitTests.m b/CSSLayoutKit/Tests/CSSLayoutKitTests.m index 22b159b2..b125f382 100644 --- a/CSSLayoutKit/Tests/CSSLayoutKitTests.m +++ b/CSSLayoutKit/Tests/CSSLayoutKitTests.m @@ -74,8 +74,8 @@ { UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; - [container css_setAlignItems:CSSAlignFlexStart]; + [container css_setFlexDirection:YGFlexDirectionRow]; + [container css_setAlignItems:YGAlignFlexStart]; UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; longTextLabel.text = @"This is a very very very very very very very very long piece of text."; @@ -87,7 +87,7 @@ UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero]; [textBadgeView css_setUsesFlexbox:YES]; - [textBadgeView css_setMargin:3.0 forEdge:CSSEdgeLeft]; + [textBadgeView css_setMargin:3.0 forEdge:YGEdgeLeft]; [textBadgeView css_setWidth:10]; [textBadgeView css_setHeight:10]; [container addSubview:textBadgeView]; @@ -102,7 +102,7 @@ UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setFlexDirection:YGFlexDirectionRow]; for (int i = 0; i < 3; i++) { UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; @@ -131,7 +131,7 @@ UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; [subview1 css_setUsesFlexbox:YES]; @@ -171,7 +171,7 @@ UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; [subview1 css_setUsesFlexbox:YES]; @@ -208,7 +208,7 @@ { UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; [subview1 css_setUsesFlexbox:YES]; @@ -237,7 +237,7 @@ { UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)]; [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:CSSFlexDirectionRow]; + [container css_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; [subview1 css_setUsesFlexbox:YES]; diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h index 6938fd95..c88fbfbb 100644 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ b/CSSLayoutKit/UIView+CSSLayout.h @@ -22,22 +22,22 @@ */ @property (nonatomic, readwrite, assign, setter=css_setUsesFlexbox:) BOOL css_usesFlexbox; -- (void)css_setDirection:(CSSDirection)direction; -- (void)css_setFlexDirection:(CSSFlexDirection)flexDirection; -- (void)css_setJustifyContent:(CSSJustify)justifyContent; -- (void)css_setAlignContent:(CSSAlign)alignContent; -- (void)css_setAlignItems:(CSSAlign)alignItems; -- (void)css_setAlignSelf:(CSSAlign)alignSelf; -- (void)css_setPositionType:(CSSPositionType)positionType; -- (void)css_setFlexWrap:(CSSWrap)flexWrap; +- (void)css_setDirection:(YGDirection)direction; +- (void)css_setFlexDirection:(YGFlexDirection)flexDirection; +- (void)css_setJustifyContent:(YGJustify)justifyContent; +- (void)css_setAlignContent:(YGAlign)alignContent; +- (void)css_setAlignItems:(YGAlign)alignItems; +- (void)css_setAlignSelf:(YGAlign)alignSelf; +- (void)css_setPositionType:(YGPositionType)positionType; +- (void)css_setFlexWrap:(YGWrap)flexWrap; - (void)css_setFlexGrow:(CGFloat)flexGrow; - (void)css_setFlexShrink:(CGFloat)flexShrink; - (void)css_setFlexBasis:(CGFloat)flexBasis; -- (void)css_setPosition:(CGFloat)position forEdge:(CSSEdge)edge; -- (void)css_setMargin:(CGFloat)margin forEdge:(CSSEdge)edge; -- (void)css_setPadding:(CGFloat)padding forEdge:(CSSEdge)edge; +- (void)css_setPosition:(CGFloat)position forEdge:(YGEdge)edge; +- (void)css_setMargin:(CGFloat)margin forEdge:(YGEdge)edge; +- (void)css_setPadding:(CGFloat)padding forEdge:(YGEdge)edge; - (void)css_setWidth:(CGFloat)width; - (void)css_setHeight:(CGFloat)height; @@ -50,9 +50,9 @@ - (void)css_setAspectRatio:(CGFloat)aspectRatio; /** - Get the resolved direction of this node. This won't be CSSDirectionInherit + Get the resolved direction of this node. This won't be YGDirectionInherit */ -- (CSSDirection)css_resolvedDirection; +- (YGDirection)css_resolvedDirection; /** Perform a layout calculation and update the frames of the views in the hierarchy with th results diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/CSSLayoutKit/UIView+CSSLayout.m index 664f50fb..21b4010a 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/CSSLayoutKit/UIView+CSSLayout.m @@ -19,7 +19,7 @@ + (void)initialize { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); } - (instancetype)init @@ -76,42 +76,42 @@ OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (void)css_setDirection:(CSSDirection)direction +- (void)css_setDirection:(YGDirection)direction { CSSNodeStyleSetDirection([self cssNode], direction); } -- (void)css_setFlexDirection:(CSSFlexDirection)flexDirection +- (void)css_setFlexDirection:(YGFlexDirection)flexDirection { CSSNodeStyleSetFlexDirection([self cssNode], flexDirection); } -- (void)css_setJustifyContent:(CSSJustify)justifyContent +- (void)css_setJustifyContent:(YGJustify)justifyContent { CSSNodeStyleSetJustifyContent([self cssNode], justifyContent); } -- (void)css_setAlignContent:(CSSAlign)alignContent +- (void)css_setAlignContent:(YGAlign)alignContent { CSSNodeStyleSetAlignContent([self cssNode], alignContent); } -- (void)css_setAlignItems:(CSSAlign)alignItems +- (void)css_setAlignItems:(YGAlign)alignItems { CSSNodeStyleSetAlignItems([self cssNode], alignItems); } -- (void)css_setAlignSelf:(CSSAlign)alignSelf +- (void)css_setAlignSelf:(YGAlign)alignSelf { CSSNodeStyleSetAlignSelf([self cssNode], alignSelf); } -- (void)css_setPositionType:(CSSPositionType)positionType +- (void)css_setPositionType:(YGPositionType)positionType { CSSNodeStyleSetPositionType([self cssNode], positionType); } -- (void)css_setFlexWrap:(CSSWrap)flexWrap +- (void)css_setFlexWrap:(YGWrap)flexWrap { CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); } @@ -131,17 +131,17 @@ CSSNodeStyleSetFlexBasis([self cssNode], flexBasis); } -- (void)css_setPosition:(CGFloat)position forEdge:(CSSEdge)edge +- (void)css_setPosition:(CGFloat)position forEdge:(YGEdge)edge { CSSNodeStyleSetPosition([self cssNode], edge, position); } -- (void)css_setMargin:(CGFloat)margin forEdge:(CSSEdge)edge +- (void)css_setMargin:(CGFloat)margin forEdge:(YGEdge)edge { CSSNodeStyleSetMargin([self cssNode], edge, margin); } -- (void)css_setPadding:(CGFloat)padding forEdge:(CSSEdge)edge +- (void)css_setPadding:(CGFloat)padding forEdge:(YGEdge)edge { CSSNodeStyleSetPadding([self cssNode], edge, padding); } @@ -183,7 +183,7 @@ #pragma mark - Layout and Sizing -- (CSSDirection)css_resolvedDirection +- (YGDirection)css_resolvedDirection { return CSSNodeLayoutGetDirection([self cssNode]); } @@ -197,8 +197,8 @@ - (CGSize)css_intrinsicSize { const CGSize constrainedSize = { - .width = CSSUndefined, - .height = CSSUndefined, + .width = YGUndefined, + .height = YGUndefined, }; return [self calculateLayoutWithSize:constrainedSize]; } @@ -240,12 +240,12 @@ static CSSSize CSSMeasureView( CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) + YGMeasureMode heightMode) { - const CGFloat constrainedWidth = (widthMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX : width; - const CGFloat constrainedHeight = (heightMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX: height; + const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width; + const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height; UIView *view = (__bridge UIView*) CSSNodeGetContext(node); const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { @@ -262,12 +262,12 @@ static CSSSize CSSMeasureView( static CGFloat CSSSanitizeMeasurement( CGFloat constrainedSize, CGFloat measuredSize, - CSSMeasureMode measureMode) + YGMeasureMode measureMode) { CGFloat result; - if (measureMode == CSSMeasureModeExactly) { + if (measureMode == YGMeasureModeExactly) { result = constrainedSize; - } else if (measureMode == CSSMeasureModeAtMost) { + } else if (measureMode == YGMeasureModeAtMost) { result = MIN(constrainedSize, measuredSize); } else { result = measuredSize; diff --git a/README.md b/README.md index ea044d33..c6bd9f37 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ for (uint32_t i = 0; i < 10; i++) { CSSNodeInsertChild(root, child, 0); } -CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); +CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); // Get for resulting layout CSSNodeLayoutGetLeft(root); diff --git a/benchmark/CSSBenchmark.c b/benchmark/CSSBenchmark.c index 0bab9511..79499f29 100644 --- a/benchmark/CSSBenchmark.c +++ b/benchmark/CSSBenchmark.c @@ -13,12 +13,12 @@ static CSSSize _measure(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { return (CSSSize){ - .width = widthMode == CSSMeasureModeUndefined ? 10 : width, - .height = heightMode == CSSMeasureModeUndefined ? 10 : width, + .width = widthMode == YGMeasureModeUndefined ? 10 : width, + .height = heightMode == YGMeasureModeUndefined ? 10 : width, }; } @@ -36,7 +36,7 @@ CSS_BENCHMARKS({ CSSNodeInsertChild(root, child, 0); } - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeFreeRecursive(root); }); @@ -50,7 +50,7 @@ CSS_BENCHMARKS({ CSSNodeInsertChild(root, child, 0); } - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeFreeRecursive(root); }); @@ -70,7 +70,7 @@ CSS_BENCHMARKS({ } } - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeFreeRecursive(root); }); @@ -86,7 +86,7 @@ CSS_BENCHMARKS({ for (uint32_t ii = 0; ii < 10; ii++) { const CSSNodeRef grandChild = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(grandChild, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow); CSSNodeStyleSetFlexGrow(grandChild, 1); CSSNodeStyleSetWidth(grandChild, 10); CSSNodeStyleSetHeight(grandChild, 10); @@ -101,7 +101,7 @@ CSS_BENCHMARKS({ for (uint32_t iii = 0; iii < 10; iii++) { const CSSNodeRef grandGrandGrandChild = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(grandGrandGrandChild, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); CSSNodeStyleSetFlexGrow(grandGrandGrandChild, 1); CSSNodeStyleSetWidth(grandGrandGrandChild, 10); CSSNodeStyleSetHeight(grandGrandGrandChild, 10); @@ -111,7 +111,7 @@ CSS_BENCHMARKS({ } } - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeFreeRecursive(root); }); diff --git a/csharp/CSSLayout/CSSInterop.cpp b/csharp/CSSLayout/CSSInterop.cpp index 679d6544..7995cab2 100644 --- a/csharp/CSSLayout/CSSInterop.cpp +++ b/csharp/CSSLayout/CSSInterop.cpp @@ -11,7 +11,7 @@ static CSSInteropLoggerFunc gManagedFunc; -static int unmanagedLogger(CSSLogLevel level, const char *format, va_list args) { +static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { int result = 0; if (gManagedFunc) { char buffer[256]; diff --git a/csharp/CSSLayout/CSSInterop.h b/csharp/CSSLayout/CSSInterop.h index bbff6072..daa82247 100644 --- a/csharp/CSSLayout/CSSInterop.h +++ b/csharp/CSSLayout/CSSInterop.h @@ -13,7 +13,7 @@ CSS_EXTERN_C_BEGIN -typedef void (*CSSInteropLoggerFunc)(CSSLogLevel level, const char *message); +typedef void (*CSSInteropLoggerFunc)(YGLogLevel level, const char *message); WIN_EXPORT void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc); diff --git a/csharp/Facebook.CSSLayout/CSSDIrection.cs b/csharp/Facebook.CSSLayout/CSSDIrection.cs deleted file mode 100644 index f350e288..00000000 --- a/csharp/Facebook.CSSLayout/CSSDIrection.cs +++ /dev/null @@ -1,22 +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. - */ - -namespace Facebook.CSSLayout -{ - public enum CSSDirection - { - Inherit, - LTR, - RTL, - [System.Obsolete("Use LTR instead")] - LeftToRight = LTR, - [System.Obsolete("Use RTL instead")] - RightToLeft = RTL, - } -} diff --git a/csharp/Facebook.CSSLayout/CSSLogger.cs b/csharp/Facebook.CSSLayout/CSSLogger.cs index 60122f27..16718deb 100644 --- a/csharp/Facebook.CSSLayout/CSSLogger.cs +++ b/csharp/Facebook.CSSLayout/CSSLogger.cs @@ -15,7 +15,7 @@ namespace Facebook.CSSLayout internal static class CSSLogger { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Func(CSSLogLevel level, string message); + public delegate void Func(YogaLogLevel level, string message); private static bool _initialized; private static Func _managedLogger = null; @@ -32,7 +32,7 @@ namespace Facebook.CSSLayout Logger(level, message); } - if (level == CSSLogLevel.Error) + if (level == YogaLogLevel.Error) { throw new InvalidOperationException(message); } diff --git a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs index cd5744d5..6864c280 100644 --- a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs +++ b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs @@ -14,9 +14,9 @@ namespace Facebook.CSSLayout { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate CSSSize CSSMeasureFunc( - IntPtr node, + IntPtr node, float width, - CSSMeasureMode widthMode, + YogaMeasureMode widthMode, float height, - CSSMeasureMode heightMode); + YogaMeasureMode heightMode); } diff --git a/csharp/Facebook.CSSLayout/CSSNode.Create.cs b/csharp/Facebook.CSSLayout/CSSNode.Create.cs index ff301b8d..31a52c85 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.Create.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.Create.cs @@ -14,15 +14,15 @@ namespace Facebook.CSSLayout public partial class CSSNode { public static CSSNode Create( - CSSDirection? styleDirection = null, - CSSFlexDirection? flexDirection = null, - CSSJustify? justifyContent = null, - CSSAlign? alignContent = null, - CSSAlign? alignItems = null, - CSSAlign? alignSelf = null, - CSSPositionType? positionType = null, - CSSWrap? wrap = null, - CSSOverflow? overflow = null, + YogaDirection? styleDirection = null, + YogaFlexDirection? flexDirection = null, + YogaJustify? justifyContent = null, + YogaAlign? alignContent = null, + YogaAlign? alignItems = null, + YogaAlign? alignSelf = null, + YogaPositionType? positionType = null, + YogaWrap? wrap = null, + YogaOverflow? overflow = null, float? flex = null, float? flexGrow = null, float? flexShrink = null, @@ -110,22 +110,22 @@ namespace Facebook.CSSLayout { if (position.Top.HasValue) { - node.SetPosition(CSSEdge.Top, position.Top.Value); + node.SetPosition(YogaEdge.Top, position.Top.Value); } if (position.Bottom.HasValue) { - node.SetPosition(CSSEdge.Bottom, position.Bottom.Value); + node.SetPosition(YogaEdge.Bottom, position.Bottom.Value); } if (position.Left.HasValue) { - node.SetPosition(CSSEdge.Left, position.Left.Value); + node.SetPosition(YogaEdge.Left, position.Left.Value); } if (position.Right.HasValue) { - node.SetPosition(CSSEdge.Right, position.Right.Value); + node.SetPosition(YogaEdge.Right, position.Right.Value); } } @@ -133,22 +133,22 @@ namespace Facebook.CSSLayout { if (margin.Top.HasValue) { - node.SetMargin(CSSEdge.Top, margin.Top.Value); + node.SetMargin(YogaEdge.Top, margin.Top.Value); } if (margin.Bottom.HasValue) { - node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value); + node.SetMargin(YogaEdge.Bottom, margin.Bottom.Value); } if (margin.Left.HasValue) { - node.SetMargin(CSSEdge.Left, margin.Left.Value); + node.SetMargin(YogaEdge.Left, margin.Left.Value); } if (margin.Right.HasValue) { - node.SetMargin(CSSEdge.Right, margin.Right.Value); + node.SetMargin(YogaEdge.Right, margin.Right.Value); } } @@ -156,22 +156,22 @@ namespace Facebook.CSSLayout { if (padding.Top.HasValue) { - node.SetPadding(CSSEdge.Top, padding.Top.Value); + node.SetPadding(YogaEdge.Top, padding.Top.Value); } if (padding.Bottom.HasValue) { - node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value); + node.SetPadding(YogaEdge.Bottom, padding.Bottom.Value); } if (padding.Left.HasValue) { - node.SetPadding(CSSEdge.Left, padding.Left.Value); + node.SetPadding(YogaEdge.Left, padding.Left.Value); } if (padding.Right.HasValue) { - node.SetPadding(CSSEdge.Right, padding.Right.Value); + node.SetPadding(YogaEdge.Right, padding.Right.Value); } } @@ -179,22 +179,22 @@ namespace Facebook.CSSLayout { if (border.Top.HasValue) { - node.SetBorder(CSSEdge.Top, border.Top.Value); + node.SetBorder(YogaEdge.Top, border.Top.Value); } if (border.Bottom.HasValue) { - node.SetBorder(CSSEdge.Bottom, border.Bottom.Value); + node.SetBorder(YogaEdge.Bottom, border.Bottom.Value); } if (border.Left.HasValue) { - node.SetBorder(CSSEdge.Left, border.Left.Value); + node.SetBorder(YogaEdge.Left, border.Left.Value); } if (border.Right.HasValue) { - node.SetBorder(CSSEdge.Right, border.Right.Value); + node.SetBorder(YogaEdge.Right, border.Right.Value); } } diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 0583a823..73694f6f 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -95,7 +95,7 @@ namespace Facebook.CSSLayout Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode); } - public CSSDirection StyleDirection + public YogaDirection StyleDirection { get { @@ -108,7 +108,7 @@ namespace Facebook.CSSLayout } } - public CSSFlexDirection FlexDirection + public YogaFlexDirection FlexDirection { get { @@ -121,7 +121,7 @@ namespace Facebook.CSSLayout } } - public CSSJustify JustifyContent + public YogaJustify JustifyContent { get { @@ -134,7 +134,7 @@ namespace Facebook.CSSLayout } } - public CSSAlign AlignItems + public YogaAlign AlignItems { get { @@ -147,7 +147,7 @@ namespace Facebook.CSSLayout } } - public CSSAlign AlignSelf + public YogaAlign AlignSelf { get { @@ -160,7 +160,7 @@ namespace Facebook.CSSLayout } } - public CSSAlign AlignContent + public YogaAlign AlignContent { get { @@ -173,7 +173,7 @@ namespace Facebook.CSSLayout } } - public CSSPositionType PositionType + public YogaPositionType PositionType { get { @@ -186,7 +186,7 @@ namespace Facebook.CSSLayout } } - public CSSWrap Wrap + public YogaWrap Wrap { get { @@ -246,42 +246,42 @@ namespace Facebook.CSSLayout } } - public float GetMargin(CSSEdge edge) + public float GetMargin(YogaEdge edge) { return Native.CSSNodeStyleGetMargin(_cssNode, edge); } - public void SetMargin(CSSEdge edge, float value) + public void SetMargin(YogaEdge edge, float value) { Native.CSSNodeStyleSetMargin(_cssNode, edge, value); } - public float GetPadding(CSSEdge edge) + public float GetPadding(YogaEdge edge) { return Native.CSSNodeStyleGetPadding(_cssNode, edge); } - public void SetPadding(CSSEdge edge, float padding) + public void SetPadding(YogaEdge edge, float padding) { Native.CSSNodeStyleSetPadding(_cssNode, edge, padding); } - public float GetBorder(CSSEdge edge) + public float GetBorder(YogaEdge edge) { return Native.CSSNodeStyleGetBorder(_cssNode, edge); } - public void SetBorder(CSSEdge edge, float border) + public void SetBorder(YogaEdge edge, float border) { Native.CSSNodeStyleSetBorder(_cssNode, edge, border); } - public float GetPosition(CSSEdge edge) + public float GetPosition(YogaEdge edge) { return Native.CSSNodeStyleGetPosition(_cssNode, edge); } - public void SetPosition(CSSEdge edge, float position) + public void SetPosition(YogaEdge edge, float position) { Native.CSSNodeStyleSetPosition(_cssNode, edge, position); } @@ -409,7 +409,7 @@ namespace Facebook.CSSLayout } } - public CSSDirection LayoutDirection + public YogaDirection LayoutDirection { get { @@ -417,7 +417,7 @@ namespace Facebook.CSSLayout } } - public CSSOverflow Overflow + public YogaOverflow Overflow { get { @@ -520,17 +520,17 @@ namespace Facebook.CSSLayout { Native.CSSNodeCalculateLayout( _cssNode, - CSSConstants.Undefined, - CSSConstants.Undefined, + YogaConstants.Undefined, + YogaConstants.Undefined, Native.CSSNodeStyleGetDirection(_cssNode)); } private CSSSize MeasureInternal( IntPtr node, float width, - CSSMeasureMode widthMode, + YogaMeasureMode widthMode, float height, - CSSMeasureMode heightMode) + YogaMeasureMode heightMode) { if (_measureFunction == null) { @@ -541,8 +541,8 @@ namespace Facebook.CSSLayout return new CSSSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) }; } - public string Print(CSSPrintOptions options = - CSSPrintOptions.Layout|CSSPrintOptions.Style|CSSPrintOptions.Children) + public string Print(YogaPrintOptions options = + YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children) { StringBuilder sb = new StringBuilder(); CSSLogger.Func orig = CSSLogger.Logger; @@ -570,13 +570,13 @@ namespace Facebook.CSSLayout } public static void SetExperimentalFeatureEnabled( - CSSExperimentalFeature feature, + YogaExperimentalFeature feature, bool enabled) { Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled); } - public static bool IsExperimentalFeatureEnabled(CSSExperimentalFeature feature) + public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature) { return Native.CSSLayoutIsExperimentalFeatureEnabled(feature); } diff --git a/csharp/Facebook.CSSLayout/MeasureFunction.cs b/csharp/Facebook.CSSLayout/MeasureFunction.cs index 51614e17..3c8128e0 100644 --- a/csharp/Facebook.CSSLayout/MeasureFunction.cs +++ b/csharp/Facebook.CSSLayout/MeasureFunction.cs @@ -12,7 +12,7 @@ namespace Facebook.CSSLayout public delegate long MeasureFunction( CSSNode node, float width, - CSSMeasureMode widthMode, + YogaMeasureMode widthMode, float height, - CSSMeasureMode heightMode); + YogaMeasureMode heightMode); } diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs index 682b8fdd..7e910732 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.CSSLayout/Native.cs @@ -41,12 +41,12 @@ namespace Facebook.CSSLayout [DllImport(DllName)] public static extern void CSSLayoutSetExperimentalFeatureEnabled( - CSSExperimentalFeature feature, + YogaExperimentalFeature feature, bool enabled); [DllImport(DllName)] public static extern bool CSSLayoutIsExperimentalFeatureEnabled( - CSSExperimentalFeature feature); + YogaExperimentalFeature feature); [DllImport(DllName)] public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index); @@ -64,7 +64,7 @@ namespace Facebook.CSSLayout public static extern void CSSNodeCalculateLayout(IntPtr node, float availableWidth, float availableHeight, - CSSDirection parentDirection); + YogaDirection parentDirection); [DllImport(DllName)] public static extern void CSSNodeMarkDirty(IntPtr node); @@ -74,7 +74,7 @@ namespace Facebook.CSSLayout public static extern bool CSSNodeIsDirty(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodePrint(IntPtr node, CSSPrintOptions options); + public static extern void CSSNodePrint(IntPtr node, YogaPrintOptions options); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] @@ -112,58 +112,58 @@ namespace Facebook.CSSLayout #region CSS_NODE_STYLE_PROPERTY [DllImport(DllName)] - public static extern void CSSNodeStyleSetDirection(IntPtr node, CSSDirection direction); + public static extern void CSSNodeStyleSetDirection(IntPtr node, YogaDirection direction); [DllImport(DllName)] - public static extern CSSDirection CSSNodeStyleGetDirection(IntPtr node); + public static extern YogaDirection CSSNodeStyleGetDirection(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, CSSFlexDirection flexDirection); + public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection); [DllImport(DllName)] - public static extern CSSFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node); + public static extern YogaFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, CSSJustify justifyContent); + public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent); [DllImport(DllName)] - public static extern CSSJustify CSSNodeStyleGetJustifyContent(IntPtr node); + public static extern YogaJustify CSSNodeStyleGetJustifyContent(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignContent(IntPtr node, CSSAlign alignContent); + public static extern void CSSNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent); [DllImport(DllName)] - public static extern CSSAlign CSSNodeStyleGetAlignContent(IntPtr node); + public static extern YogaAlign CSSNodeStyleGetAlignContent(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignItems(IntPtr node, CSSAlign alignItems); + public static extern void CSSNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems); [DllImport(DllName)] - public static extern CSSAlign CSSNodeStyleGetAlignItems(IntPtr node); + public static extern YogaAlign CSSNodeStyleGetAlignItems(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, CSSAlign alignSelf); + public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf); [DllImport(DllName)] - public static extern CSSAlign CSSNodeStyleGetAlignSelf(IntPtr node); + public static extern YogaAlign CSSNodeStyleGetAlignSelf(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetPositionType(IntPtr node, CSSPositionType positionType); + public static extern void CSSNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType); [DllImport(DllName)] - public static extern CSSPositionType CSSNodeStyleGetPositionType(IntPtr node); + public static extern YogaPositionType CSSNodeStyleGetPositionType(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, CSSWrap flexWrap); + public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap); [DllImport(DllName)] - public static extern CSSWrap CSSNodeStyleGetFlexWrap(IntPtr node); + public static extern YogaWrap CSSNodeStyleGetFlexWrap(IntPtr node); [DllImport(DllName)] - public static extern void CSSNodeStyleSetOverflow(IntPtr node, CSSOverflow flexWrap); + public static extern void CSSNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap); [DllImport(DllName)] - public static extern CSSOverflow CSSNodeStyleGetOverflow(IntPtr node); + public static extern YogaOverflow CSSNodeStyleGetOverflow(IntPtr node); [DllImport(DllName)] public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex); @@ -233,28 +233,28 @@ namespace Facebook.CSSLayout #region CSS_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName)] - public static extern void CSSNodeStyleSetPosition(IntPtr node, CSSEdge edge, float position); + public static extern void CSSNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position); [DllImport(DllName)] - public static extern float CSSNodeStyleGetPosition(IntPtr node, CSSEdge edge); + public static extern float CSSNodeStyleGetPosition(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetMargin(IntPtr node, CSSEdge edge, float margin); + public static extern void CSSNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin); [DllImport(DllName)] - public static extern float CSSNodeStyleGetMargin(IntPtr node, CSSEdge edge); + public static extern float CSSNodeStyleGetMargin(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetPadding(IntPtr node, CSSEdge edge, float padding); + public static extern void CSSNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding); [DllImport(DllName)] - public static extern float CSSNodeStyleGetPadding(IntPtr node, CSSEdge edge); + public static extern float CSSNodeStyleGetPadding(IntPtr node, YogaEdge edge); [DllImport(DllName)] - public static extern void CSSNodeStyleSetBorder(IntPtr node, CSSEdge edge, float border); + public static extern void CSSNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border); [DllImport(DllName)] - public static extern float CSSNodeStyleGetBorder(IntPtr node, CSSEdge edge); + public static extern float CSSNodeStyleGetBorder(IntPtr node, YogaEdge edge); #endregion @@ -279,7 +279,7 @@ namespace Facebook.CSSLayout public static extern float CSSNodeLayoutGetHeight(IntPtr node); [DllImport(DllName)] - public static extern CSSDirection CSSNodeLayoutGetDirection(IntPtr node); + public static extern YogaDirection CSSNodeLayoutGetDirection(IntPtr node); #endregion } diff --git a/csharp/Facebook.CSSLayout/CSSAlign.cs b/csharp/Facebook.CSSLayout/YogaAlign.cs similarity index 94% rename from csharp/Facebook.CSSLayout/CSSAlign.cs rename to csharp/Facebook.CSSLayout/YogaAlign.cs index 94cbad3b..64932253 100644 --- a/csharp/Facebook.CSSLayout/CSSAlign.cs +++ b/csharp/Facebook.CSSLayout/YogaAlign.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSAlign + public enum YogaAlign { Auto, FlexStart, diff --git a/csharp/Facebook.CSSLayout/CSSConstants.cs b/csharp/Facebook.CSSLayout/YogaConstants.cs similarity index 93% rename from csharp/Facebook.CSSLayout/CSSConstants.cs rename to csharp/Facebook.CSSLayout/YogaConstants.cs index a57d62f2..b7fa3399 100644 --- a/csharp/Facebook.CSSLayout/CSSConstants.cs +++ b/csharp/Facebook.CSSLayout/YogaConstants.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public static class CSSConstants + public static class YogaConstants { public const float Undefined = float.NaN; diff --git a/csharp/Facebook.CSSLayout/CSSDimension.cs b/csharp/Facebook.CSSLayout/YogaDimension.cs similarity index 92% rename from csharp/Facebook.CSSLayout/CSSDimension.cs rename to csharp/Facebook.CSSLayout/YogaDimension.cs index 9ae6512f..dd167359 100644 --- a/csharp/Facebook.CSSLayout/CSSDimension.cs +++ b/csharp/Facebook.CSSLayout/YogaDimension.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSDimension + public enum YogaDimension { Width, Height, diff --git a/csharp/Facebook.CSSLayout/YogaDirection.cs b/csharp/Facebook.CSSLayout/YogaDirection.cs new file mode 100644 index 00000000..4f1317b6 --- /dev/null +++ b/csharp/Facebook.CSSLayout/YogaDirection.cs @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +namespace Facebook.CSSLayout +{ + public enum YogaDirection + { + Inherit, + LTR, + RTL, + } +} diff --git a/csharp/Facebook.CSSLayout/CSSEdge.cs b/csharp/Facebook.CSSLayout/YogaEdge.cs similarity index 95% rename from csharp/Facebook.CSSLayout/CSSEdge.cs rename to csharp/Facebook.CSSLayout/YogaEdge.cs index b639eb9e..15a7ef75 100644 --- a/csharp/Facebook.CSSLayout/CSSEdge.cs +++ b/csharp/Facebook.CSSLayout/YogaEdge.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSEdge + public enum YogaEdge { Left, Top, diff --git a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs b/csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs similarity index 90% rename from csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs rename to csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs index 160fc724..b5b09f3a 100644 --- a/csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs +++ b/csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSExperimentalFeature + public enum YogaExperimentalFeature { Rounding, WebFlexBasis, diff --git a/csharp/Facebook.CSSLayout/CSSFlexDirection.cs b/csharp/Facebook.CSSLayout/YogaFlexDirection.cs similarity index 92% rename from csharp/Facebook.CSSLayout/CSSFlexDirection.cs rename to csharp/Facebook.CSSLayout/YogaFlexDirection.cs index 24c82392..d02eeaa9 100644 --- a/csharp/Facebook.CSSLayout/CSSFlexDirection.cs +++ b/csharp/Facebook.CSSLayout/YogaFlexDirection.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSFlexDirection + public enum YogaFlexDirection { Column, ColumnReverse, diff --git a/csharp/Facebook.CSSLayout/CSSJustify.cs b/csharp/Facebook.CSSLayout/YogaJustify.cs similarity index 94% rename from csharp/Facebook.CSSLayout/CSSJustify.cs rename to csharp/Facebook.CSSLayout/YogaJustify.cs index 5f97f31b..a8a3d3a1 100644 --- a/csharp/Facebook.CSSLayout/CSSJustify.cs +++ b/csharp/Facebook.CSSLayout/YogaJustify.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSJustify + public enum YogaJustify { FlexStart, Center, diff --git a/csharp/Facebook.CSSLayout/CSSLogLevel.cs b/csharp/Facebook.CSSLayout/YogaLogLevel.cs similarity index 93% rename from csharp/Facebook.CSSLayout/CSSLogLevel.cs rename to csharp/Facebook.CSSLayout/YogaLogLevel.cs index 53a5cbe8..89fce541 100644 --- a/csharp/Facebook.CSSLayout/CSSLogLevel.cs +++ b/csharp/Facebook.CSSLayout/YogaLogLevel.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSLogLevel + public enum YogaLogLevel { Error, Warn, diff --git a/csharp/Facebook.CSSLayout/CSSMeasureMode.cs b/csharp/Facebook.CSSLayout/YogaMeasureMode.cs similarity index 92% rename from csharp/Facebook.CSSLayout/CSSMeasureMode.cs rename to csharp/Facebook.CSSLayout/YogaMeasureMode.cs index 4b9cdd9c..28d837f3 100644 --- a/csharp/Facebook.CSSLayout/CSSMeasureMode.cs +++ b/csharp/Facebook.CSSLayout/YogaMeasureMode.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSMeasureMode + public enum YogaMeasureMode { Undefined, Exactly, diff --git a/csharp/Facebook.CSSLayout/CSSOverflow.cs b/csharp/Facebook.CSSLayout/YogaOverflow.cs similarity index 93% rename from csharp/Facebook.CSSLayout/CSSOverflow.cs rename to csharp/Facebook.CSSLayout/YogaOverflow.cs index 7207668d..89bef500 100644 --- a/csharp/Facebook.CSSLayout/CSSOverflow.cs +++ b/csharp/Facebook.CSSLayout/YogaOverflow.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSOverflow + public enum YogaOverflow { Visible, Hidden, diff --git a/csharp/Facebook.CSSLayout/CSSPositionType.cs b/csharp/Facebook.CSSLayout/YogaPositionType.cs similarity index 92% rename from csharp/Facebook.CSSLayout/CSSPositionType.cs rename to csharp/Facebook.CSSLayout/YogaPositionType.cs index 11b9ebde..7f76b6a3 100644 --- a/csharp/Facebook.CSSLayout/CSSPositionType.cs +++ b/csharp/Facebook.CSSLayout/YogaPositionType.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSPositionType + public enum YogaPositionType { Relative, Absolute, diff --git a/csharp/Facebook.CSSLayout/CSSPrintOptions.cs b/csharp/Facebook.CSSLayout/YogaPrintOptions.cs similarity index 92% rename from csharp/Facebook.CSSLayout/CSSPrintOptions.cs rename to csharp/Facebook.CSSLayout/YogaPrintOptions.cs index 1df7d381..a52f38e8 100644 --- a/csharp/Facebook.CSSLayout/CSSPrintOptions.cs +++ b/csharp/Facebook.CSSLayout/YogaPrintOptions.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSPrintOptions + public enum YogaPrintOptions { Layout = 1, Style = 2, diff --git a/csharp/Facebook.CSSLayout/CSSWrap.cs b/csharp/Facebook.CSSLayout/YogaWrap.cs similarity index 93% rename from csharp/Facebook.CSSLayout/CSSWrap.cs rename to csharp/Facebook.CSSLayout/YogaWrap.cs index 34d2e4c2..df6d30bb 100644 --- a/csharp/Facebook.CSSLayout/CSSWrap.cs +++ b/csharp/Facebook.CSSLayout/YogaWrap.cs @@ -9,7 +9,7 @@ namespace Facebook.CSSLayout { - public enum CSSWrap + public enum YogaWrap { NoWrap, Wrap, diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index 0e3086d1..d058942c 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -25,13 +25,13 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10f); - root_child0.SetPosition(CSSEdge.Top, 10f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Start, 10f); + root_child0.SetPosition(YogaEdge.Top, 10f); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -44,7 +44,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -66,13 +66,13 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.End, 10f); - root_child0.SetPosition(CSSEdge.Bottom, 10f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.End, 10f); + root_child0.SetPosition(YogaEdge.Bottom, 10f); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -107,13 +107,13 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10f); - root_child0.SetPosition(CSSEdge.Top, 10f); - root_child0.SetPosition(CSSEdge.End, 10f); - root_child0.SetPosition(CSSEdge.Bottom, 10f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Start, 10f); + root_child0.SetPosition(YogaEdge.Top, 10f); + root_child0.SetPosition(YogaEdge.End, 10f); + root_child0.SetPosition(YogaEdge.Bottom, 10f); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -126,7 +126,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -148,15 +148,15 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 10f); - root_child0.SetPosition(CSSEdge.Top, 10f); - root_child0.SetPosition(CSSEdge.End, 10f); - root_child0.SetPosition(CSSEdge.Bottom, 10f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Start, 10f); + root_child0.SetPosition(YogaEdge.Top, 10f); + root_child0.SetPosition(YogaEdge.End, 10f); + root_child0.SetPosition(YogaEdge.Bottom, 10f); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -169,7 +169,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -187,22 +187,22 @@ namespace Facebook.CSSLayout public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.Overflow = CSSOverflow.Hidden; + root.FlexDirection = YogaFlexDirection.Row; + root.Overflow = YogaOverflow.Hidden; root.Width = 50f; root.Height = 50f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Start, 0f); - root_child0.SetPosition(CSSEdge.Top, 0f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Start, 0f); + root_child0.SetPosition(YogaEdge.Top, 0f); root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.Width = 100f; root_child0_child0.Height = 100f; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -220,7 +220,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -243,37 +243,37 @@ namespace Facebook.CSSLayout public void Test_absolute_layout_within_border() { CSSNode root = new CSSNode(); - root.SetMargin(CSSEdge.Left, 10f); - root.SetMargin(CSSEdge.Top, 10f); - root.SetMargin(CSSEdge.Right, 10f); - root.SetMargin(CSSEdge.Bottom, 10f); - root.SetPadding(CSSEdge.Left, 10f); - root.SetPadding(CSSEdge.Top, 10f); - root.SetPadding(CSSEdge.Right, 10f); - root.SetPadding(CSSEdge.Bottom, 10f); - root.SetBorder(CSSEdge.Left, 10f); - root.SetBorder(CSSEdge.Top, 10f); - root.SetBorder(CSSEdge.Right, 10f); - root.SetBorder(CSSEdge.Bottom, 10f); + root.SetMargin(YogaEdge.Left, 10f); + root.SetMargin(YogaEdge.Top, 10f); + root.SetMargin(YogaEdge.Right, 10f); + root.SetMargin(YogaEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10f); + root.SetPadding(YogaEdge.Top, 10f); + root.SetPadding(YogaEdge.Right, 10f); + root.SetPadding(YogaEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10f); + root.SetBorder(YogaEdge.Top, 10f); + root.SetBorder(YogaEdge.Right, 10f); + root.SetBorder(YogaEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.PositionType = CSSPositionType.Absolute; - root_child0.SetPosition(CSSEdge.Left, 0f); - root_child0.SetPosition(CSSEdge.Top, 0f); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.SetPosition(YogaEdge.Left, 0f); + root_child0.SetPosition(YogaEdge.Top, 0f); root_child0.Width = 50f; root_child0.Height = 50f; root.Insert(0, root_child0); CSSNode root_child1 = new CSSNode(); - root_child1.PositionType = CSSPositionType.Absolute; - root_child1.SetPosition(CSSEdge.Right, 0f); - root_child1.SetPosition(CSSEdge.Bottom, 0f); + root_child1.PositionType = YogaPositionType.Absolute; + root_child1.SetPosition(YogaEdge.Right, 0f); + root_child1.SetPosition(YogaEdge.Bottom, 0f); root_child1.Width = 50f; root_child1.Height = 50f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(10f, root.LayoutX); @@ -291,7 +291,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(10f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs index d2735862..c17d2b0a 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs @@ -21,7 +21,7 @@ namespace Facebook.CSSLayout public void Test_align_content_flex_start() { CSSNode root = new CSSNode(); - root.Wrap = CSSWrap.Wrap; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; @@ -49,7 +49,7 @@ namespace Facebook.CSSLayout root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -82,7 +82,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child4.LayoutWidth); Assert.AreEqual(10f, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -120,8 +120,8 @@ namespace Facebook.CSSLayout public void Test_align_content_flex_end() { CSSNode root = new CSSNode(); - root.AlignContent = CSSAlign.FlexEnd; - root.Wrap = CSSWrap.Wrap; + root.AlignContent = YogaAlign.FlexEnd; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; @@ -149,7 +149,7 @@ namespace Facebook.CSSLayout root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -182,7 +182,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child4.LayoutWidth); Assert.AreEqual(10f, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -220,8 +220,8 @@ namespace Facebook.CSSLayout public void Test_align_content_center() { CSSNode root = new CSSNode(); - root.AlignContent = CSSAlign.Center; - root.Wrap = CSSWrap.Wrap; + root.AlignContent = YogaAlign.Center; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; @@ -249,7 +249,7 @@ namespace Facebook.CSSLayout root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -282,7 +282,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child4.LayoutWidth); Assert.AreEqual(10f, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -320,8 +320,8 @@ namespace Facebook.CSSLayout public void Test_align_content_stretch() { CSSNode root = new CSSNode(); - root.AlignContent = CSSAlign.Stretch; - root.Wrap = CSSWrap.Wrap; + root.AlignContent = YogaAlign.Stretch; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; @@ -344,7 +344,7 @@ namespace Facebook.CSSLayout CSSNode root_child4 = new CSSNode(); root_child4.Width = 50f; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -377,7 +377,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child4.LayoutWidth); Assert.AreEqual(0f, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs index e7ce8095..cf2ac0ed 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs @@ -27,7 +27,7 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -40,7 +40,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -58,7 +58,7 @@ namespace Facebook.CSSLayout public void Test_align_items_center() { CSSNode root = new CSSNode(); - root.AlignItems = CSSAlign.Center; + root.AlignItems = YogaAlign.Center; root.Width = 100f; root.Height = 100f; @@ -66,7 +66,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -79,7 +79,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -97,7 +97,7 @@ namespace Facebook.CSSLayout public void Test_align_items_flex_start() { CSSNode root = new CSSNode(); - root.AlignItems = CSSAlign.FlexStart; + root.AlignItems = YogaAlign.FlexStart; root.Width = 100f; root.Height = 100f; @@ -105,7 +105,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -118,7 +118,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -136,7 +136,7 @@ namespace Facebook.CSSLayout public void Test_align_items_flex_end() { CSSNode root = new CSSNode(); - root.AlignItems = CSSAlign.FlexEnd; + root.AlignItems = YogaAlign.FlexEnd; root.Width = 100f; root.Height = 100f; @@ -144,7 +144,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -157,7 +157,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs index 3cb9e7a0..c7fdc958 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs @@ -25,11 +25,11 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.AlignSelf = CSSAlign.Center; + root_child0.AlignSelf = YogaAlign.Center; root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -42,7 +42,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -64,11 +64,11 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.AlignSelf = CSSAlign.FlexEnd; + root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -81,7 +81,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -103,11 +103,11 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.AlignSelf = CSSAlign.FlexStart; + root_child0.AlignSelf = YogaAlign.FlexStart; root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -120,7 +120,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -138,16 +138,16 @@ namespace Facebook.CSSLayout public void Test_align_self_flex_end_override_flex_start() { CSSNode root = new CSSNode(); - root.AlignItems = CSSAlign.FlexStart; + root.AlignItems = YogaAlign.FlexStart; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.AlignSelf = CSSAlign.FlexEnd; + root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -160,7 +160,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs index 2a2d263d..fab4b731 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs @@ -21,11 +21,11 @@ namespace Facebook.CSSLayout public void Test_border_no_size() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10f); - root.SetBorder(CSSEdge.Top, 10f); - root.SetBorder(CSSEdge.Right, 10f); - root.SetBorder(CSSEdge.Bottom, 10f); - root.StyleDirection = CSSDirection.LTR; + root.SetBorder(YogaEdge.Left, 10f); + root.SetBorder(YogaEdge.Top, 10f); + root.SetBorder(YogaEdge.Right, 10f); + root.SetBorder(YogaEdge.Bottom, 10f); + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -33,7 +33,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20f, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -46,16 +46,16 @@ namespace Facebook.CSSLayout public void Test_border_container_match_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10f); - root.SetBorder(CSSEdge.Top, 10f); - root.SetBorder(CSSEdge.Right, 10f); - root.SetBorder(CSSEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10f); + root.SetBorder(YogaEdge.Top, 10f); + root.SetBorder(YogaEdge.Right, 10f); + root.SetBorder(YogaEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -68,7 +68,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -86,10 +86,10 @@ namespace Facebook.CSSLayout public void Test_border_flex_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10f); - root.SetBorder(CSSEdge.Top, 10f); - root.SetBorder(CSSEdge.Right, 10f); - root.SetBorder(CSSEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10f); + root.SetBorder(YogaEdge.Top, 10f); + root.SetBorder(YogaEdge.Right, 10f); + root.SetBorder(YogaEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; @@ -97,7 +97,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1f; root_child0.Width = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -110,7 +110,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -128,17 +128,17 @@ namespace Facebook.CSSLayout public void Test_border_stretch_child() { CSSNode root = new CSSNode(); - root.SetBorder(CSSEdge.Left, 10f); - root.SetBorder(CSSEdge.Top, 10f); - root.SetBorder(CSSEdge.Right, 10f); - root.SetBorder(CSSEdge.Bottom, 10f); + root.SetBorder(YogaEdge.Left, 10f); + root.SetBorder(YogaEdge.Top, 10f); + root.SetBorder(YogaEdge.Right, 10f); + root.SetBorder(YogaEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -151,7 +151,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -169,11 +169,11 @@ namespace Facebook.CSSLayout public void Test_border_center_child() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.Center; - root.AlignItems = CSSAlign.Center; - root.SetBorder(CSSEdge.Start, 10f); - root.SetBorder(CSSEdge.End, 20f); - root.SetBorder(CSSEdge.Bottom, 20f); + root.JustifyContent = YogaJustify.Center; + root.AlignItems = YogaAlign.Center; + root.SetBorder(YogaEdge.Start, 10f); + root.SetBorder(YogaEdge.End, 20f); + root.SetBorder(YogaEdge.Bottom, 20f); root.Width = 100f; root.Height = 100f; @@ -181,7 +181,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -194,7 +194,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs index 0658e3bc..81d639b0 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs @@ -34,7 +34,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -57,7 +57,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout public void Test_flex_direction_row_no_width() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Height = 100f; CSSNode root_child0 = new CSSNode(); @@ -99,7 +99,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -122,7 +122,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -164,7 +164,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -187,7 +187,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -215,7 +215,7 @@ namespace Facebook.CSSLayout public void Test_flex_direction_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -230,7 +230,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -253,7 +253,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -281,7 +281,7 @@ namespace Facebook.CSSLayout public void Test_flex_direction_column_reverse() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.ColumnReverse; + root.FlexDirection = YogaFlexDirection.ColumnReverse; root.Width = 100f; root.Height = 100f; @@ -296,7 +296,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -319,7 +319,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -347,7 +347,7 @@ namespace Facebook.CSSLayout public void Test_flex_direction_row_reverse() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.RowReverse; + root.FlexDirection = YogaFlexDirection.RowReverse; root.Width = 100f; root.Height = 100f; @@ -362,7 +362,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -385,7 +385,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs index 27c8099c..995eec52 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs @@ -32,7 +32,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -50,7 +50,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child1.LayoutWidth); Assert.AreEqual(25f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -73,7 +73,7 @@ namespace Facebook.CSSLayout public void Test_flex_basis_flex_grow_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -103,7 +103,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(25f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -137,7 +137,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexBasis = 50f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -155,7 +155,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -178,7 +178,7 @@ namespace Facebook.CSSLayout public void Test_flex_basis_flex_shrink_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -190,7 +190,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexBasis = 50f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -208,7 +208,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -248,7 +248,7 @@ namespace Facebook.CSSLayout root_child2.Width = 50f; root_child2.Height = 50f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -271,7 +271,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -317,7 +317,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -340,7 +340,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(20f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -378,7 +378,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexShrink = 1f; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -396,7 +396,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0_child0.LayoutWidth); Assert.AreEqual(0f, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs index 3f52a8fb..7ea50ec3 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs @@ -21,7 +21,7 @@ namespace Facebook.CSSLayout public void Test_wrap_column() { CSSNode root = new CSSNode(); - root.Wrap = CSSWrap.Wrap; + root.Wrap = YogaWrap.Wrap; root.Height = 100f; CSSNode root_child0 = new CSSNode(); @@ -43,7 +43,7 @@ namespace Facebook.CSSLayout root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -71,7 +71,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30f, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -104,8 +104,8 @@ namespace Facebook.CSSLayout public void Test_wrap_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.Wrap = CSSWrap.Wrap; + root.FlexDirection = YogaFlexDirection.Row; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; CSSNode root_child0 = new CSSNode(); @@ -127,7 +127,7 @@ namespace Facebook.CSSLayout root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -155,7 +155,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30f, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -188,9 +188,9 @@ namespace Facebook.CSSLayout public void Test_wrap_row_align_items_flex_end() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.AlignItems = CSSAlign.FlexEnd; - root.Wrap = CSSWrap.Wrap; + root.FlexDirection = YogaFlexDirection.Row; + root.AlignItems = YogaAlign.FlexEnd; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; CSSNode root_child0 = new CSSNode(); @@ -212,7 +212,7 @@ namespace Facebook.CSSLayout root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -240,7 +240,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30f, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -273,9 +273,9 @@ namespace Facebook.CSSLayout public void Test_wrap_row_align_items_center() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.AlignItems = CSSAlign.Center; - root.Wrap = CSSWrap.Wrap; + root.FlexDirection = YogaFlexDirection.Row; + root.AlignItems = YogaAlign.Center; + root.Wrap = YogaWrap.Wrap; root.Width = 100f; CSSNode root_child0 = new CSSNode(); @@ -297,7 +297,7 @@ namespace Facebook.CSSLayout root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -325,7 +325,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(30f, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs index 849b2be1..1a2a3ea7 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs @@ -21,7 +21,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_row_flex_start() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 102f; root.Height = 102f; @@ -36,7 +36,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -59,7 +59,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(102f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -87,8 +87,8 @@ namespace Facebook.CSSLayout public void Test_justify_content_row_flex_end() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.JustifyContent = CSSJustify.FlexEnd; + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102f; root.Height = 102f; @@ -103,7 +103,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -126,7 +126,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(102f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -154,8 +154,8 @@ namespace Facebook.CSSLayout public void Test_justify_content_row_center() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.JustifyContent = CSSJustify.Center; + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.Center; root.Width = 102f; root.Height = 102f; @@ -170,7 +170,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -193,7 +193,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(102f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -221,8 +221,8 @@ namespace Facebook.CSSLayout public void Test_justify_content_row_space_between() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.JustifyContent = CSSJustify.SpaceBetween; + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102f; root.Height = 102f; @@ -237,7 +237,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -260,7 +260,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(102f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -288,8 +288,8 @@ namespace Facebook.CSSLayout public void Test_justify_content_row_space_around() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.JustifyContent = CSSJustify.SpaceAround; + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102f; root.Height = 102f; @@ -304,7 +304,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Width = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -327,7 +327,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child2.LayoutWidth); Assert.AreEqual(102f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -368,7 +368,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -391,7 +391,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -419,7 +419,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_column_flex_end() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.FlexEnd; + root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102f; root.Height = 102f; @@ -434,7 +434,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -457,7 +457,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -485,7 +485,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_column_center() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.Center; + root.JustifyContent = YogaJustify.Center; root.Width = 102f; root.Height = 102f; @@ -500,7 +500,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -523,7 +523,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -551,7 +551,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_column_space_between() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.SpaceBetween; + root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102f; root.Height = 102f; @@ -566,7 +566,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -589,7 +589,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -617,7 +617,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_column_space_around() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.SpaceAround; + root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102f; root.Height = 102f; @@ -632,7 +632,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -655,7 +655,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs index a7791c07..e6030df8 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs @@ -21,15 +21,15 @@ namespace Facebook.CSSLayout public void Test_margin_start() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Start, 10f); + root_child0.SetMargin(YogaEdge.Start, 10f); root_child0.Width = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -42,7 +42,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -64,10 +64,10 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Top, 10f); + root_child0.SetMargin(YogaEdge.Top, 10f); root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -80,7 +80,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -98,16 +98,16 @@ namespace Facebook.CSSLayout public void Test_margin_end() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; - root.JustifyContent = CSSJustify.FlexEnd; + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.End, 10f); + root_child0.SetMargin(YogaEdge.End, 10f); root_child0.Width = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -120,7 +120,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -138,15 +138,15 @@ namespace Facebook.CSSLayout public void Test_margin_bottom() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.FlexEnd; + root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.SetMargin(CSSEdge.Bottom, 10f); + root_child0.SetMargin(YogaEdge.Bottom, 10f); root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -159,7 +159,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -177,15 +177,15 @@ namespace Facebook.CSSLayout public void Test_margin_and_flex_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.SetMargin(CSSEdge.Start, 10f); + root_child0.SetMargin(YogaEdge.Start, 10f); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -198,7 +198,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(90f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -221,9 +221,9 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.SetMargin(CSSEdge.Top, 10f); + root_child0.SetMargin(YogaEdge.Top, 10f); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -236,7 +236,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -254,15 +254,15 @@ namespace Facebook.CSSLayout public void Test_margin_and_stretch_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.SetMargin(CSSEdge.Top, 10f); + root_child0.SetMargin(YogaEdge.Top, 10f); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -275,7 +275,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -298,9 +298,9 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.FlexGrow = 1f; - root_child0.SetMargin(CSSEdge.Start, 10f); + root_child0.SetMargin(YogaEdge.Start, 10f); root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -313,7 +313,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(90f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -331,7 +331,7 @@ namespace Facebook.CSSLayout public void Test_margin_with_sibling_row() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -342,7 +342,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -360,7 +360,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -393,7 +393,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -411,7 +411,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs index 3b88d4f1..dcfa7f1a 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs @@ -28,7 +28,7 @@ namespace Facebook.CSSLayout root_child0.MaxWidth = 50f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -41,7 +41,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -59,7 +59,7 @@ namespace Facebook.CSSLayout public void Test_max_height() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -67,7 +67,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.MaxHeight = 50f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -80,7 +80,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -109,7 +109,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -127,7 +127,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child1.LayoutWidth); Assert.AreEqual(20f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -150,7 +150,7 @@ namespace Facebook.CSSLayout public void Test_min_width() { CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -162,7 +162,7 @@ namespace Facebook.CSSLayout CSSNode root_child1 = new CSSNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -180,7 +180,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -203,7 +203,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_min_max() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.Center; + root.JustifyContent = YogaJustify.Center; root.Width = 100f; root.MinHeight = 100f; root.MaxHeight = 200f; @@ -212,7 +212,7 @@ namespace Facebook.CSSLayout root_child0.Width = 60f; root_child0.Height = 60f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -225,7 +225,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(60f, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -243,7 +243,7 @@ namespace Facebook.CSSLayout public void Test_align_items_min_max() { CSSNode root = new CSSNode(); - root.AlignItems = CSSAlign.Center; + root.AlignItems = YogaAlign.Center; root.MinWidth = 100f; root.MaxWidth = 200f; root.Height = 100f; @@ -252,7 +252,7 @@ namespace Facebook.CSSLayout root_child0.Width = 60f; root_child0.Height = 60f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -265,7 +265,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(60f, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -283,7 +283,7 @@ namespace Facebook.CSSLayout public void Test_justify_content_overflow_min_max() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.Center; + root.JustifyContent = YogaJustify.Center; root.MinHeight = 100f; root.MaxHeight = 110f; @@ -301,7 +301,7 @@ namespace Facebook.CSSLayout root_child2.Width = 50f; root_child2.Height = 50f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -324,7 +324,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(50f, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -356,7 +356,7 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexDirection = CSSFlexDirection.Row; + root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 100f; root.Insert(0, root_child0); @@ -364,7 +364,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1f; root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -382,7 +382,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0_child0.LayoutWidth); Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -409,7 +409,7 @@ namespace Facebook.CSSLayout root.Height = 100f; CSSNode root_child0 = new CSSNode(); - root_child0.FlexDirection = CSSFlexDirection.Row; + root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 300f; root.Insert(0, root_child0); @@ -417,7 +417,7 @@ namespace Facebook.CSSLayout root_child0_child0.FlexGrow = 1f; root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -435,7 +435,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(200f, root_child0_child0.LayoutWidth); Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs index 02a5fa15..c9ec0ae6 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs @@ -21,11 +21,11 @@ namespace Facebook.CSSLayout public void Test_padding_no_size() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10f); - root.SetPadding(CSSEdge.Top, 10f); - root.SetPadding(CSSEdge.Right, 10f); - root.SetPadding(CSSEdge.Bottom, 10f); - root.StyleDirection = CSSDirection.LTR; + root.SetPadding(YogaEdge.Left, 10f); + root.SetPadding(YogaEdge.Top, 10f); + root.SetPadding(YogaEdge.Right, 10f); + root.SetPadding(YogaEdge.Bottom, 10f); + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -33,7 +33,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(20f, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -46,16 +46,16 @@ namespace Facebook.CSSLayout public void Test_padding_container_match_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10f); - root.SetPadding(CSSEdge.Top, 10f); - root.SetPadding(CSSEdge.Right, 10f); - root.SetPadding(CSSEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10f); + root.SetPadding(YogaEdge.Top, 10f); + root.SetPadding(YogaEdge.Right, 10f); + root.SetPadding(YogaEdge.Bottom, 10f); CSSNode root_child0 = new CSSNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -68,7 +68,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -86,10 +86,10 @@ namespace Facebook.CSSLayout public void Test_padding_flex_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10f); - root.SetPadding(CSSEdge.Top, 10f); - root.SetPadding(CSSEdge.Right, 10f); - root.SetPadding(CSSEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10f); + root.SetPadding(YogaEdge.Top, 10f); + root.SetPadding(YogaEdge.Right, 10f); + root.SetPadding(YogaEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; @@ -97,7 +97,7 @@ namespace Facebook.CSSLayout root_child0.FlexGrow = 1f; root_child0.Width = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -110,7 +110,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -128,17 +128,17 @@ namespace Facebook.CSSLayout public void Test_padding_stretch_child() { CSSNode root = new CSSNode(); - root.SetPadding(CSSEdge.Left, 10f); - root.SetPadding(CSSEdge.Top, 10f); - root.SetPadding(CSSEdge.Right, 10f); - root.SetPadding(CSSEdge.Bottom, 10f); + root.SetPadding(YogaEdge.Left, 10f); + root.SetPadding(YogaEdge.Top, 10f); + root.SetPadding(YogaEdge.Right, 10f); + root.SetPadding(YogaEdge.Bottom, 10f); root.Width = 100f; root.Height = 100f; CSSNode root_child0 = new CSSNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -151,7 +151,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(80f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -169,11 +169,11 @@ namespace Facebook.CSSLayout public void Test_padding_center_child() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.Center; - root.AlignItems = CSSAlign.Center; - root.SetPadding(CSSEdge.Start, 10f); - root.SetPadding(CSSEdge.End, 20f); - root.SetPadding(CSSEdge.Bottom, 20f); + root.JustifyContent = YogaJustify.Center; + root.AlignItems = YogaAlign.Center; + root.SetPadding(YogaEdge.Start, 10f); + root.SetPadding(YogaEdge.End, 20f); + root.SetPadding(YogaEdge.Bottom, 20f); root.Width = 100f; root.Height = 100f; @@ -181,7 +181,7 @@ namespace Facebook.CSSLayout root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -194,7 +194,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -212,20 +212,20 @@ namespace Facebook.CSSLayout public void Test_child_with_padding_align_end() { CSSNode root = new CSSNode(); - root.JustifyContent = CSSJustify.FlexEnd; - root.AlignItems = CSSAlign.FlexEnd; + root.JustifyContent = YogaJustify.FlexEnd; + root.AlignItems = YogaAlign.FlexEnd; root.Width = 200f; root.Height = 200f; CSSNode root_child0 = new CSSNode(); - root_child0.SetPadding(CSSEdge.Left, 20f); - root_child0.SetPadding(CSSEdge.Top, 20f); - root_child0.SetPadding(CSSEdge.Right, 20f); - root_child0.SetPadding(CSSEdge.Bottom, 20f); + root_child0.SetPadding(YogaEdge.Left, 20f); + root_child0.SetPadding(YogaEdge.Top, 20f); + root_child0.SetPadding(YogaEdge.Right, 20f); + root_child0.SetPadding(YogaEdge.Bottom, 20f); root_child0.Width = 100f; root_child0.Height = 100f; root.Insert(0, root_child0); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -238,7 +238,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs index cfd11f1e..36b255de 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs @@ -20,10 +20,10 @@ namespace Facebook.CSSLayout [Test] public void Test_rounding_flex_basis_flex_grow_row_width_of_100() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; @@ -38,7 +38,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.FlexGrow = 1f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -61,7 +61,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(33f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -84,16 +84,16 @@ namespace Facebook.CSSLayout Assert.AreEqual(33f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_grow_row_prime_number_width() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 113f; root.Height = 100f; @@ -116,7 +116,7 @@ namespace Facebook.CSSLayout CSSNode root_child4 = new CSSNode(); root_child4.FlexGrow = 1f; root.Insert(4, root_child4); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -149,7 +149,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(23f, root_child4.LayoutWidth); Assert.AreEqual(100f, root_child4.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -182,16 +182,16 @@ namespace Facebook.CSSLayout Assert.AreEqual(23f, root_child4.LayoutWidth); Assert.AreEqual(100f, root_child4.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_shrink_row() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.FlexDirection = CSSFlexDirection.Row; + root.FlexDirection = YogaFlexDirection.Row; root.Width = 101f; root.Height = 100f; @@ -207,7 +207,7 @@ namespace Facebook.CSSLayout CSSNode root_child2 = new CSSNode(); root_child2.FlexBasis = 25f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -230,7 +230,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(25f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -253,13 +253,13 @@ namespace Facebook.CSSLayout Assert.AreEqual(25f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_overrides_main_size() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); root.Width = 100f; @@ -280,7 +280,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -303,7 +303,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -326,13 +326,13 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); root.Width = 87.4f; @@ -353,7 +353,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -376,7 +376,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -399,13 +399,13 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial_nested() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); root.Width = 87.4f; @@ -420,14 +420,14 @@ namespace Facebook.CSSLayout CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexBasis = 0.3f; - root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f); + root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f); root_child0_child0.Height = 9.9f; root_child0.Insert(0, root_child0_child0); CSSNode root_child0_child1 = new CSSNode(); root_child0_child1.FlexGrow = 4f; root_child0_child1.FlexBasis = 0.3f; - root_child0_child1.SetPosition(CSSEdge.Top, 13.3f); + root_child0_child1.SetPosition(YogaEdge.Top, 13.3f); root_child0_child1.Height = 1.1f; root_child0.Insert(1, root_child0_child1); @@ -440,7 +440,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -473,7 +473,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -506,13 +506,13 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_1() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); root.Width = 100f; @@ -533,7 +533,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -556,7 +556,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -579,13 +579,13 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_2() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); root.Width = 100f; @@ -606,7 +606,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -629,7 +629,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(25f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -652,16 +652,16 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(25f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_3() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.SetPosition(CSSEdge.Top, 0.3f); + root.SetPosition(YogaEdge.Top, 0.3f); root.Width = 100f; root.Height = 113.4f; @@ -680,7 +680,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -703,7 +703,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -726,16 +726,16 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_4() { - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); CSSNode root = new CSSNode(); - root.SetPosition(CSSEdge.Top, 0.7f); + root.SetPosition(YogaEdge.Top, 0.7f); root.Width = 100f; root.Height = 113.4f; @@ -754,7 +754,7 @@ namespace Facebook.CSSLayout root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); - root.StyleDirection = CSSDirection.LTR; + root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -777,7 +777,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - root.StyleDirection = CSSDirection.RTL; + root.StyleDirection = YogaDirection.RTL; root.CalculateLayout(); Assert.AreEqual(0f, root.LayoutX); @@ -800,7 +800,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false); + CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs index 96481d0f..e2e8363d 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs @@ -22,8 +22,8 @@ namespace Facebook.CSSLayout public void TestSimple() { CSSNode nodeDefault = new CSSNode(); - CSSNode nodeCreated = CSSNode.Create(flexDirection: CSSFlexDirection.Row); - Assert.AreEqual(CSSFlexDirection.Row, nodeCreated.FlexDirection); + CSSNode nodeCreated = CSSNode.Create(flexDirection: YogaFlexDirection.Row); + Assert.AreEqual(YogaFlexDirection.Row, nodeCreated.FlexDirection); Assert.IsFalse(nodeDefault.IsDirty); nodeDefault.CopyStyle(nodeCreated); Assert.IsTrue(nodeDefault.IsDirty); @@ -43,39 +43,39 @@ namespace Facebook.CSSLayout public void TestMultiple() { CSSNode node = CSSNode.Create( - positionType: CSSPositionType.Absolute, - wrap: CSSWrap.Wrap, + positionType: YogaPositionType.Absolute, + wrap: YogaWrap.Wrap, position: new Spacing(top:6, right:4), margin: new Spacing(bottom:5, left:3)); - Assert.AreEqual(CSSFlexDirection.Column, node.FlexDirection); - Assert.AreEqual(CSSPositionType.Absolute, node.PositionType); - Assert.AreEqual(CSSWrap.Wrap, node.Wrap); - Assert.AreEqual(6, node.GetPosition(CSSEdge.Top)); - Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Bottom))); - Assert.AreEqual(4, node.GetPosition(CSSEdge.Right)); - Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Left))); - Assert.AreEqual(0, node.GetMargin(CSSEdge.Top)); - Assert.AreEqual(5, node.GetMargin(CSSEdge.Bottom)); - Assert.AreEqual(3, node.GetMargin(CSSEdge.Left)); - Assert.AreEqual(0, node.GetMargin(CSSEdge.Right)); + Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection); + Assert.AreEqual(YogaPositionType.Absolute, node.PositionType); + Assert.AreEqual(YogaWrap.Wrap, node.Wrap); + Assert.AreEqual(6, node.GetPosition(YogaEdge.Top)); + Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom))); + Assert.AreEqual(4, node.GetPosition(YogaEdge.Right)); + Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left))); + Assert.AreEqual(0, node.GetMargin(YogaEdge.Top)); + Assert.AreEqual(5, node.GetMargin(YogaEdge.Bottom)); + Assert.AreEqual(3, node.GetMargin(YogaEdge.Left)); + Assert.AreEqual(0, node.GetMargin(YogaEdge.Right)); } [Test] public void TestFull() { CSSNode node = CSSNode.Create( - styleDirection: CSSDirection.RTL, - flexDirection: CSSFlexDirection.RowReverse, + styleDirection: YogaDirection.RTL, + flexDirection: YogaFlexDirection.RowReverse, - justifyContent: CSSJustify.SpaceAround, - alignContent: CSSAlign.Center, - alignItems: CSSAlign.FlexEnd, - alignSelf: CSSAlign.Stretch, + justifyContent: YogaJustify.SpaceAround, + alignContent: YogaAlign.Center, + alignItems: YogaAlign.FlexEnd, + alignSelf: YogaAlign.Stretch, - positionType: CSSPositionType.Absolute, - wrap: CSSWrap.Wrap, - overflow: CSSOverflow.Scroll, + positionType: YogaPositionType.Absolute, + wrap: YogaWrap.Wrap, + overflow: YogaOverflow.Scroll, flex: 1, flexGrow: 2, @@ -94,43 +94,43 @@ namespace Facebook.CSSLayout maxWidth: 25, maxHeight: 26); - Assert.AreEqual(CSSDirection.RTL, node.StyleDirection); - Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection); + Assert.AreEqual(YogaDirection.RTL, node.StyleDirection); + Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection); - Assert.AreEqual(CSSJustify.SpaceAround, node.JustifyContent); - Assert.AreEqual(CSSAlign.Center, node.AlignContent); - Assert.AreEqual(CSSAlign.FlexEnd, node.AlignItems); - Assert.AreEqual(CSSAlign.Stretch, node.AlignSelf); + Assert.AreEqual(YogaJustify.SpaceAround, node.JustifyContent); + Assert.AreEqual(YogaAlign.Center, node.AlignContent); + Assert.AreEqual(YogaAlign.FlexEnd, node.AlignItems); + Assert.AreEqual(YogaAlign.Stretch, node.AlignSelf); - Assert.AreEqual(CSSPositionType.Absolute, node.PositionType); - Assert.AreEqual(CSSWrap.Wrap, node.Wrap); - Assert.AreEqual(CSSOverflow.Scroll, node.Overflow); + Assert.AreEqual(YogaPositionType.Absolute, node.PositionType); + Assert.AreEqual(YogaWrap.Wrap, node.Wrap); + Assert.AreEqual(YogaOverflow.Scroll, node.Overflow); Assert.AreEqual(2, node.FlexGrow); Assert.AreEqual(3, node.FlexShrink); Assert.AreEqual(4, node.FlexBasis); - node.FlexGrow = CSSConstants.Undefined; + node.FlexGrow = YogaConstants.Undefined; Assert.AreEqual(1, node.FlexGrow); - Assert.AreEqual(5, node.GetPosition(CSSEdge.Top)); - Assert.AreEqual(6, node.GetPosition(CSSEdge.Bottom)); - Assert.AreEqual(7, node.GetPosition(CSSEdge.Left)); - Assert.AreEqual(8, node.GetPosition(CSSEdge.Right)); + Assert.AreEqual(5, node.GetPosition(YogaEdge.Top)); + Assert.AreEqual(6, node.GetPosition(YogaEdge.Bottom)); + Assert.AreEqual(7, node.GetPosition(YogaEdge.Left)); + Assert.AreEqual(8, node.GetPosition(YogaEdge.Right)); - Assert.AreEqual(9, node.GetMargin(CSSEdge.Top)); - Assert.AreEqual(10, node.GetMargin(CSSEdge.Bottom)); - Assert.AreEqual(11, node.GetMargin(CSSEdge.Left)); - Assert.AreEqual(12, node.GetMargin(CSSEdge.Right)); + Assert.AreEqual(9, node.GetMargin(YogaEdge.Top)); + Assert.AreEqual(10, node.GetMargin(YogaEdge.Bottom)); + Assert.AreEqual(11, node.GetMargin(YogaEdge.Left)); + Assert.AreEqual(12, node.GetMargin(YogaEdge.Right)); - Assert.AreEqual(13, node.GetPadding(CSSEdge.Top)); - Assert.AreEqual(14, node.GetPadding(CSSEdge.Bottom)); - Assert.AreEqual(15, node.GetPadding(CSSEdge.Left)); - Assert.AreEqual(16, node.GetPadding(CSSEdge.Right)); + Assert.AreEqual(13, node.GetPadding(YogaEdge.Top)); + Assert.AreEqual(14, node.GetPadding(YogaEdge.Bottom)); + Assert.AreEqual(15, node.GetPadding(YogaEdge.Left)); + Assert.AreEqual(16, node.GetPadding(YogaEdge.Right)); - Assert.AreEqual(17, node.GetBorder(CSSEdge.Top)); - Assert.AreEqual(18, node.GetBorder(CSSEdge.Bottom)); - Assert.AreEqual(19, node.GetBorder(CSSEdge.Left)); - Assert.AreEqual(20, node.GetBorder(CSSEdge.Right)); + Assert.AreEqual(17, node.GetBorder(YogaEdge.Top)); + Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom)); + Assert.AreEqual(19, node.GetBorder(YogaEdge.Left)); + Assert.AreEqual(20, node.GetBorder(YogaEdge.Right)); Assert.AreEqual(21, node.Width); Assert.AreEqual(22, node.Height); diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs index b56c6d43..42e83d39 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs @@ -219,7 +219,7 @@ namespace Facebook.CSSLayout public void TestCopyStyle() { CSSNode node0 = new CSSNode(); - Assert.IsTrue(CSSConstants.IsUndefined(node0.MaxHeight)); + Assert.IsTrue(YogaConstants.IsUndefined(node0.MaxHeight)); CSSNode node1 = new CSSNode(); node1.MaxHeight = 100; diff --git a/enums.py b/enums.py index 22e1b0ff..e54e49d6 100644 --- a/enums.py +++ b/enums.py @@ -12,54 +12,54 @@ from __future__ import unicode_literals import os ENUMS = { - 'CSSDirection': [ + 'Direction': [ 'Inherit', 'LTR', 'RTL', ], - 'CSSFlexDirection': [ + 'FlexDirection': [ 'Column', 'ColumnReverse', 'Row', 'RowReverse', ], - 'CSSJustify': [ + 'Justify': [ 'FlexStart', 'Center', 'FlexEnd', 'SpaceBetween', 'SpaceAround', ], - 'CSSOverflow': [ + 'Overflow': [ 'Visible', 'Hidden', 'Scroll', ], - 'CSSAlign': [ + 'Align': [ 'Auto', 'FlexStart', 'Center', 'FlexEnd', 'Stretch', ], - 'CSSPositionType': [ + 'PositionType': [ 'Relative', 'Absolute', ], - 'CSSWrap': [ + 'Wrap': [ 'NoWrap', 'Wrap', ], - 'CSSMeasureMode': [ + 'MeasureMode': [ 'Undefined', 'Exactly', 'AtMost', ], - 'CSSDimension': [ + 'Dimension': [ 'Width', 'Height', ], - 'CSSEdge': [ + 'Edge': [ 'Left', 'Top', 'Right', @@ -70,19 +70,19 @@ ENUMS = { 'Vertical', 'All', ], - 'CSSLogLevel': [ + 'LogLevel': [ 'Error', 'Warn', 'Info', 'Debug', 'Verbose', ], - 'CSSExperimentalFeature': [ + 'ExperimentalFeature': [ 'Rounding', # Mimic web flex-basis behavior. 'WebFlexBasis', ], - 'CSSPrintOptions': [ + 'PrintOptions': [ ('Layout', 1), ('Style', 2), ('Children', 4), @@ -118,26 +118,26 @@ with open(root + '/CSSLayout/CSSEnums.h', 'w') as f: f.write(LICENSE) remaining = len(ENUMS) for name, values in ENUMS.items(): - f.write('typedef enum %s {\n' % name) + f.write('typedef enum YG%s {\n' % name) for value in values: if isinstance(value, tuple): - f.write(' %s%s = %d,\n' % (name, value[0], value[1])) + f.write(' YG%s%s = %d,\n' % (name, value[0], value[1])) else: - f.write(' %s%s,\n' % (name, value)) - f.write(' %sCount,\n' % name) - f.write('} %s;\n' % name) + f.write(' YG%s%s,\n' % (name, value)) + f.write(' YG%sCount,\n' % name) + f.write('} YG%s;\n' % name) if remaining > 1: f.write('\n') remaining = remaining - 1 # write out java files for name, values in ENUMS.items(): - with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f: + with open(root + '/java/com/facebook/csslayout/Yoga%s.java' % name, 'w') as f: f.write(LICENSE) f.write('package com.facebook.csslayout;\n\n') f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n') f.write('@DoNotStrip\n') - f.write('public enum %s {\n' % name) + f.write('public enum Yoga%s {\n' % name) if len(values) > 0: for value in values: if isinstance(value, tuple): @@ -153,7 +153,7 @@ for name, values in ENUMS.items(): f.write('\n') f.write(' private int mIntValue;\n') f.write('\n') - f.write(' %s(int intValue) {\n' % name) + f.write(' Yoga%s(int intValue) {\n' % name) f.write(' mIntValue = intValue;\n') f.write(' }\n') f.write('\n') @@ -161,7 +161,7 @@ for name, values in ENUMS.items(): f.write(' return mIntValue;\n') f.write(' }\n') f.write('\n') - f.write(' public static %s fromInt(int value) {\n' % name) + f.write(' public static Yoga%s fromInt(int value) {\n' % name) f.write(' switch (value) {\n') for value in values: if isinstance(value, tuple): @@ -175,10 +175,10 @@ for name, values in ENUMS.items(): # write out csharp files for name, values in ENUMS.items(): - with open(root + '/csharp/Facebook.CSSLayout/%s.cs' % name, 'w') as f: + with open(root + '/csharp/Facebook.CSSLayout/Yoga%s.cs' % name, 'w') as f: f.write(LICENSE) f.write('namespace Facebook.CSSLayout\n{\n') - f.write(' public enum %s\n {\n' % name) + f.write(' public enum Yoga%s\n {\n' % name) for value in values: if isinstance(value, tuple): f.write(' %s = %d,\n' % (value[0], value[1])) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index fe655a7c..1d98f7df 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -32,7 +32,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', true);'); + this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);'); } this.push(''); } @@ -51,7 +51,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', false);'); + this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);'); } } @@ -69,47 +69,47 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');'); }}, - CSSAlignAuto:{value:'CSSAlignAuto'}, - CSSAlignCenter:{value:'CSSAlignCenter'}, - CSSAlignFlexEnd:{value:'CSSAlignFlexEnd'}, - CSSAlignFlexStart:{value:'CSSAlignFlexStart'}, - CSSAlignStretch:{value:'CSSAlignStretch'}, + YGAlignAuto:{value:'YGAlignAuto'}, + YGAlignCenter:{value:'YGAlignCenter'}, + YGAlignFlexEnd:{value:'YGAlignFlexEnd'}, + YGAlignFlexStart:{value:'YGAlignFlexStart'}, + YGAlignStretch:{value:'YGAlignStretch'}, - CSSDirectionInherit:{value:'CSSDirectionInherit'}, - CSSDirectionLTR:{value:'CSSDirectionLTR'}, - CSSDirectionRTL:{value:'CSSDirectionRTL'}, + YGDirectionInherit:{value:'YGDirectionInherit'}, + YGDirectionLTR:{value:'YGDirectionLTR'}, + YGDirectionRTL:{value:'YGDirectionRTL'}, - CSSEdgeBottom:{value:'CSSEdgeBottom'}, - CSSEdgeEnd:{value:'CSSEdgeEnd'}, - CSSEdgeLeft:{value:'CSSEdgeLeft'}, - CSSEdgeRight:{value:'CSSEdgeRight'}, - CSSEdgeStart:{value:'CSSEdgeStart'}, - CSSEdgeTop:{value:'CSSEdgeTop'}, + YGEdgeBottom:{value:'YGEdgeBottom'}, + YGEdgeEnd:{value:'YGEdgeEnd'}, + YGEdgeLeft:{value:'YGEdgeLeft'}, + YGEdgeRight:{value:'YGEdgeRight'}, + YGEdgeStart:{value:'YGEdgeStart'}, + YGEdgeTop:{value:'YGEdgeTop'}, - CSSFlexDirectionColumn:{value:'CSSFlexDirectionColumn'}, - CSSFlexDirectionColumnReverse:{value:'CSSFlexDirectionColumnReverse'}, - CSSFlexDirectionRow:{value:'CSSFlexDirectionRow'}, - CSSFlexDirectionRowReverse:{value:'CSSFlexDirectionRowReverse'}, + YGFlexDirectionColumn:{value:'YGFlexDirectionColumn'}, + YGFlexDirectionColumnReverse:{value:'YGFlexDirectionColumnReverse'}, + YGFlexDirectionRow:{value:'YGFlexDirectionRow'}, + YGFlexDirectionRowReverse:{value:'YGFlexDirectionRowReverse'}, - CSSJustifyCenter:{value:'CSSJustifyCenter'}, - CSSJustifyFlexEnd:{value:'CSSJustifyFlexEnd'}, - CSSJustifyFlexStart:{value:'CSSJustifyFlexStart'}, - CSSJustifySpaceAround:{value:'CSSJustifySpaceAround'}, - CSSJustifySpaceBetween:{value:'CSSJustifySpaceBetween'}, + YGJustifyCenter:{value:'YGJustifyCenter'}, + YGJustifyFlexEnd:{value:'YGJustifyFlexEnd'}, + YGJustifyFlexStart:{value:'YGJustifyFlexStart'}, + YGJustifySpaceAround:{value:'YGJustifySpaceAround'}, + YGJustifySpaceBetween:{value:'YGJustifySpaceBetween'}, - CSSOverflowHidden:{value:'CSSOverflowHidden'}, - CSSOverflowVisible:{value:'CSSOverflowVisible'}, + YGOverflowHidden:{value:'YGOverflowHidden'}, + YGOverflowVisible:{value:'YGOverflowVisible'}, - CSSPositionTypeAbsolute:{value:'CSSPositionTypeAbsolute'}, - CSSPositionTypeRelative:{value:'CSSPositionTypeRelative'}, + YGPositionTypeAbsolute:{value:'YGPositionTypeAbsolute'}, + YGPositionTypeRelative:{value:'YGPositionTypeRelative'}, - CSSWrapNoWrap:{value:'CSSWrapNoWrap'}, - CSSWrapWrap:{value:'CSSWrapWrap'}, + YGWrapNoWrap:{value:'YGWrapNoWrap'}, + YGWrapWrap:{value:'YGWrapWrap'}, - CSSUndefined:{value:'CSSUndefined'}, + YGUndefined:{value:'YGUndefined'}, CSSNodeCalculateLayout:{value:function(node, dir) { - this.push('CSSNodeCalculateLayout(' + node + ', CSSUndefined, CSSUndefined, ' + dir + ');'); + this.push('CSSNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');'); }}, CSSNodeInsertChild:{value:function(parentName, nodeName, index) { diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 4ceb2a2f..49c8e7cd 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -39,7 +39,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', true);'); + this.push('CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);'); } this.push(''); } @@ -53,7 +53,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', false);'); + this.push('CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', false);'); } } @@ -78,44 +78,44 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { this.push('Assert.AreEqual(' + v0 + 'f, ' + v1 + ');'); }}, - CSSAlignAuto:{value:'CSSAlign.Auto'}, - CSSAlignCenter:{value:'CSSAlign.Center'}, - CSSAlignFlexEnd:{value:'CSSAlign.FlexEnd'}, - CSSAlignFlexStart:{value:'CSSAlign.FlexStart'}, - CSSAlignStretch:{value:'CSSAlign.Stretch'}, + YGAlignAuto:{value:'YogaAlign.Auto'}, + YGAlignCenter:{value:'YogaAlign.Center'}, + YGAlignFlexEnd:{value:'YogaAlign.FlexEnd'}, + YGAlignFlexStart:{value:'YogaAlign.FlexStart'}, + YGAlignStretch:{value:'YogaAlign.Stretch'}, - CSSDirectionInherit:{value:'CSSDirection.Inherit'}, - CSSDirectionLTR:{value:'CSSDirection.LTR'}, - CSSDirectionRTL:{value:'CSSDirection.RTL'}, + YGDirectionInherit:{value:'YogaDirection.Inherit'}, + YGDirectionLTR:{value:'YogaDirection.LTR'}, + YGDirectionRTL:{value:'YogaDirection.RTL'}, - CSSEdgeBottom:{value:'CSSEdge.Bottom'}, - CSSEdgeEnd:{value:'CSSEdge.End'}, - CSSEdgeLeft:{value:'CSSEdge.Left'}, - CSSEdgeRight:{value:'CSSEdge.Right'}, - CSSEdgeStart:{value:'CSSEdge.Start'}, - CSSEdgeTop:{value:'CSSEdge.Top'}, + YGEdgeBottom:{value:'YogaEdge.Bottom'}, + YGEdgeEnd:{value:'YogaEdge.End'}, + YGEdgeLeft:{value:'YogaEdge.Left'}, + YGEdgeRight:{value:'YogaEdge.Right'}, + YGEdgeStart:{value:'YogaEdge.Start'}, + YGEdgeTop:{value:'YogaEdge.Top'}, - CSSFlexDirectionColumn:{value:'CSSFlexDirection.Column'}, - CSSFlexDirectionColumnReverse:{value:'CSSFlexDirection.ColumnReverse'}, - CSSFlexDirectionRow:{value:'CSSFlexDirection.Row'}, - CSSFlexDirectionRowReverse:{value:'CSSFlexDirection.RowReverse'}, + YGFlexDirectionColumn:{value:'YogaFlexDirection.Column'}, + YGFlexDirectionColumnReverse:{value:'YogaFlexDirection.ColumnReverse'}, + YGFlexDirectionRow:{value:'YogaFlexDirection.Row'}, + YGFlexDirectionRowReverse:{value:'YogaFlexDirection.RowReverse'}, - CSSJustifyCenter:{value:'CSSJustify.Center'}, - CSSJustifyFlexEnd:{value:'CSSJustify.FlexEnd'}, - CSSJustifyFlexStart:{value:'CSSJustify.FlexStart'}, - CSSJustifySpaceAround:{value:'CSSJustify.SpaceAround'}, - CSSJustifySpaceBetween:{value:'CSSJustify.SpaceBetween'}, + YGJustifyCenter:{value:'YogaJustify.Center'}, + YGJustifyFlexEnd:{value:'YogaJustify.FlexEnd'}, + YGJustifyFlexStart:{value:'YogaJustify.FlexStart'}, + YGJustifySpaceAround:{value:'YogaJustify.SpaceAround'}, + YGJustifySpaceBetween:{value:'YogaJustify.SpaceBetween'}, - CSSOverflowHidden:{value:'CSSOverflow.Hidden'}, - CSSOverflowVisible:{value:'CSSOverflow.Visible'}, + YGOverflowHidden:{value:'YogaOverflow.Hidden'}, + YGOverflowVisible:{value:'YogaOverflow.Visible'}, - CSSPositionTypeAbsolute:{value:'CSSPositionType.Absolute'}, - CSSPositionTypeRelative:{value:'CSSPositionType.Relative'}, + YGPositionTypeAbsolute:{value:'YogaPositionType.Absolute'}, + YGPositionTypeRelative:{value:'YogaPositionType.Relative'}, - CSSUndefined:{value:'CSSConstants.Undefined'}, + YGUndefined:{value:'YogaConstants.Undefined'}, - CSSWrapNoWrap:{value:'CSSWrap.NoWrap'}, - CSSWrapWrap:{value:'CSSWrap.Wrap'}, + YGWrapNoWrap:{value:'YogaWrap.NoWrap'}, + YGWrapWrap:{value:'YogaWrap.Wrap'}, CSSNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.StyleDirection = ' + dir + ';'); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 83cc8f24..48b2b82c 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -46,7 +46,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); + this.push('CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); } this.push(''); } @@ -60,7 +60,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); + this.push('CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); } } @@ -83,44 +83,44 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { this.push('assertEquals(' + v0 + 'f, ' + v1 + ', 0.0f);'); }}, - CSSAlignAuto:{value:'CSSAlign.AUTO'}, - CSSAlignCenter:{value:'CSSAlign.CENTER'}, - CSSAlignFlexEnd:{value:'CSSAlign.FLEX_END'}, - CSSAlignFlexStart:{value:'CSSAlign.FLEX_START'}, - CSSAlignStretch:{value:'CSSAlign.STRETCH'}, + YGAlignAuto:{value:'YogaAlign.AUTO'}, + YGAlignCenter:{value:'YogaAlign.CENTER'}, + YGAlignFlexEnd:{value:'YogaAlign.FLEX_END'}, + YGAlignFlexStart:{value:'YogaAlign.FLEX_START'}, + YGAlignStretch:{value:'YogaAlign.STRETCH'}, - CSSDirectionInherit:{value:'CSSDirection.INHERIT'}, - CSSDirectionLTR:{value:'CSSDirection.LTR'}, - CSSDirectionRTL:{value:'CSSDirection.RTL'}, + YGDirectionInherit:{value:'YogaDirection.INHERIT'}, + YGDirectionLTR:{value:'YogaDirection.LTR'}, + YGDirectionRTL:{value:'YogaDirection.RTL'}, - CSSEdgeBottom:{value:'CSSEdge.BOTTOM'}, - CSSEdgeEnd:{value:'CSSEdge.END'}, - CSSEdgeLeft:{value:'CSSEdge.LEFT'}, - CSSEdgeRight:{value:'CSSEdge.RIGHT'}, - CSSEdgeStart:{value:'CSSEdge.START'}, - CSSEdgeTop:{value:'CSSEdge.TOP'}, + YGEdgeBottom:{value:'YogaEdge.BOTTOM'}, + YGEdgeEnd:{value:'YogaEdge.END'}, + YGEdgeLeft:{value:'YogaEdge.LEFT'}, + YGEdgeRight:{value:'YogaEdge.RIGHT'}, + YGEdgeStart:{value:'YogaEdge.START'}, + YGEdgeTop:{value:'YogaEdge.TOP'}, - CSSFlexDirectionColumn:{value:'CSSFlexDirection.COLUMN'}, - CSSFlexDirectionColumnReverse:{value:'CSSFlexDirection.COLUMN_REVERSE'}, - CSSFlexDirectionRow:{value:'CSSFlexDirection.ROW'}, - CSSFlexDirectionRowReverse:{value:'CSSFlexDirection.ROW_REVERSE'}, + YGFlexDirectionColumn:{value:'YogaFlexDirection.COLUMN'}, + YGFlexDirectionColumnReverse:{value:'YogaFlexDirection.COLUMN_REVERSE'}, + YGFlexDirectionRow:{value:'YogaFlexDirection.ROW'}, + YGFlexDirectionRowReverse:{value:'YogaFlexDirection.ROW_REVERSE'}, - CSSJustifyCenter:{value:'CSSJustify.CENTER'}, - CSSJustifyFlexEnd:{value:'CSSJustify.FLEX_END'}, - CSSJustifyFlexStart:{value:'CSSJustify.FLEX_START'}, - CSSJustifySpaceAround:{value:'CSSJustify.SPACE_AROUND'}, - CSSJustifySpaceBetween:{value:'CSSJustify.SPACE_BETWEEN'}, + YGJustifyCenter:{value:'YogaJustify.CENTER'}, + YGJustifyFlexEnd:{value:'YogaJustify.FLEX_END'}, + YGJustifyFlexStart:{value:'YogaJustify.FLEX_START'}, + YGJustifySpaceAround:{value:'YogaJustify.SPACE_AROUND'}, + YGJustifySpaceBetween:{value:'YogaJustify.SPACE_BETWEEN'}, - CSSOverflowHidden:{value:'CSSOverflow.HIDDEN'}, - CSSOverflowVisible:{value:'CSSOverflow.VISIBLE'}, + YGOverflowHidden:{value:'YogaOverflow.HIDDEN'}, + YGOverflowVisible:{value:'YogaOverflow.VISIBLE'}, - CSSPositionTypeAbsolute:{value:'CSSPositionType.ABSOLUTE'}, - CSSPositionTypeRelative:{value:'CSSPositionType.RELATIVE'}, + YGPositionTypeAbsolute:{value:'YogaPositionType.ABSOLUTE'}, + YGPositionTypeRelative:{value:'YogaPositionType.RELATIVE'}, - CSSUndefined:{value:'CSSConstants.UNDEFINED'}, + YGUndefined:{value:'YogaConstants.UNDEFINED'}, - CSSWrapNoWrap:{value:'CSSWrap.NO_WRAP'}, - CSSWrapWrap:{value:'CSSWrap.WRAP'}, + YGWrapNoWrap:{value:'YogaWrap.NO_WRAP'}, + YGWrapWrap:{value:'YogaWrap.WRAP'}, CSSNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.setDirection(' + dir + ');'); diff --git a/gentest/gentest.js b/gentest/gentest.js index 02f44609..ed6fd6b9 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -87,13 +87,13 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) { 'root', null); - e.CSSNodeCalculateLayout('root', e.CSSDirectionLTR); + e.CSSNodeCalculateLayout('root', e.YGDirectionLTR); e.push(''); assertTestTree(e, LTRLayoutTree[i], 'root', null); e.push(''); - e.CSSNodeCalculateLayout('root', e.CSSDirectionRTL); + e.CSSNodeCalculateLayout('root', e.YGDirectionRTL); e.push(''); assertTestTree(e, RTLLayoutTree[i], 'root', null); @@ -119,7 +119,7 @@ function assertTestTree(e, node, nodeName, parentName) { } function checkDefaultValues() { - // Sanity check of the CSSLayout default values by test-template.html + // Sanity check of the Yoga default values by test-template.html [ {style:'flex-direction', value:'column'}, {style:'justify-content', value:'flex-start'}, @@ -198,83 +198,83 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index break; case 'left': if (genericNode.rawStyle.indexOf('start:') >= 0) { - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeStart, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeLeft, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'top': - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeTop, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'right': if (genericNode.rawStyle.indexOf('end:') >= 0) { - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeEnd, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeRight, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'bottom': - e.CSSNodeStyleSetPosition(nodeName, e.CSSEdgeBottom, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'margin-left': if (genericNode.rawStyle.indexOf('margin-start:') >= 0) { - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeStart, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeLeft, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'margin-top': - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeTop, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'margin-right': if (genericNode.rawStyle.indexOf('margin-end:') >= 0) { - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeEnd, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeRight, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'margin-bottom': - e.CSSNodeStyleSetMargin(nodeName, e.CSSEdgeBottom, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'padding-left': if (genericNode.rawStyle.indexOf('padding-start:') >= 0) { - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeStart, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeLeft, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'padding-top': - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeTop, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'padding-right': if (genericNode.rawStyle.indexOf('padding-end:') >= 0) { - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeEnd, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeRight, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'padding-bottom': - e.CSSNodeStyleSetPadding(nodeName, e.CSSEdgeBottom, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'border-left-width': if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) { - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeStart, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeLeft, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'border-top-width': - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeTop, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'border-right-width': if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) { - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeEnd, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeRight, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'border-bottom-width': - e.CSSNodeStyleSetBorder(nodeName, e.CSSEdgeBottom, pixelValue(e, node.style[style])); + e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'width': e.CSSNodeStyleSetWidth(nodeName, pixelValue(e, node.style[style])); @@ -318,66 +318,66 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index function overflowValue(e, value) { switch (value) { - case 'visible': return e.CSSOverflowVisible; - case 'hidden': return e.CSSOverflowHidden; + case 'visible': return e.YGOverflowVisible; + case 'hidden': return e.YGOverflowHidden; } } function wrapValue(e, value) { switch (value) { - case 'wrap': return e.CSSWrapWrap; - case 'nowrap': return e.CSSWrapNoWrap; + case 'wrap': return e.YGWrapWrap; + case 'nowrap': return e.YGWrapNoWrap; } } function flexDirectionValue(e, value) { switch (value) { - case 'row': return e.CSSFlexDirectionRow; - case 'row-reverse': return e.CSSFlexDirectionRowReverse; - case 'column': return e.CSSFlexDirectionColumn; - case 'column-reverse': return e.CSSFlexDirectionColumnReverse; + case 'row': return e.YGFlexDirectionRow; + case 'row-reverse': return e.YGFlexDirectionRowReverse; + case 'column': return e.YGFlexDirectionColumn; + case 'column-reverse': return e.YGFlexDirectionColumnReverse; } } function justifyValue(e, value) { switch (value) { - case 'center': return e.CSSJustifyCenter; - case 'space-around': return e.CSSJustifySpaceAround; - case 'space-between': return e.CSSJustifySpaceBetween; - case 'flex-start': return e.CSSJustifyFlexStart; - case 'flex-end': return e.CSSJustifyFlexEnd; + case 'center': return e.YGJustifyCenter; + case 'space-around': return e.YGJustifySpaceAround; + case 'space-between': return e.YGJustifySpaceBetween; + case 'flex-start': return e.YGJustifyFlexStart; + case 'flex-end': return e.YGJustifyFlexEnd; } } function positionValue(e, value) { switch (value) { - case 'absolute': return e.CSSPositionTypeAbsolute; - default: return e.CSSPositionTypeRelative + case 'absolute': return e.YGPositionTypeAbsolute; + default: return e.YGPositionTypeRelative } } function directionValue(e, value) { switch (value) { - case 'ltr': return e.CSSDirectionLTR; - case 'rtl': return e.CSSDirectionRTL; - case 'inherit': return e.CSSDirectionInherit; + case 'ltr': return e.YGDirectionLTR; + case 'rtl': return e.YGDirectionRTL; + case 'inherit': return e.YGDirectionInherit; } } function alignValue(e, value) { switch (value) { - case 'auto': return e.CSSAlignAuto; - case 'center': return e.CSSAlignCenter; - case 'stretch': return e.CSSAlignStretch; - case 'flex-start': return e.CSSAlignFlexStart; - case 'flex-end': return e.CSSAlignFlexEnd; + case 'auto': return e.YGAlignAuto; + case 'center': return e.YGAlignCenter; + case 'stretch': return e.YGAlignStretch; + case 'flex-start': return e.YGAlignFlexStart; + case 'flex-end': return e.YGAlignFlexEnd; } } function pixelValue(e, value) { switch (value) { - case 'auto': return e.CSSUndefined; - case 'undefined': return e.CSSUndefined; + case 'auto': return e.YGUndefined; + case 'undefined': return e.YGUndefined; default: return value.replace('px', ''); } } diff --git a/java/com/facebook/csslayout/CSSLogger.java b/java/com/facebook/csslayout/CSSLogger.java index d270e39f..c751768f 100644 --- a/java/com/facebook/csslayout/CSSLogger.java +++ b/java/com/facebook/csslayout/CSSLogger.java @@ -13,10 +13,10 @@ import com.facebook.proguard.annotations.DoNotStrip; /** * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); - * See CSSLogLevel for the different log levels. + * See YogaLogLevel for the different log levels. */ @DoNotStrip public interface CSSLogger { @DoNotStrip - void log(CSSLogLevel level, String message); + void log(YogaLogLevel level, String message); } diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/CSSNode.java index 47939fe6..1fc2af87 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/CSSNode.java @@ -39,13 +39,13 @@ public class CSSNode implements CSSNodeAPI { int feature, boolean enabled); public static void setExperimentalFeatureEnabled( - CSSExperimentalFeature feature, + YogaExperimentalFeature feature, boolean enabled) { jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled); } private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature); - public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) { + public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) { return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue()); } @@ -61,13 +61,13 @@ public class CSSNode implements CSSNodeAPI { private boolean mHasSetPosition = false; @DoNotStrip - private float mWidth = CSSConstants.UNDEFINED; + private float mWidth = YogaConstants.UNDEFINED; @DoNotStrip - private float mHeight = CSSConstants.UNDEFINED; + private float mHeight = YogaConstants.UNDEFINED; @DoNotStrip - private float mTop = CSSConstants.UNDEFINED; + private float mTop = YogaConstants.UNDEFINED; @DoNotStrip - private float mLeft = CSSConstants.UNDEFINED; + private float mLeft = YogaConstants.UNDEFINED; @DoNotStrip private int mLayoutDirection = 0; @@ -97,10 +97,10 @@ public class CSSNode implements CSSNodeAPI { mHasSetBorder = false; mHasSetPosition = false; - mWidth = CSSConstants.UNDEFINED; - mHeight = CSSConstants.UNDEFINED; - mTop = CSSConstants.UNDEFINED; - mLeft = CSSConstants.UNDEFINED; + mWidth = YogaConstants.UNDEFINED; + mHeight = YogaConstants.UNDEFINED; + mTop = YogaConstants.UNDEFINED; + mLeft = YogaConstants.UNDEFINED; mLayoutDirection = 0; mMeasureFunction = null; @@ -193,103 +193,103 @@ public class CSSNode implements CSSNodeAPI { private native int jni_CSSNodeStyleGetDirection(long nativePointer); @Override - public CSSDirection getStyleDirection() { - return CSSDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)]; + public YogaDirection getStyleDirection() { + return YogaDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)]; } private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction); @Override - public void setDirection(CSSDirection direction) { + public void setDirection(YogaDirection direction) { jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue()); } private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer); @Override - public CSSFlexDirection getFlexDirection() { - return CSSFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)]; + public YogaFlexDirection getFlexDirection() { + return YogaFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)]; } private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection); @Override - public void setFlexDirection(CSSFlexDirection flexDirection) { + public void setFlexDirection(YogaFlexDirection flexDirection) { jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue()); } private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer); @Override - public CSSJustify getJustifyContent() { - return CSSJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)]; + public YogaJustify getJustifyContent() { + return YogaJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)]; } private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent); @Override - public void setJustifyContent(CSSJustify justifyContent) { + public void setJustifyContent(YogaJustify justifyContent) { jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue()); } private native int jni_CSSNodeStyleGetAlignItems(long nativePointer); @Override - public CSSAlign getAlignItems() { - return CSSAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)]; + public YogaAlign getAlignItems() { + return YogaAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)]; } private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems); @Override - public void setAlignItems(CSSAlign alignItems) { + public void setAlignItems(YogaAlign alignItems) { jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue()); } private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer); @Override - public CSSAlign getAlignSelf() { - return CSSAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)]; + public YogaAlign getAlignSelf() { + return YogaAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)]; } private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf); @Override - public void setAlignSelf(CSSAlign alignSelf) { + public void setAlignSelf(YogaAlign alignSelf) { jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue()); } private native int jni_CSSNodeStyleGetAlignContent(long nativePointer); @Override - public CSSAlign getAlignContent() { - return CSSAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)]; + public YogaAlign getAlignContent() { + return YogaAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)]; } private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent); @Override - public void setAlignContent(CSSAlign alignContent) { + public void setAlignContent(YogaAlign alignContent) { jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue()); } private native int jni_CSSNodeStyleGetPositionType(long nativePointer); @Override - public CSSPositionType getPositionType() { - return CSSPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)]; + public YogaPositionType getPositionType() { + return YogaPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)]; } private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType); @Override - public void setPositionType(CSSPositionType positionType) { + public void setPositionType(YogaPositionType positionType) { jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue()); } private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType); @Override - public void setWrap(CSSWrap flexWrap) { + public void setWrap(YogaWrap flexWrap) { jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue()); } private native int jni_CSSNodeStyleGetOverflow(long nativePointer); @Override - public CSSOverflow getOverflow() { - return CSSOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)]; + public YogaOverflow getOverflow() { + return YogaOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)]; } private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow); @Override - public void setOverflow(CSSOverflow overflow) { + public void setOverflow(YogaOverflow overflow) { jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue()); } @@ -337,64 +337,64 @@ public class CSSNode implements CSSNodeAPI { private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge); @Override - public float getMargin(CSSEdge edge) { + public float getMargin(YogaEdge edge) { if (!mHasSetMargin) { - return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin); @Override - public void setMargin(CSSEdge edge, float margin) { + public void setMargin(YogaEdge edge, float margin) { mHasSetMargin = true; jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); } private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge); @Override - public float getPadding(CSSEdge edge) { + public float getPadding(YogaEdge edge) { if (!mHasSetPadding) { - return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding); @Override - public void setPadding(CSSEdge edge, float padding) { + public void setPadding(YogaEdge edge, float padding) { mHasSetPadding = true; jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); } private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge); @Override - public float getBorder(CSSEdge edge) { + public float getBorder(YogaEdge edge) { if (!mHasSetBorder) { - return edge.intValue() < CSSEdge.START.intValue() ? 0 : CSSConstants.UNDEFINED; + return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; } return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border); @Override - public void setBorder(CSSEdge edge, float border) { + public void setBorder(YogaEdge edge, float border) { mHasSetBorder = true; jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border); } private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge); @Override - public float getPosition(CSSEdge edge) { + public float getPosition(YogaEdge edge) { if (!mHasSetPosition) { - return CSSConstants.UNDEFINED; + return YogaConstants.UNDEFINED; } return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue()); } private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position); @Override - public void setPosition(CSSEdge edge, float position) { + public void setPosition(YogaEdge edge, float position) { mHasSetPosition = true; jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position); } @@ -502,8 +502,8 @@ public class CSSNode implements CSSNodeAPI { } @Override - public CSSDirection getLayoutDirection() { - return CSSDirection.values()[mLayoutDirection]; + public YogaDirection getLayoutDirection() { + return YogaDirection.values()[mLayoutDirection]; } private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc); @@ -527,9 +527,9 @@ public class CSSNode implements CSSNodeAPI { return mMeasureFunction.measure( this, width, - CSSMeasureMode.values()[widthMode], + YogaMeasureMode.values()[widthMode], height, - CSSMeasureMode.values()[heightMode]); + YogaMeasureMode.values()[heightMode]); } @Override diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/CSSNodeAPI.java index 8e5d19d5..3c13015a 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/CSSNodeAPI.java @@ -18,9 +18,9 @@ public interface CSSNodeAPI { long measure( CSSNodeAPI node, float width, - CSSMeasureMode widthMode, + YogaMeasureMode widthMode, float height, - CSSMeasureMode heightMode); + YogaMeasureMode heightMode); } int getChildCount(); @@ -37,21 +37,21 @@ public interface CSSNodeAPI { void dirty(); void markLayoutSeen(); void copyStyle(CSSNodeType srcNode); - CSSDirection getStyleDirection(); - void setDirection(CSSDirection direction); - CSSFlexDirection getFlexDirection(); - void setFlexDirection(CSSFlexDirection flexDirection); - CSSJustify getJustifyContent(); - void setJustifyContent(CSSJustify justifyContent); - CSSAlign getAlignItems(); - void setAlignItems(CSSAlign alignItems); - CSSAlign getAlignSelf(); - void setAlignSelf(CSSAlign alignSelf); - CSSAlign getAlignContent(); - void setAlignContent(CSSAlign alignContent); - CSSPositionType getPositionType(); - void setPositionType(CSSPositionType positionType); - void setWrap(CSSWrap flexWrap); + YogaDirection getStyleDirection(); + void setDirection(YogaDirection direction); + YogaFlexDirection getFlexDirection(); + void setFlexDirection(YogaFlexDirection flexDirection); + YogaJustify getJustifyContent(); + void setJustifyContent(YogaJustify justifyContent); + YogaAlign getAlignItems(); + void setAlignItems(YogaAlign alignItems); + YogaAlign getAlignSelf(); + void setAlignSelf(YogaAlign alignSelf); + YogaAlign getAlignContent(); + void setAlignContent(YogaAlign alignContent); + YogaPositionType getPositionType(); + void setPositionType(YogaPositionType positionType); + void setWrap(YogaWrap flexWrap); void setFlex(float flex); float getFlexGrow(); void setFlexGrow(float flexGrow); @@ -59,14 +59,14 @@ public interface CSSNodeAPI { void setFlexShrink(float flexShrink); float getFlexBasis(); void setFlexBasis(float flexBasis); - float getMargin(CSSEdge edge); - void setMargin(CSSEdge edge, float margin); - float getPadding(CSSEdge edge); - void setPadding(CSSEdge edge, float padding); - float getBorder(CSSEdge edge); - void setBorder(CSSEdge edge, float border); - float getPosition(CSSEdge edge); - void setPosition(CSSEdge edge, float position); + float getMargin(YogaEdge edge); + void setMargin(YogaEdge edge, float margin); + float getPadding(YogaEdge edge); + void setPadding(YogaEdge edge, float padding); + float getBorder(YogaEdge edge); + void setBorder(YogaEdge edge, float border); + float getPosition(YogaEdge edge); + void setPosition(YogaEdge edge, float position); float getWidth(); void setWidth(float width); float getHeight(); @@ -83,9 +83,9 @@ public interface CSSNodeAPI { float getLayoutY(); float getLayoutWidth(); float getLayoutHeight(); - CSSDirection getLayoutDirection(); - CSSOverflow getOverflow(); - void setOverflow(CSSOverflow overflow); + YogaDirection getLayoutDirection(); + YogaOverflow getOverflow(); + void setOverflow(YogaOverflow overflow); void setData(Object data); Object getData(); void reset(); diff --git a/java/com/facebook/csslayout/CSSAlign.java b/java/com/facebook/csslayout/YogaAlign.java similarity index 89% rename from java/com/facebook/csslayout/CSSAlign.java rename to java/com/facebook/csslayout/YogaAlign.java index 4f4af8cb..0ad38450 100644 --- a/java/com/facebook/csslayout/CSSAlign.java +++ b/java/com/facebook/csslayout/YogaAlign.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSAlign { +public enum YogaAlign { AUTO(0), FLEX_START(1), CENTER(2), @@ -21,7 +21,7 @@ public enum CSSAlign { private int mIntValue; - CSSAlign(int intValue) { + YogaAlign(int intValue) { mIntValue = intValue; } @@ -29,7 +29,7 @@ public enum CSSAlign { return mIntValue; } - public static CSSAlign fromInt(int value) { + public static YogaAlign fromInt(int value) { switch (value) { case 0: return AUTO; case 1: return FLEX_START; diff --git a/java/com/facebook/csslayout/CSSConstants.java b/java/com/facebook/csslayout/YogaConstants.java similarity index 94% rename from java/com/facebook/csslayout/CSSConstants.java rename to java/com/facebook/csslayout/YogaConstants.java index 01a0d597..03db3feb 100644 --- a/java/com/facebook/csslayout/CSSConstants.java +++ b/java/com/facebook/csslayout/YogaConstants.java @@ -9,7 +9,7 @@ package com.facebook.csslayout; -public class CSSConstants { +public class YogaConstants { public static final float UNDEFINED = Float.NaN; diff --git a/java/com/facebook/csslayout/CSSDimension.java b/java/com/facebook/csslayout/YogaDimension.java similarity index 86% rename from java/com/facebook/csslayout/CSSDimension.java rename to java/com/facebook/csslayout/YogaDimension.java index 77785ea6..a73f49c8 100644 --- a/java/com/facebook/csslayout/CSSDimension.java +++ b/java/com/facebook/csslayout/YogaDimension.java @@ -12,13 +12,13 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSDimension { +public enum YogaDimension { WIDTH(0), HEIGHT(1); private int mIntValue; - CSSDimension(int intValue) { + YogaDimension(int intValue) { mIntValue = intValue; } @@ -26,7 +26,7 @@ public enum CSSDimension { return mIntValue; } - public static CSSDimension fromInt(int value) { + public static YogaDimension fromInt(int value) { switch (value) { case 0: return WIDTH; case 1: return HEIGHT; diff --git a/java/com/facebook/csslayout/CSSDirection.java b/java/com/facebook/csslayout/YogaDirection.java similarity index 87% rename from java/com/facebook/csslayout/CSSDirection.java rename to java/com/facebook/csslayout/YogaDirection.java index 38916ea5..2c0473aa 100644 --- a/java/com/facebook/csslayout/CSSDirection.java +++ b/java/com/facebook/csslayout/YogaDirection.java @@ -12,14 +12,14 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSDirection { +public enum YogaDirection { INHERIT(0), LTR(1), RTL(2); private int mIntValue; - CSSDirection(int intValue) { + YogaDirection(int intValue) { mIntValue = intValue; } @@ -27,7 +27,7 @@ public enum CSSDirection { return mIntValue; } - public static CSSDirection fromInt(int value) { + public static YogaDirection fromInt(int value) { switch (value) { case 0: return INHERIT; case 1: return LTR; diff --git a/java/com/facebook/csslayout/CSSEdge.java b/java/com/facebook/csslayout/YogaEdge.java similarity index 91% rename from java/com/facebook/csslayout/CSSEdge.java rename to java/com/facebook/csslayout/YogaEdge.java index 8fe6a2fb..811297f0 100644 --- a/java/com/facebook/csslayout/CSSEdge.java +++ b/java/com/facebook/csslayout/YogaEdge.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSEdge { +public enum YogaEdge { LEFT(0), TOP(1), RIGHT(2), @@ -25,7 +25,7 @@ public enum CSSEdge { private int mIntValue; - CSSEdge(int intValue) { + YogaEdge(int intValue) { mIntValue = intValue; } @@ -33,7 +33,7 @@ public enum CSSEdge { return mIntValue; } - public static CSSEdge fromInt(int value) { + public static YogaEdge fromInt(int value) { switch (value) { case 0: return LEFT; case 1: return TOP; diff --git a/java/com/facebook/csslayout/CSSExperimentalFeature.java b/java/com/facebook/csslayout/YogaExperimentalFeature.java similarity index 83% rename from java/com/facebook/csslayout/CSSExperimentalFeature.java rename to java/com/facebook/csslayout/YogaExperimentalFeature.java index 3489e919..f0d91f0b 100644 --- a/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/java/com/facebook/csslayout/YogaExperimentalFeature.java @@ -12,13 +12,13 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSExperimentalFeature { +public enum YogaExperimentalFeature { ROUNDING(0), WEB_FLEX_BASIS(1); private int mIntValue; - CSSExperimentalFeature(int intValue) { + YogaExperimentalFeature(int intValue) { mIntValue = intValue; } @@ -26,7 +26,7 @@ public enum CSSExperimentalFeature { return mIntValue; } - public static CSSExperimentalFeature fromInt(int value) { + public static YogaExperimentalFeature fromInt(int value) { switch (value) { case 0: return ROUNDING; case 1: return WEB_FLEX_BASIS; diff --git a/java/com/facebook/csslayout/CSSFlexDirection.java b/java/com/facebook/csslayout/YogaFlexDirection.java similarity index 86% rename from java/com/facebook/csslayout/CSSFlexDirection.java rename to java/com/facebook/csslayout/YogaFlexDirection.java index 3047516d..b16128db 100644 --- a/java/com/facebook/csslayout/CSSFlexDirection.java +++ b/java/com/facebook/csslayout/YogaFlexDirection.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSFlexDirection { +public enum YogaFlexDirection { COLUMN(0), COLUMN_REVERSE(1), ROW(2), @@ -20,7 +20,7 @@ public enum CSSFlexDirection { private int mIntValue; - CSSFlexDirection(int intValue) { + YogaFlexDirection(int intValue) { mIntValue = intValue; } @@ -28,7 +28,7 @@ public enum CSSFlexDirection { return mIntValue; } - public static CSSFlexDirection fromInt(int value) { + public static YogaFlexDirection fromInt(int value) { switch (value) { case 0: return COLUMN; case 1: return COLUMN_REVERSE; diff --git a/java/com/facebook/csslayout/CSSJustify.java b/java/com/facebook/csslayout/YogaJustify.java similarity index 89% rename from java/com/facebook/csslayout/CSSJustify.java rename to java/com/facebook/csslayout/YogaJustify.java index 2c9abc6b..eb328dd4 100644 --- a/java/com/facebook/csslayout/CSSJustify.java +++ b/java/com/facebook/csslayout/YogaJustify.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSJustify { +public enum YogaJustify { FLEX_START(0), CENTER(1), FLEX_END(2), @@ -21,7 +21,7 @@ public enum CSSJustify { private int mIntValue; - CSSJustify(int intValue) { + YogaJustify(int intValue) { mIntValue = intValue; } @@ -29,7 +29,7 @@ public enum CSSJustify { return mIntValue; } - public static CSSJustify fromInt(int value) { + public static YogaJustify fromInt(int value) { switch (value) { case 0: return FLEX_START; case 1: return CENTER; diff --git a/java/com/facebook/csslayout/CSSLogLevel.java b/java/com/facebook/csslayout/YogaLogLevel.java similarity index 88% rename from java/com/facebook/csslayout/CSSLogLevel.java rename to java/com/facebook/csslayout/YogaLogLevel.java index 9d54b1eb..75d74e08 100644 --- a/java/com/facebook/csslayout/CSSLogLevel.java +++ b/java/com/facebook/csslayout/YogaLogLevel.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSLogLevel { +public enum YogaLogLevel { ERROR(0), WARN(1), INFO(2), @@ -21,7 +21,7 @@ public enum CSSLogLevel { private int mIntValue; - CSSLogLevel(int intValue) { + YogaLogLevel(int intValue) { mIntValue = intValue; } @@ -29,7 +29,7 @@ public enum CSSLogLevel { return mIntValue; } - public static CSSLogLevel fromInt(int value) { + public static YogaLogLevel fromInt(int value) { switch (value) { case 0: return ERROR; case 1: return WARN; diff --git a/java/com/facebook/csslayout/CSSMeasureMode.java b/java/com/facebook/csslayout/YogaMeasureMode.java similarity index 86% rename from java/com/facebook/csslayout/CSSMeasureMode.java rename to java/com/facebook/csslayout/YogaMeasureMode.java index 5b14c7dd..6ea9d038 100644 --- a/java/com/facebook/csslayout/CSSMeasureMode.java +++ b/java/com/facebook/csslayout/YogaMeasureMode.java @@ -12,14 +12,14 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSMeasureMode { +public enum YogaMeasureMode { UNDEFINED(0), EXACTLY(1), AT_MOST(2); private int mIntValue; - CSSMeasureMode(int intValue) { + YogaMeasureMode(int intValue) { mIntValue = intValue; } @@ -27,7 +27,7 @@ public enum CSSMeasureMode { return mIntValue; } - public static CSSMeasureMode fromInt(int value) { + public static YogaMeasureMode fromInt(int value) { switch (value) { case 0: return UNDEFINED; case 1: return EXACTLY; diff --git a/java/com/facebook/csslayout/CSSOverflow.java b/java/com/facebook/csslayout/YogaOverflow.java similarity index 87% rename from java/com/facebook/csslayout/CSSOverflow.java rename to java/com/facebook/csslayout/YogaOverflow.java index df6bedd7..0fa04bb4 100644 --- a/java/com/facebook/csslayout/CSSOverflow.java +++ b/java/com/facebook/csslayout/YogaOverflow.java @@ -12,14 +12,14 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSOverflow { +public enum YogaOverflow { VISIBLE(0), HIDDEN(1), SCROLL(2); private int mIntValue; - CSSOverflow(int intValue) { + YogaOverflow(int intValue) { mIntValue = intValue; } @@ -27,7 +27,7 @@ public enum CSSOverflow { return mIntValue; } - public static CSSOverflow fromInt(int value) { + public static YogaOverflow fromInt(int value) { switch (value) { case 0: return VISIBLE; case 1: return HIDDEN; diff --git a/java/com/facebook/csslayout/CSSPositionType.java b/java/com/facebook/csslayout/YogaPositionType.java similarity index 85% rename from java/com/facebook/csslayout/CSSPositionType.java rename to java/com/facebook/csslayout/YogaPositionType.java index 01eeece6..0215c627 100644 --- a/java/com/facebook/csslayout/CSSPositionType.java +++ b/java/com/facebook/csslayout/YogaPositionType.java @@ -12,13 +12,13 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSPositionType { +public enum YogaPositionType { RELATIVE(0), ABSOLUTE(1); private int mIntValue; - CSSPositionType(int intValue) { + YogaPositionType(int intValue) { mIntValue = intValue; } @@ -26,7 +26,7 @@ public enum CSSPositionType { return mIntValue; } - public static CSSPositionType fromInt(int value) { + public static YogaPositionType fromInt(int value) { switch (value) { case 0: return RELATIVE; case 1: return ABSOLUTE; diff --git a/java/com/facebook/csslayout/CSSPrintOptions.java b/java/com/facebook/csslayout/YogaPrintOptions.java similarity index 86% rename from java/com/facebook/csslayout/CSSPrintOptions.java rename to java/com/facebook/csslayout/YogaPrintOptions.java index 49cbc25e..fae22f0a 100644 --- a/java/com/facebook/csslayout/CSSPrintOptions.java +++ b/java/com/facebook/csslayout/YogaPrintOptions.java @@ -12,14 +12,14 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSPrintOptions { +public enum YogaPrintOptions { LAYOUT(1), STYLE(2), CHILDREN(4); private int mIntValue; - CSSPrintOptions(int intValue) { + YogaPrintOptions(int intValue) { mIntValue = intValue; } @@ -27,7 +27,7 @@ public enum CSSPrintOptions { return mIntValue; } - public static CSSPrintOptions fromInt(int value) { + public static YogaPrintOptions fromInt(int value) { switch (value) { case 1: return LAYOUT; case 2: return STYLE; diff --git a/java/com/facebook/csslayout/CSSWrap.java b/java/com/facebook/csslayout/YogaWrap.java similarity index 88% rename from java/com/facebook/csslayout/CSSWrap.java rename to java/com/facebook/csslayout/YogaWrap.java index 52a7aaf8..8a371d5e 100644 --- a/java/com/facebook/csslayout/CSSWrap.java +++ b/java/com/facebook/csslayout/YogaWrap.java @@ -12,13 +12,13 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip -public enum CSSWrap { +public enum YogaWrap { NO_WRAP(0), WRAP(1); private int mIntValue; - CSSWrap(int intValue) { + YogaWrap(int intValue) { mIntValue = intValue; } @@ -26,7 +26,7 @@ public enum CSSWrap { return mIntValue; } - public static CSSWrap fromInt(int value) { + public static YogaWrap fromInt(int value) { switch (value) { case 0: return NO_WRAP; case 1: return WRAP; diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 67946869..1a01570d 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -40,7 +40,7 @@ static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) { _jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i)); } } else { - CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); + CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); } } @@ -48,15 +48,15 @@ static void _jniPrint(CSSNodeRef node) { if (auto obj = jobjectContext(node)->lockLocal()) { cout << obj->toString() << endl; } else { - CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); + CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); } } static CSSSize _jniMeasureFunc(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { if (auto obj = jobjectContext(node)->lockLocal()) { static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") ->getMethod("measure"); @@ -72,31 +72,31 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node, return CSSSize{measuredWidth, measuredHeight}; } else { - CSSLog(CSSLogLevelError, "Java CSSNode was GCed during layout calculation\n"); + CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n"); return CSSSize{ - widthMode == CSSMeasureModeUndefined ? 0 : width, - heightMode == CSSMeasureModeUndefined ? 0 : height, + widthMode == YGMeasureModeUndefined ? 0 : width, + heightMode == YGMeasureModeUndefined ? 0 : height, }; } } -struct JCSSLogLevel : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/CSSLogLevel;"; +struct JYogaLogLevel : public JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;"; }; static global_ref *jLogger; -static int _jniLog(CSSLogLevel level, const char *format, va_list args) { +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"); + ->getMethod, jstring)>("log"); static auto logLevelFromInt = - JCSSLogLevel::javaClassStatic()->getStaticMethod("fromInt"); + JYogaLogLevel::javaClassStatic()->getStaticMethod("fromInt"); logFunc(jLogger->get(), - logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast(level)), + logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast(level)), Environment::current()->NewStringUTF(buffer)); return result; @@ -123,18 +123,18 @@ void jni_CSSLayoutSetLogger(alias_ref clazz, alias_ref logger) void jni_CSSLog(alias_ref clazz, jint level, jstring message) { const char *nMessage = Environment::current()->GetStringUTFChars(message, 0); - CSSLog(static_cast(level), "%s", nMessage); + 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); + CSSLayoutSetExperimentalFeatureEnabled(static_cast(feature), enabled); } jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref clazz, jint feature) { - return CSSLayoutIsExperimentalFeatureEnabled(static_cast(feature)); + return CSSLayoutIsExperimentalFeatureEnabled(static_cast(feature)); } jint jni_CSSNodeGetInstanceCount(alias_ref clazz) { @@ -176,8 +176,8 @@ void jni_CSSNodeRemoveChild(alias_ref, jlong nativePointer, jlong child void jni_CSSNodeCalculateLayout(alias_ref, jlong nativePointer) { const CSSNodeRef root = _jlong2CSSNodeRef(nativePointer); CSSNodeCalculateLayout(root, - CSSUndefined, - CSSUndefined, + YGUndefined, + YGUndefined, CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer))); _jniTransferLayoutOutputsRecursive(root); } @@ -220,7 +220,7 @@ void jni_CSSNodeCopyStyle(alias_ref, jlong dstNativePointer, jlong srcN #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)); \ + static_cast(edge)); \ } \ \ void jni_CSSNodeStyleSet##name(alias_ref, \ @@ -228,19 +228,19 @@ void jni_CSSNodeCopyStyle(alias_ref, jlong dstNativePointer, jlong srcN jint edge, \ javatype value) { \ CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \ - static_cast(edge), \ + static_cast(edge), \ static_cast(value)); \ } -CSS_NODE_JNI_STYLE_PROP(jint, CSSDirection, Direction); -CSS_NODE_JNI_STYLE_PROP(jint, CSSFlexDirection, FlexDirection); -CSS_NODE_JNI_STYLE_PROP(jint, CSSJustify, JustifyContent); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf); -CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent); -CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType); -CSS_NODE_JNI_STYLE_PROP(jint, CSSWrap, FlexWrap); -CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow); +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)); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index 78f42abc..c3ba26c7 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -23,13 +23,13 @@ public class CSSLayoutAbsolutePositionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.START, 10f); - root_child0.setPosition(CSSEdge.TOP, 10f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.START, 10f); + root_child0.setPosition(YogaEdge.TOP, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -42,7 +42,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -63,13 +63,13 @@ public class CSSLayoutAbsolutePositionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.END, 10f); - root_child0.setPosition(CSSEdge.BOTTOM, 10f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.END, 10f); + root_child0.setPosition(YogaEdge.BOTTOM, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -82,7 +82,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -103,13 +103,13 @@ public class CSSLayoutAbsolutePositionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.START, 10f); - root_child0.setPosition(CSSEdge.TOP, 10f); - root_child0.setPosition(CSSEdge.END, 10f); - root_child0.setPosition(CSSEdge.BOTTOM, 10f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.START, 10f); + root_child0.setPosition(YogaEdge.TOP, 10f); + root_child0.setPosition(YogaEdge.END, 10f); + root_child0.setPosition(YogaEdge.BOTTOM, 10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -122,7 +122,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -143,15 +143,15 @@ public class CSSLayoutAbsolutePositionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.START, 10f); - root_child0.setPosition(CSSEdge.TOP, 10f); - root_child0.setPosition(CSSEdge.END, 10f); - root_child0.setPosition(CSSEdge.BOTTOM, 10f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.START, 10f); + root_child0.setPosition(YogaEdge.TOP, 10f); + root_child0.setPosition(YogaEdge.END, 10f); + root_child0.setPosition(YogaEdge.BOTTOM, 10f); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -164,7 +164,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -181,22 +181,22 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setOverflow(CSSOverflow.HIDDEN); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setOverflow(YogaOverflow.HIDDEN); root.setWidth(50f); root.setHeight(50f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.START, 0f); - root_child0.setPosition(CSSEdge.TOP, 0f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.START, 0f); + root_child0.setPosition(YogaEdge.TOP, 0f); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setWidth(100f); root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -214,7 +214,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -236,37 +236,37 @@ public class CSSLayoutAbsolutePositionTest { @Test public void test_absolute_layout_within_border() { final CSSNode root = new CSSNode(); - root.setMargin(CSSEdge.LEFT, 10f); - root.setMargin(CSSEdge.TOP, 10f); - root.setMargin(CSSEdge.RIGHT, 10f); - root.setMargin(CSSEdge.BOTTOM, 10f); - root.setPadding(CSSEdge.LEFT, 10); - root.setPadding(CSSEdge.TOP, 10); - root.setPadding(CSSEdge.RIGHT, 10); - root.setPadding(CSSEdge.BOTTOM, 10); - root.setBorder(CSSEdge.LEFT, 10f); - root.setBorder(CSSEdge.TOP, 10f); - root.setBorder(CSSEdge.RIGHT, 10f); - root.setBorder(CSSEdge.BOTTOM, 10f); + root.setMargin(YogaEdge.LEFT, 10f); + root.setMargin(YogaEdge.TOP, 10f); + root.setMargin(YogaEdge.RIGHT, 10f); + root.setMargin(YogaEdge.BOTTOM, 10f); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPositionType(CSSPositionType.ABSOLUTE); - root_child0.setPosition(CSSEdge.LEFT, 0f); - root_child0.setPosition(CSSEdge.TOP, 0f); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 0f); + root_child0.setPosition(YogaEdge.TOP, 0f); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); final CSSNode root_child1 = new CSSNode(); - root_child1.setPositionType(CSSPositionType.ABSOLUTE); - root_child1.setPosition(CSSEdge.RIGHT, 0f); - root_child1.setPosition(CSSEdge.BOTTOM, 0f); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.RIGHT, 0f); + root_child1.setPosition(YogaEdge.BOTTOM, 0f); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(10f, root.getLayoutX(), 0.0f); @@ -284,7 +284,7 @@ public class CSSLayoutAbsolutePositionTest { assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(10f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java index 45a6d49e..0c81f46d 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java @@ -19,7 +19,7 @@ public class CSSLayoutAlignContentTest { @Test public void test_align_content_flex_start() { final CSSNode root = new CSSNode(); - root.setWrap(CSSWrap.WRAP); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); @@ -47,7 +47,7 @@ public class CSSLayoutAlignContentTest { root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -80,7 +80,7 @@ public class CSSLayoutAlignContentTest { assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -117,8 +117,8 @@ public class CSSLayoutAlignContentTest { @Test public void test_align_content_flex_end() { final CSSNode root = new CSSNode(); - root.setAlignContent(CSSAlign.FLEX_END); - root.setWrap(CSSWrap.WRAP); + root.setAlignContent(YogaAlign.FLEX_END); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); @@ -146,7 +146,7 @@ public class CSSLayoutAlignContentTest { root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -179,7 +179,7 @@ public class CSSLayoutAlignContentTest { assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -216,8 +216,8 @@ public class CSSLayoutAlignContentTest { @Test public void test_align_content_center() { final CSSNode root = new CSSNode(); - root.setAlignContent(CSSAlign.CENTER); - root.setWrap(CSSWrap.WRAP); + root.setAlignContent(YogaAlign.CENTER); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); @@ -245,7 +245,7 @@ public class CSSLayoutAlignContentTest { root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -278,7 +278,7 @@ public class CSSLayoutAlignContentTest { assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -315,8 +315,8 @@ public class CSSLayoutAlignContentTest { @Test public void test_align_content_stretch() { final CSSNode root = new CSSNode(); - root.setAlignContent(CSSAlign.STRETCH); - root.setWrap(CSSWrap.WRAP); + root.setAlignContent(YogaAlign.STRETCH); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); @@ -339,7 +339,7 @@ public class CSSLayoutAlignContentTest { final CSSNode root_child4 = new CSSNode(); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -372,7 +372,7 @@ public class CSSLayoutAlignContentTest { assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java index ce29f740..4dcdcea4 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java @@ -25,7 +25,7 @@ public class CSSLayoutAlignItemsTest { final CSSNode root_child0 = new CSSNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -38,7 +38,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -55,7 +55,7 @@ public class CSSLayoutAlignItemsTest { @Test public void test_align_items_center() { final CSSNode root = new CSSNode(); - root.setAlignItems(CSSAlign.CENTER); + root.setAlignItems(YogaAlign.CENTER); root.setWidth(100f); root.setHeight(100f); @@ -63,7 +63,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -76,7 +76,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -93,7 +93,7 @@ public class CSSLayoutAlignItemsTest { @Test public void test_align_items_flex_start() { final CSSNode root = new CSSNode(); - root.setAlignItems(CSSAlign.FLEX_START); + root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); @@ -101,7 +101,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -114,7 +114,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -131,7 +131,7 @@ public class CSSLayoutAlignItemsTest { @Test public void test_align_items_flex_end() { final CSSNode root = new CSSNode(); - root.setAlignItems(CSSAlign.FLEX_END); + root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(100f); root.setHeight(100f); @@ -139,7 +139,7 @@ public class CSSLayoutAlignItemsTest { root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -152,7 +152,7 @@ public class CSSLayoutAlignItemsTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java index c2ae50e2..3651e5b3 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java @@ -23,11 +23,11 @@ public class CSSLayoutAlignSelfTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setAlignSelf(CSSAlign.CENTER); + root_child0.setAlignSelf(YogaAlign.CENTER); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -40,7 +40,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -61,11 +61,11 @@ public class CSSLayoutAlignSelfTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setAlignSelf(CSSAlign.FLEX_END); + root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -78,7 +78,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -99,11 +99,11 @@ public class CSSLayoutAlignSelfTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setAlignSelf(CSSAlign.FLEX_START); + root_child0.setAlignSelf(YogaAlign.FLEX_START); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -116,7 +116,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -133,16 +133,16 @@ public class CSSLayoutAlignSelfTest { @Test public void test_align_self_flex_end_override_flex_start() { final CSSNode root = new CSSNode(); - root.setAlignItems(CSSAlign.FLEX_START); + root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setAlignSelf(CSSAlign.FLEX_END); + root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -155,7 +155,7 @@ public class CSSLayoutAlignSelfTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java index 3acd73fa..1e1ac2ca 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java @@ -19,11 +19,11 @@ public class CSSLayoutBorderTest { @Test public void test_border_no_size() { final CSSNode root = new CSSNode(); - root.setBorder(CSSEdge.LEFT, 10f); - root.setBorder(CSSEdge.TOP, 10f); - root.setBorder(CSSEdge.RIGHT, 10f); - root.setBorder(CSSEdge.BOTTOM, 10f); - root.setDirection(CSSDirection.LTR); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -31,7 +31,7 @@ public class CSSLayoutBorderTest { assertEquals(20f, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -43,16 +43,16 @@ public class CSSLayoutBorderTest { @Test public void test_border_container_match_child() { final CSSNode root = new CSSNode(); - root.setBorder(CSSEdge.LEFT, 10f); - root.setBorder(CSSEdge.TOP, 10f); - root.setBorder(CSSEdge.RIGHT, 10f); - root.setBorder(CSSEdge.BOTTOM, 10f); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); final CSSNode root_child0 = new CSSNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -65,7 +65,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -82,10 +82,10 @@ public class CSSLayoutBorderTest { @Test public void test_border_flex_child() { final CSSNode root = new CSSNode(); - root.setBorder(CSSEdge.LEFT, 10f); - root.setBorder(CSSEdge.TOP, 10f); - root.setBorder(CSSEdge.RIGHT, 10f); - root.setBorder(CSSEdge.BOTTOM, 10f); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); @@ -93,7 +93,7 @@ public class CSSLayoutBorderTest { root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -106,7 +106,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -123,17 +123,17 @@ public class CSSLayoutBorderTest { @Test public void test_border_stretch_child() { final CSSNode root = new CSSNode(); - root.setBorder(CSSEdge.LEFT, 10f); - root.setBorder(CSSEdge.TOP, 10f); - root.setBorder(CSSEdge.RIGHT, 10f); - root.setBorder(CSSEdge.BOTTOM, 10f); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -146,7 +146,7 @@ public class CSSLayoutBorderTest { assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -163,11 +163,11 @@ public class CSSLayoutBorderTest { @Test public void test_border_center_child() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.CENTER); - root.setAlignItems(CSSAlign.CENTER); - root.setBorder(CSSEdge.START, 10f); - root.setBorder(CSSEdge.END, 20f); - root.setBorder(CSSEdge.BOTTOM, 20f); + root.setJustifyContent(YogaJustify.CENTER); + root.setAlignItems(YogaAlign.CENTER); + root.setBorder(YogaEdge.START, 10f); + root.setBorder(YogaEdge.END, 20f); + root.setBorder(YogaEdge.BOTTOM, 20f); root.setWidth(100f); root.setHeight(100f); @@ -175,7 +175,7 @@ public class CSSLayoutBorderTest { root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -188,7 +188,7 @@ public class CSSLayoutBorderTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java index fad52543..73b1a98e 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java @@ -32,7 +32,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -55,7 +55,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -82,7 +82,7 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_row_no_width() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); @@ -96,7 +96,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -119,7 +119,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -160,7 +160,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -183,7 +183,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -210,7 +210,7 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -225,7 +225,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -248,7 +248,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -275,7 +275,7 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_column_reverse() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE); + root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); root.setWidth(100f); root.setHeight(100f); @@ -290,7 +290,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -313,7 +313,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -340,7 +340,7 @@ public class CSSLayoutFlexDirectionTest { @Test public void test_flex_direction_row_reverse() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW_REVERSE); + root.setFlexDirection(YogaFlexDirection.ROW_REVERSE); root.setWidth(100f); root.setHeight(100f); @@ -355,7 +355,7 @@ public class CSSLayoutFlexDirectionTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -378,7 +378,7 @@ public class CSSLayoutFlexDirectionTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java index a9421f35..3d4f1b84 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java @@ -30,7 +30,7 @@ public class CSSLayoutFlexTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -48,7 +48,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -70,7 +70,7 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_flex_grow_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -82,7 +82,7 @@ public class CSSLayoutFlexTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -100,7 +100,7 @@ public class CSSLayoutFlexTest { assertEquals(25f, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -133,7 +133,7 @@ public class CSSLayoutFlexTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -151,7 +151,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -173,7 +173,7 @@ public class CSSLayoutFlexTest { @Test public void test_flex_basis_flex_shrink_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -185,7 +185,7 @@ public class CSSLayoutFlexTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -203,7 +203,7 @@ public class CSSLayoutFlexTest { assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -242,7 +242,7 @@ public class CSSLayoutFlexTest { root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -265,7 +265,7 @@ public class CSSLayoutFlexTest { assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -310,7 +310,7 @@ public class CSSLayoutFlexTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -333,7 +333,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -370,7 +370,7 @@ public class CSSLayoutFlexTest { root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexShrink(1f); root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -388,7 +388,7 @@ public class CSSLayoutFlexTest { assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java index c0850c1c..8df07243 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java @@ -19,7 +19,7 @@ public class CSSLayoutFlexWrapTest { @Test public void test_wrap_column() { final CSSNode root = new CSSNode(); - root.setWrap(CSSWrap.WRAP); + root.setWrap(YogaWrap.WRAP); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); @@ -41,7 +41,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -69,7 +69,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -101,8 +101,8 @@ public class CSSLayoutFlexWrapTest { @Test public void test_wrap_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setWrap(CSSWrap.WRAP); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); @@ -124,7 +124,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -152,7 +152,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -184,9 +184,9 @@ public class CSSLayoutFlexWrapTest { @Test public void test_wrap_row_align_items_flex_end() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setAlignItems(CSSAlign.FLEX_END); - root.setWrap(CSSWrap.WRAP); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setAlignItems(YogaAlign.FLEX_END); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); @@ -208,7 +208,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -236,7 +236,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -268,9 +268,9 @@ public class CSSLayoutFlexWrapTest { @Test public void test_wrap_row_align_items_center() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setAlignItems(CSSAlign.CENTER); - root.setWrap(CSSWrap.WRAP); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setAlignItems(YogaAlign.CENTER); + root.setWrap(YogaWrap.WRAP); root.setWidth(100f); final CSSNode root_child0 = new CSSNode(); @@ -292,7 +292,7 @@ public class CSSLayoutFlexWrapTest { root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -320,7 +320,7 @@ public class CSSLayoutFlexWrapTest { assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java index 310c31c3..2f486e6f 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java @@ -19,7 +19,7 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_row_flex_start() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(102f); root.setHeight(102f); @@ -34,7 +34,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -57,7 +57,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -84,8 +84,8 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_row_flex_end() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setJustifyContent(CSSJustify.FLEX_END); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); @@ -100,7 +100,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -123,7 +123,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -150,8 +150,8 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_row_center() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setJustifyContent(CSSJustify.CENTER); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); @@ -166,7 +166,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -189,7 +189,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -216,8 +216,8 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_row_space_between() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setJustifyContent(CSSJustify.SPACE_BETWEEN); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); @@ -232,7 +232,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -255,7 +255,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -282,8 +282,8 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_row_space_around() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setJustifyContent(CSSJustify.SPACE_AROUND); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); @@ -298,7 +298,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -321,7 +321,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(10f, root_child2.getLayoutWidth(), 0.0f); assertEquals(102f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -361,7 +361,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -384,7 +384,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -411,7 +411,7 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_column_flex_end() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.FLEX_END); + root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); @@ -426,7 +426,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -449,7 +449,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -476,7 +476,7 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_column_center() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.CENTER); + root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); @@ -491,7 +491,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -514,7 +514,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -541,7 +541,7 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_column_space_between() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.SPACE_BETWEEN); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); @@ -556,7 +556,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -579,7 +579,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -606,7 +606,7 @@ public class CSSLayoutJustifyContentTest { @Test public void test_justify_content_column_space_around() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.SPACE_AROUND); + root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); @@ -621,7 +621,7 @@ public class CSSLayoutJustifyContentTest { final CSSNode root_child2 = new CSSNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -644,7 +644,7 @@ public class CSSLayoutJustifyContentTest { assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java index 63a07584..f265ef7b 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java @@ -19,15 +19,15 @@ public class CSSLayoutMarginTest { @Test public void test_margin_start() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(CSSEdge.START, 10f); + root_child0.setMargin(YogaEdge.START, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -40,7 +40,7 @@ public class CSSLayoutMarginTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -61,10 +61,10 @@ public class CSSLayoutMarginTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(CSSEdge.TOP, 10f); + root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -77,7 +77,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -94,16 +94,16 @@ public class CSSLayoutMarginTest { @Test public void test_margin_end() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); - root.setJustifyContent(CSSJustify.FLEX_END); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(CSSEdge.END, 10f); + root_child0.setMargin(YogaEdge.END, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -116,7 +116,7 @@ public class CSSLayoutMarginTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -133,15 +133,15 @@ public class CSSLayoutMarginTest { @Test public void test_margin_bottom() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.FLEX_END); + root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setMargin(CSSEdge.BOTTOM, 10f); + root_child0.setMargin(YogaEdge.BOTTOM, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -154,7 +154,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -171,15 +171,15 @@ public class CSSLayoutMarginTest { @Test public void test_margin_and_flex_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(CSSEdge.START, 10f); + root_child0.setMargin(YogaEdge.START, 10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -192,7 +192,7 @@ public class CSSLayoutMarginTest { assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -214,9 +214,9 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(CSSEdge.TOP, 10f); + root_child0.setMargin(YogaEdge.TOP, 10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -229,7 +229,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -246,15 +246,15 @@ public class CSSLayoutMarginTest { @Test public void test_margin_and_stretch_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(CSSEdge.TOP, 10f); + root_child0.setMargin(YogaEdge.TOP, 10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -267,7 +267,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -289,9 +289,9 @@ public class CSSLayoutMarginTest { final CSSNode root_child0 = new CSSNode(); root_child0.setFlexGrow(1f); - root_child0.setMargin(CSSEdge.START, 10f); + root_child0.setMargin(YogaEdge.START, 10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -304,7 +304,7 @@ public class CSSLayoutMarginTest { assertEquals(90f, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -321,7 +321,7 @@ public class CSSLayoutMarginTest { @Test public void test_margin_with_sibling_row() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -332,7 +332,7 @@ public class CSSLayoutMarginTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -350,7 +350,7 @@ public class CSSLayoutMarginTest { assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -382,7 +382,7 @@ public class CSSLayoutMarginTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -400,7 +400,7 @@ public class CSSLayoutMarginTest { assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java index 56f34d61..d509e6a2 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java @@ -26,7 +26,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setMaxWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -39,7 +39,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -56,7 +56,7 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_max_height() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -64,7 +64,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setWidth(10f); root_child0.setMaxHeight(50f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -77,7 +77,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -105,7 +105,7 @@ public class CSSLayoutMinMaxDimensionTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -123,7 +123,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -145,7 +145,7 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_min_width() { final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -157,7 +157,7 @@ public class CSSLayoutMinMaxDimensionTest { final CSSNode root_child1 = new CSSNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -175,7 +175,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -197,7 +197,7 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_justify_content_min_max() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.CENTER); + root.setJustifyContent(YogaJustify.CENTER); root.setWidth(100f); root.setMinHeight(100f); root.setMaxHeight(200f); @@ -206,7 +206,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -219,7 +219,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -236,7 +236,7 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_align_items_min_max() { final CSSNode root = new CSSNode(); - root.setAlignItems(CSSAlign.CENTER); + root.setAlignItems(YogaAlign.CENTER); root.setMinWidth(100f); root.setMaxWidth(200f); root.setHeight(100f); @@ -245,7 +245,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -258,7 +258,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -275,7 +275,7 @@ public class CSSLayoutMinMaxDimensionTest { @Test public void test_justify_content_overflow_min_max() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.CENTER); + root.setJustifyContent(YogaJustify.CENTER); root.setMinHeight(100f); root.setMaxHeight(110f); @@ -293,7 +293,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -316,7 +316,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -347,7 +347,7 @@ public class CSSLayoutMinMaxDimensionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexDirection(CSSFlexDirection.ROW); + root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(100f); root.addChildAt(root_child0, 0); @@ -355,7 +355,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -373,7 +373,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -399,7 +399,7 @@ public class CSSLayoutMinMaxDimensionTest { root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); - root_child0.setFlexDirection(CSSFlexDirection.ROW); + root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(300f); root.addChildAt(root_child0, 0); @@ -407,7 +407,7 @@ public class CSSLayoutMinMaxDimensionTest { root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -425,7 +425,7 @@ public class CSSLayoutMinMaxDimensionTest { assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java index f837953f..a50ac8b5 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java @@ -19,11 +19,11 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_no_size() { final CSSNode root = new CSSNode(); - root.setPadding(CSSEdge.LEFT, 10); - root.setPadding(CSSEdge.TOP, 10); - root.setPadding(CSSEdge.RIGHT, 10); - root.setPadding(CSSEdge.BOTTOM, 10); - root.setDirection(CSSDirection.LTR); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -31,7 +31,7 @@ public class CSSLayoutPaddingTest { assertEquals(20f, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -43,16 +43,16 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_container_match_child() { final CSSNode root = new CSSNode(); - root.setPadding(CSSEdge.LEFT, 10); - root.setPadding(CSSEdge.TOP, 10); - root.setPadding(CSSEdge.RIGHT, 10); - root.setPadding(CSSEdge.BOTTOM, 10); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); final CSSNode root_child0 = new CSSNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -65,7 +65,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -82,10 +82,10 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_flex_child() { final CSSNode root = new CSSNode(); - root.setPadding(CSSEdge.LEFT, 10); - root.setPadding(CSSEdge.TOP, 10); - root.setPadding(CSSEdge.RIGHT, 10); - root.setPadding(CSSEdge.BOTTOM, 10); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); root.setWidth(100f); root.setHeight(100f); @@ -93,7 +93,7 @@ public class CSSLayoutPaddingTest { root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -106,7 +106,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -123,17 +123,17 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_stretch_child() { final CSSNode root = new CSSNode(); - root.setPadding(CSSEdge.LEFT, 10); - root.setPadding(CSSEdge.TOP, 10); - root.setPadding(CSSEdge.RIGHT, 10); - root.setPadding(CSSEdge.BOTTOM, 10); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); root.setWidth(100f); root.setHeight(100f); final CSSNode root_child0 = new CSSNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -146,7 +146,7 @@ public class CSSLayoutPaddingTest { assertEquals(80f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -163,11 +163,11 @@ public class CSSLayoutPaddingTest { @Test public void test_padding_center_child() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.CENTER); - root.setAlignItems(CSSAlign.CENTER); - root.setPadding(CSSEdge.START, 10); - root.setPadding(CSSEdge.END, 20); - root.setPadding(CSSEdge.BOTTOM, 20); + root.setJustifyContent(YogaJustify.CENTER); + root.setAlignItems(YogaAlign.CENTER); + root.setPadding(YogaEdge.START, 10); + root.setPadding(YogaEdge.END, 20); + root.setPadding(YogaEdge.BOTTOM, 20); root.setWidth(100f); root.setHeight(100f); @@ -175,7 +175,7 @@ public class CSSLayoutPaddingTest { root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -188,7 +188,7 @@ public class CSSLayoutPaddingTest { assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -205,20 +205,20 @@ public class CSSLayoutPaddingTest { @Test public void test_child_with_padding_align_end() { final CSSNode root = new CSSNode(); - root.setJustifyContent(CSSJustify.FLEX_END); - root.setAlignItems(CSSAlign.FLEX_END); + root.setJustifyContent(YogaJustify.FLEX_END); + root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(200f); root.setHeight(200f); final CSSNode root_child0 = new CSSNode(); - root_child0.setPadding(CSSEdge.LEFT, 20); - root_child0.setPadding(CSSEdge.TOP, 20); - root_child0.setPadding(CSSEdge.RIGHT, 20); - root_child0.setPadding(CSSEdge.BOTTOM, 20); + root_child0.setPadding(YogaEdge.LEFT, 20); + root_child0.setPadding(YogaEdge.TOP, 20); + root_child0.setPadding(YogaEdge.RIGHT, 20); + root_child0.setPadding(YogaEdge.BOTTOM, 20); root_child0.setWidth(100f); root_child0.setHeight(100f); root.addChildAt(root_child0, 0); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -231,7 +231,7 @@ public class CSSLayoutPaddingTest { assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java index 17587908..e3e6543b 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java @@ -18,10 +18,10 @@ import static org.junit.Assert.assertEquals; public class CSSLayoutRoundingTest { @Test public void test_rounding_flex_basis_flex_grow_row_width_of_100() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); @@ -36,7 +36,7 @@ public class CSSLayoutRoundingTest { final CSSNode root_child2 = new CSSNode(); root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -59,7 +59,7 @@ public class CSSLayoutRoundingTest { assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -82,15 +82,15 @@ public class CSSLayoutRoundingTest { assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_grow_row_prime_number_width() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(113f); root.setHeight(100f); @@ -113,7 +113,7 @@ public class CSSLayoutRoundingTest { final CSSNode root_child4 = new CSSNode(); root_child4.setFlexGrow(1f); root.addChildAt(root_child4, 4); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -146,7 +146,7 @@ public class CSSLayoutRoundingTest { assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -179,15 +179,15 @@ public class CSSLayoutRoundingTest { assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_shrink_row() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setFlexDirection(CSSFlexDirection.ROW); + root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(101f); root.setHeight(100f); @@ -203,7 +203,7 @@ public class CSSLayoutRoundingTest { final CSSNode root_child2 = new CSSNode(); root_child2.setFlexBasis(25f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -226,7 +226,7 @@ public class CSSLayoutRoundingTest { assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -249,12 +249,12 @@ public class CSSLayoutRoundingTest { assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_overrides_main_size() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); root.setWidth(100f); @@ -275,7 +275,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -298,7 +298,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -321,12 +321,12 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); root.setWidth(87.4f); @@ -347,7 +347,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -370,7 +370,7 @@ public class CSSLayoutRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -393,12 +393,12 @@ public class CSSLayoutRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial_nested() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); root.setWidth(87.4f); @@ -413,14 +413,14 @@ public class CSSLayoutRoundingTest { final CSSNode root_child0_child0 = new CSSNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0.3f); - root_child0_child0.setPosition(CSSEdge.BOTTOM, 13.3f); + root_child0_child0.setPosition(YogaEdge.BOTTOM, 13.3f); root_child0_child0.setHeight(9.9f); root_child0.addChildAt(root_child0_child0, 0); final CSSNode root_child0_child1 = new CSSNode(); root_child0_child1.setFlexGrow(4f); root_child0_child1.setFlexBasis(0.3f); - root_child0_child1.setPosition(CSSEdge.TOP, 13.3f); + root_child0_child1.setPosition(YogaEdge.TOP, 13.3f); root_child0_child1.setHeight(1.1f); root_child0.addChildAt(root_child0_child1, 1); @@ -433,7 +433,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -466,7 +466,7 @@ public class CSSLayoutRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -499,12 +499,12 @@ public class CSSLayoutRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_1() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); root.setWidth(100f); @@ -525,7 +525,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -548,7 +548,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -571,12 +571,12 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_2() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); root.setWidth(100f); @@ -597,7 +597,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -620,7 +620,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -643,15 +643,15 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_3() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setPosition(CSSEdge.TOP, 0.3f); + root.setPosition(YogaEdge.TOP, 0.3f); root.setWidth(100f); root.setHeight(113.4f); @@ -670,7 +670,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -693,7 +693,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -716,15 +716,15 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_4() { - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); final CSSNode root = new CSSNode(); - root.setPosition(CSSEdge.TOP, 0.7f); + root.setPosition(YogaEdge.TOP, 0.7f); root.setWidth(100f); root.setHeight(113.4f); @@ -743,7 +743,7 @@ public class CSSLayoutRoundingTest { root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - root.setDirection(CSSDirection.LTR); + root.setDirection(YogaDirection.LTR); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -766,7 +766,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - root.setDirection(CSSDirection.RTL); + root.setDirection(YogaDirection.RTL); root.calculateLayout(); assertEquals(0f, root.getLayoutX(), 0.0f); @@ -789,7 +789,7 @@ public class CSSLayoutRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false); + CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } } diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/CSSNodeTest.java index 48abed92..70eb8ce5 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/CSSNodeTest.java @@ -30,9 +30,9 @@ public class CSSNodeTest { public long measure( CSSNodeAPI node, float width, - CSSMeasureMode widthMode, + YogaMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YogaMeasureMode heightMode) { return MeasureOutput.make(100, 100); } }); @@ -41,42 +41,42 @@ public class CSSNodeTest { assertEquals(100, (int) node.getLayoutHeight()); } - private CSSLogLevel mLogLevel; + private YogaLogLevel mLogLevel; private String mLogMessage; @Test public void testLogger() { CSSNode.setLogger(new CSSLogger() { - public void log(CSSLogLevel level, String message) { + public void log(YogaLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_CSSLog(CSSLogLevel.DEBUG.intValue(), "Hello"); - assertEquals(CSSLogLevel.DEBUG, mLogLevel); + CSSNode.jni_CSSLog(YogaLogLevel.DEBUG.intValue(), "Hello"); + assertEquals(YogaLogLevel.DEBUG, mLogLevel); assertEquals("Hello", mLogMessage); } @Test public void testUpdateLogger() { CSSNode.setLogger(new CSSLogger() { - public void log(CSSLogLevel level, String message) {} + public void log(YogaLogLevel level, String message) {} }); CSSNode.setLogger(new CSSLogger() { - public void log(CSSLogLevel level, String message) { + public void log(YogaLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_CSSLog(CSSLogLevel.VERBOSE.intValue(), "Flexbox"); - assertEquals(CSSLogLevel.VERBOSE, mLogLevel); + CSSNode.jni_CSSLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox"); + assertEquals(YogaLogLevel.VERBOSE, mLogLevel); assertEquals("Flexbox", mLogMessage); } @Test public void testCopyStyle() { final CSSNode node0 = new CSSNode(); - assertTrue(CSSConstants.isUndefined(node0.getMaxHeight())); + assertTrue(YogaConstants.isUndefined(node0.getMaxHeight())); final CSSNode node1 = new CSSNode(); node1.setMaxHeight(100); diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index a0bedbe5..4e5bca75 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -18,13 +18,13 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -36,7 +36,7 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -57,13 +57,13 @@ TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -75,7 +75,7 @@ TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -96,13 +96,13 @@ TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -114,7 +114,7 @@ TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) { ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -135,15 +135,15 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -155,7 +155,7 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -172,22 +172,22 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetOverflow(root, CSSOverflowHidden); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetOverflow(root, YGOverflowHidden); CSSNodeStyleSetWidth(root, 50); CSSNodeStyleSetHeight(root, 50); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 0); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 0); + CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0); CSSNodeInsertChild(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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -204,7 +204,7 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -226,37 +226,37 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl TEST(CSSLayoutTest, absolute_layout_within_border) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetMargin(root, CSSEdgeLeft, 10); - CSSNodeStyleSetMargin(root, CSSEdgeTop, 10); - CSSNodeStyleSetMargin(root, CSSEdgeRight, 10); - CSSNodeStyleSetMargin(root, CSSEdgeBottom, 10); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); + 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); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + 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 CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child1, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child1, CSSEdgeRight, 0); - CSSNodeStyleSetPosition(root_child1, CSSEdgeBottom, 0); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root)); @@ -273,7 +273,7 @@ TEST(CSSLayoutTest, absolute_layout_within_border) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index d3078098..eb0daa57 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -14,7 +14,7 @@ TEST(CSSLayoutTest, align_content_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -42,7 +42,7 @@ TEST(CSSLayoutTest, align_content_flex_start) { CSSNodeStyleSetWidth(root_child4, 50); CSSNodeStyleSetHeight(root_child4, 10); CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -74,7 +74,7 @@ TEST(CSSLayoutTest, align_content_flex_start) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -111,8 +111,8 @@ TEST(CSSLayoutTest, align_content_flex_start) { TEST(CSSLayoutTest, align_content_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetAlignContent(root, YGAlignFlexEnd); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -140,7 +140,7 @@ TEST(CSSLayoutTest, align_content_flex_end) { CSSNodeStyleSetWidth(root_child4, 50); CSSNodeStyleSetHeight(root_child4, 10); CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -172,7 +172,7 @@ TEST(CSSLayoutTest, align_content_flex_end) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -209,8 +209,8 @@ TEST(CSSLayoutTest, align_content_flex_end) { TEST(CSSLayoutTest, align_content_center) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, CSSAlignCenter); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetAlignContent(root, YGAlignCenter); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -238,7 +238,7 @@ TEST(CSSLayoutTest, align_content_center) { CSSNodeStyleSetWidth(root_child4, 50); CSSNodeStyleSetHeight(root_child4, 10); CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -270,7 +270,7 @@ TEST(CSSLayoutTest, align_content_center) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -307,8 +307,8 @@ TEST(CSSLayoutTest, align_content_center) { TEST(CSSLayoutTest, align_content_stretch) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, CSSAlignStretch); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetAlignContent(root, YGAlignStretch); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -331,7 +331,7 @@ TEST(CSSLayoutTest, align_content_stretch) { const CSSNodeRef root_child4 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child4, 50); CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -363,7 +363,7 @@ TEST(CSSLayoutTest, align_content_stretch) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index c72acc7a..5c8db2c0 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -20,7 +20,7 @@ TEST(CSSLayoutTest, align_items_stretch) { const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -32,7 +32,7 @@ TEST(CSSLayoutTest, align_items_stretch) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -49,7 +49,7 @@ TEST(CSSLayoutTest, align_items_stretch) { TEST(CSSLayoutTest, align_items_center) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignCenter); + CSSNodeStyleSetAlignItems(root, YGAlignCenter); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -57,7 +57,7 @@ TEST(CSSLayoutTest, align_items_center) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -69,7 +69,7 @@ TEST(CSSLayoutTest, align_items_center) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -86,7 +86,7 @@ TEST(CSSLayoutTest, align_items_center) { TEST(CSSLayoutTest, align_items_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -94,7 +94,7 @@ TEST(CSSLayoutTest, align_items_flex_start) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -106,7 +106,7 @@ TEST(CSSLayoutTest, align_items_flex_start) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -123,7 +123,7 @@ TEST(CSSLayoutTest, align_items_flex_start) { TEST(CSSLayoutTest, align_items_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); + CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -131,7 +131,7 @@ TEST(CSSLayoutTest, align_items_flex_end) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -143,7 +143,7 @@ TEST(CSSLayoutTest, align_items_flex_end) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index 6e090730..bc183398 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -18,11 +18,11 @@ TEST(CSSLayoutTest, align_self_center) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignCenter); + CSSNodeStyleSetAlignSelf(root_child0, YGAlignCenter); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -34,7 +34,7 @@ TEST(CSSLayoutTest, align_self_center) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -55,11 +55,11 @@ TEST(CSSLayoutTest, align_self_flex_end) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); + CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -71,7 +71,7 @@ TEST(CSSLayoutTest, align_self_flex_end) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -92,11 +92,11 @@ TEST(CSSLayoutTest, align_self_flex_start) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexStart); + CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -108,7 +108,7 @@ TEST(CSSLayoutTest, align_self_flex_start) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -125,16 +125,16 @@ TEST(CSSLayoutTest, align_self_flex_start) { TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); + CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -146,7 +146,7 @@ TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutAspectRatioTest.cpp b/tests/CSSLayoutAspectRatioTest.cpp index e43a7707..aba09889 100644 --- a/tests/CSSLayoutAspectRatioTest.cpp +++ b/tests/CSSLayoutAspectRatioTest.cpp @@ -12,18 +12,18 @@ static CSSSize _measure(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { return CSSSize { - .width = widthMode == CSSMeasureModeExactly ? width : 50, - .height = heightMode == CSSMeasureModeExactly ? height : 50, + .width = widthMode == YGMeasureModeExactly ? width : 50, + .height = heightMode == YGMeasureModeExactly ? height : 50, }; } TEST(CSSLayoutTest, aspect_ratio_cross_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -32,7 +32,7 @@ TEST(CSSLayoutTest, aspect_ratio_cross_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -44,7 +44,7 @@ TEST(CSSLayoutTest, aspect_ratio_cross_defined) { TEST(CSSLayoutTest, aspect_ratio_main_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -53,7 +53,7 @@ TEST(CSSLayoutTest, aspect_ratio_main_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -73,7 +73,7 @@ TEST(CSSLayoutTest, aspect_ratio_both_dimensions_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -92,7 +92,7 @@ TEST(CSSLayoutTest, aspect_ratio_align_stretch) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -104,7 +104,7 @@ TEST(CSSLayoutTest, aspect_ratio_align_stretch) { TEST(CSSLayoutTest, aspect_ratio_flex_grow) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -114,7 +114,7 @@ TEST(CSSLayoutTest, aspect_ratio_flex_grow) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -126,7 +126,7 @@ TEST(CSSLayoutTest, aspect_ratio_flex_grow) { TEST(CSSLayoutTest, aspect_ratio_flex_shrink) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -136,7 +136,7 @@ TEST(CSSLayoutTest, aspect_ratio_flex_shrink) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -148,7 +148,7 @@ TEST(CSSLayoutTest, aspect_ratio_flex_shrink) { TEST(CSSLayoutTest, aspect_ratio_basis) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -157,7 +157,7 @@ TEST(CSSLayoutTest, aspect_ratio_basis) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -173,14 +173,14 @@ TEST(CSSLayoutTest, aspect_ratio_absolute_layout_width_defined) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + 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); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -196,14 +196,14 @@ TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0); - CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); + 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); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -215,7 +215,7 @@ TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) { TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -225,7 +225,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -237,7 +237,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) { TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -247,7 +247,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -259,7 +259,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) { TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -269,7 +269,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -281,7 +281,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) { TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -291,7 +291,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -303,7 +303,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) { TEST(CSSLayoutTest, aspect_ratio_double_cross) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -312,7 +312,7 @@ TEST(CSSLayoutTest, aspect_ratio_double_cross) { CSSNodeStyleSetAspectRatio(root_child0, 2); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -324,7 +324,7 @@ TEST(CSSLayoutTest, aspect_ratio_double_cross) { TEST(CSSLayoutTest, aspect_ratio_half_cross) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -333,7 +333,7 @@ TEST(CSSLayoutTest, aspect_ratio_half_cross) { CSSNodeStyleSetAspectRatio(root_child0, 0.5); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -345,7 +345,7 @@ TEST(CSSLayoutTest, aspect_ratio_half_cross) { TEST(CSSLayoutTest, aspect_ratio_double_main) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -354,7 +354,7 @@ TEST(CSSLayoutTest, aspect_ratio_double_main) { CSSNodeStyleSetAspectRatio(root_child0, 2); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -366,7 +366,7 @@ TEST(CSSLayoutTest, aspect_ratio_double_main) { TEST(CSSLayoutTest, aspect_ratio_half_main) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -375,7 +375,7 @@ TEST(CSSLayoutTest, aspect_ratio_half_main) { CSSNodeStyleSetAspectRatio(root_child0, 0.5); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); @@ -387,7 +387,7 @@ TEST(CSSLayoutTest, aspect_ratio_half_main) { TEST(CSSLayoutTest, aspect_ratio_with_measure_func) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -396,7 +396,7 @@ TEST(CSSLayoutTest, aspect_ratio_with_measure_func) { CSSNodeStyleSetAspectRatio(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index 56dac071..42818c36 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -14,18 +14,18 @@ TEST(CSSLayoutTest, border_no_size) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); + CSSNodeStyleSetBorder(root, YGEdgeTop, 10); + CSSNodeStyleSetBorder(root, YGEdgeRight, 10); + CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); + CSSNodeCalculateLayout(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)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -37,16 +37,16 @@ TEST(CSSLayoutTest, border_no_size) { TEST(CSSLayoutTest, border_container_match_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); + CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); + CSSNodeStyleSetBorder(root, YGEdgeTop, 10); + CSSNodeStyleSetBorder(root, YGEdgeRight, 10); + CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -58,7 +58,7 @@ TEST(CSSLayoutTest, border_container_match_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -75,10 +75,10 @@ TEST(CSSLayoutTest, border_container_match_child) { TEST(CSSLayoutTest, border_flex_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); + CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); + CSSNodeStyleSetBorder(root, YGEdgeTop, 10); + CSSNodeStyleSetBorder(root, YGEdgeRight, 10); + CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -86,7 +86,7 @@ TEST(CSSLayoutTest, border_flex_child) { CSSNodeStyleSetFlexGrow(root_child0, 1); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -98,7 +98,7 @@ TEST(CSSLayoutTest, border_flex_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -115,17 +115,17 @@ TEST(CSSLayoutTest, border_flex_child) { TEST(CSSLayoutTest, border_stretch_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeTop, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 10); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); + CSSNodeStyleSetBorder(root, YGEdgeLeft, 10); + CSSNodeStyleSetBorder(root, YGEdgeTop, 10); + CSSNodeStyleSetBorder(root, YGEdgeRight, 10); + CSSNodeStyleSetBorder(root, YGEdgeBottom, 10); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -137,7 +137,7 @@ TEST(CSSLayoutTest, border_stretch_child) { ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -154,11 +154,11 @@ TEST(CSSLayoutTest, border_stretch_child) { TEST(CSSLayoutTest, border_center_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); - CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetBorder(root, CSSEdgeStart, 10); - CSSNodeStyleSetBorder(root, CSSEdgeEnd, 20); - CSSNodeStyleSetBorder(root, CSSEdgeBottom, 20); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); + CSSNodeStyleSetAlignItems(root, YGAlignCenter); + CSSNodeStyleSetBorder(root, YGEdgeStart, 10); + CSSNodeStyleSetBorder(root, YGEdgeEnd, 20); + CSSNodeStyleSetBorder(root, YGEdgeBottom, 20); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -166,7 +166,7 @@ TEST(CSSLayoutTest, border_center_child) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -178,7 +178,7 @@ TEST(CSSLayoutTest, border_center_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutDefaultValuesTest.cpp b/tests/CSSLayoutDefaultValuesTest.cpp index 727084c4..534607f2 100644 --- a/tests/CSSLayoutDefaultValuesTest.cpp +++ b/tests/CSSLayoutDefaultValuesTest.cpp @@ -16,46 +16,46 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_EQ(0, CSSNodeChildCount(root)); ASSERT_EQ(NULL, CSSNodeGetChild(root, 1)); - ASSERT_EQ(CSSDirectionInherit, CSSNodeStyleGetDirection(root)); - ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(root)); - ASSERT_EQ(CSSJustifyFlexStart, CSSNodeStyleGetJustifyContent(root)); - ASSERT_EQ(CSSAlignFlexStart, CSSNodeStyleGetAlignContent(root)); - ASSERT_EQ(CSSAlignStretch, CSSNodeStyleGetAlignItems(root)); - ASSERT_EQ(CSSAlignAuto, CSSNodeStyleGetAlignSelf(root)); - ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root)); - ASSERT_EQ(CSSWrapNoWrap, CSSNodeStyleGetFlexWrap(root)); - ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root)); + 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_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeLeft))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeTop))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeRight))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeBottom))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeEnd))); + 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_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeEnd))); + 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, CSSNodeStyleGetPadding(root, CSSEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeEnd))); + 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, CSSNodeStyleGetBorder(root, CSSEdgeLeft)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeTop)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeRight)); - ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeBottom)); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeStart))); - ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeEnd))); + 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_TRUE(CSSValueIsUndefined(CSSNodeStyleGetWidth(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetHeight(root))); @@ -70,7 +70,7 @@ TEST(CSSLayoutTest, assert_default_values) { ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetBottom(root)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetWidth(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetHeight(root))); - ASSERT_EQ(CSSDirectionInherit, CSSNodeLayoutGetDirection(root)); + ASSERT_EQ(YGDirectionInherit, CSSNodeLayoutGetDirection(root)); CSSNodeFreeRecursive(root); } diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/CSSLayoutDirtyMarkingTest.cpp index fed544f3..5177bfab 100644 --- a/tests/CSSLayoutDirtyMarkingTest.cpp +++ b/tests/CSSLayoutDirtyMarkingTest.cpp @@ -12,7 +12,7 @@ TEST(CSSLayoutTest, dirty_propagation) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -26,7 +26,7 @@ TEST(CSSLayoutTest, dirty_propagation) { CSSNodeStyleSetHeight(root_child1, 20); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeStyleSetWidth(root_child0, 20); @@ -34,7 +34,7 @@ TEST(CSSLayoutTest, dirty_propagation) { EXPECT_FALSE(CSSNodeIsDirty(root_child1)); EXPECT_TRUE(CSSNodeIsDirty(root)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); EXPECT_FALSE(CSSNodeIsDirty(root_child0)); EXPECT_FALSE(CSSNodeIsDirty(root_child1)); @@ -45,7 +45,7 @@ TEST(CSSLayoutTest, dirty_propagation) { TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -59,7 +59,7 @@ TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) { CSSNodeStyleSetHeight(root_child1, 20); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); CSSNodeStyleSetWidth(root_child0, 50); @@ -72,7 +72,7 @@ TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) { TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 50); CSSNodeStyleSetHeight(root, 50); @@ -81,7 +81,7 @@ TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) { CSSNodeStyleSetHeight(child0, 25); CSSNodeInsertChild(root, child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); const CSSNodeRef child1 = CSSNodeNew(); CSSNodeRemoveChild(root, child1); diff --git a/tests/CSSLayoutEdgeTest.cpp b/tests/CSSLayoutEdgeTest.cpp index ea171b59..00d952fa 100644 --- a/tests/CSSLayoutEdgeTest.cpp +++ b/tests/CSSLayoutEdgeTest.cpp @@ -12,22 +12,22 @@ TEST(CSSLayoutTest, start_overrides) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 20); - CSSNodeStyleSetMargin(root_child0, CSSEdgeRight, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); @@ -36,22 +36,22 @@ TEST(CSSLayoutTest, start_overrides) { TEST(CSSLayoutTest, end_overrides) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeEnd, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 20); - CSSNodeStyleSetMargin(root_child0, CSSEdgeRight, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0)); @@ -60,17 +60,17 @@ TEST(CSSLayoutTest, end_overrides) { TEST(CSSLayoutTest, horizontal_overridden) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeHorizontal, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0)); @@ -79,17 +79,17 @@ TEST(CSSLayoutTest, horizontal_overridden) { TEST(CSSLayoutTest, vertical_overridden) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionColumn); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeVertical, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeTop, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); @@ -98,17 +98,17 @@ TEST(CSSLayoutTest, vertical_overridden) { TEST(CSSLayoutTest, horizontal_overrides_all) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionColumn); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeHorizontal, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeAll, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + 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)); @@ -119,17 +119,17 @@ TEST(CSSLayoutTest, horizontal_overrides_all) { TEST(CSSLayoutTest, vertical_overrides_all) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionColumn); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeVertical, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeAll, 20); + CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + 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)); @@ -140,20 +140,20 @@ TEST(CSSLayoutTest, vertical_overrides_all) { TEST(CSSLayoutTest, all_overridden) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionColumn); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeTop, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeRight, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeBottom, 10); - CSSNodeStyleSetMargin(root_child0, CSSEdgeAll, 20); + 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); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + 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)); diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index 9b319d0d..48ac2724 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -27,7 +27,7 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -49,7 +49,7 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -76,7 +76,7 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) { TEST(CSSLayoutTest, flex_direction_row_no_width) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -90,7 +90,7 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -112,7 +112,7 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -153,7 +153,7 @@ TEST(CSSLayoutTest, flex_direction_column) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -175,7 +175,7 @@ TEST(CSSLayoutTest, flex_direction_column) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -202,7 +202,7 @@ TEST(CSSLayoutTest, flex_direction_column) { TEST(CSSLayoutTest, flex_direction_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -217,7 +217,7 @@ TEST(CSSLayoutTest, flex_direction_row) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -239,7 +239,7 @@ TEST(CSSLayoutTest, flex_direction_row) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -266,7 +266,7 @@ TEST(CSSLayoutTest, flex_direction_row) { TEST(CSSLayoutTest, flex_direction_column_reverse) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionColumnReverse); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -281,7 +281,7 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -303,7 +303,7 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -330,7 +330,7 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) { TEST(CSSLayoutTest, flex_direction_row_reverse) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRowReverse); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -345,7 +345,7 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -367,7 +367,7 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index 3ccef380..b31af0f6 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -25,7 +25,7 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -42,7 +42,7 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -64,7 +64,7 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) { TEST(CSSLayoutTest, flex_basis_flex_grow_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -76,7 +76,7 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -93,7 +93,7 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) { ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -126,7 +126,7 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexBasis(root_child1, 50); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -143,7 +143,7 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -165,7 +165,7 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -177,7 +177,7 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexBasis(root_child1, 50); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -194,7 +194,7 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -233,7 +233,7 @@ TEST(CSSLayoutTest, flex_shrink_to_zero) { CSSNodeStyleSetWidth(root_child2, 50); CSSNodeStyleSetHeight(root_child2, 50); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -255,7 +255,7 @@ TEST(CSSLayoutTest, flex_shrink_to_zero) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -300,7 +300,7 @@ TEST(CSSLayoutTest, flex_basis_overrides_main_size) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -322,7 +322,7 @@ TEST(CSSLayoutTest, flex_basis_overrides_main_size) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -359,7 +359,7 @@ TEST(CSSLayoutTest, flex_grow_shrink_at_most) { CSSNodeStyleSetFlexGrow(root_child0_child0, 1); CSSNodeStyleSetFlexShrink(root_child0_child0, 1); CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -376,7 +376,7 @@ TEST(CSSLayoutTest, flex_grow_shrink_at_most) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index ae5113c4..d4be92b5 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -14,7 +14,7 @@ TEST(CSSLayoutTest, wrap_column) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -36,7 +36,7 @@ TEST(CSSLayoutTest, wrap_column) { CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -63,7 +63,7 @@ TEST(CSSLayoutTest, wrap_column) { ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -95,8 +95,8 @@ TEST(CSSLayoutTest, wrap_column) { TEST(CSSLayoutTest, wrap_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -118,7 +118,7 @@ TEST(CSSLayoutTest, wrap_row) { CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -145,7 +145,7 @@ TEST(CSSLayoutTest, wrap_row) { ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -177,9 +177,9 @@ TEST(CSSLayoutTest, wrap_row) { TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -201,7 +201,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -228,7 +228,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -260,9 +260,9 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) { TEST(CSSLayoutTest, wrap_row_align_items_center) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetFlexWrap(root, CSSWrapWrap); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetAlignItems(root, YGAlignCenter); + CSSNodeStyleSetFlexWrap(root, YGWrapWrap); CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); @@ -284,7 +284,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) { CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -311,7 +311,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) { ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index 6ac22334..9903c437 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -14,7 +14,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -29,7 +29,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -51,7 +51,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -78,8 +78,8 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { TEST(CSSLayoutTest, justify_content_row_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -94,7 +94,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -116,7 +116,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -143,8 +143,8 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { TEST(CSSLayoutTest, justify_content_row_center) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -159,7 +159,7 @@ TEST(CSSLayoutTest, justify_content_row_center) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -181,7 +181,7 @@ TEST(CSSLayoutTest, justify_content_row_center) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -208,8 +208,8 @@ TEST(CSSLayoutTest, justify_content_row_center) { TEST(CSSLayoutTest, justify_content_row_space_between) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifySpaceBetween); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -224,7 +224,7 @@ TEST(CSSLayoutTest, justify_content_row_space_between) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -246,7 +246,7 @@ TEST(CSSLayoutTest, justify_content_row_space_between) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -273,8 +273,8 @@ TEST(CSSLayoutTest, justify_content_row_space_between) { TEST(CSSLayoutTest, justify_content_row_space_around) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifySpaceAround); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetJustifyContent(root, YGJustifySpaceAround); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -289,7 +289,7 @@ TEST(CSSLayoutTest, justify_content_row_space_around) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -311,7 +311,7 @@ TEST(CSSLayoutTest, justify_content_row_space_around) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -351,7 +351,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -373,7 +373,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) { ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -400,7 +400,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) { TEST(CSSLayoutTest, justify_content_column_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); + CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -415,7 +415,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -437,7 +437,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) { ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -464,7 +464,7 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) { TEST(CSSLayoutTest, justify_content_column_center) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -479,7 +479,7 @@ TEST(CSSLayoutTest, justify_content_column_center) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -501,7 +501,7 @@ TEST(CSSLayoutTest, justify_content_column_center) { ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -528,7 +528,7 @@ TEST(CSSLayoutTest, justify_content_column_center) { TEST(CSSLayoutTest, justify_content_column_space_between) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifySpaceBetween); + CSSNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -543,7 +543,7 @@ TEST(CSSLayoutTest, justify_content_column_space_between) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -565,7 +565,7 @@ TEST(CSSLayoutTest, justify_content_column_space_between) { ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -592,7 +592,7 @@ TEST(CSSLayoutTest, justify_content_column_space_between) { TEST(CSSLayoutTest, justify_content_column_space_around) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifySpaceAround); + CSSNodeStyleSetJustifyContent(root, YGJustifySpaceAround); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -607,7 +607,7 @@ TEST(CSSLayoutTest, justify_content_column_space_around) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -629,7 +629,7 @@ TEST(CSSLayoutTest, justify_content_column_space_around) { ASSERT_FLOAT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index 091ef4d0..a10aa362 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -14,15 +14,15 @@ TEST(CSSLayoutTest, margin_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -34,7 +34,7 @@ TEST(CSSLayoutTest, margin_start) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -55,10 +55,10 @@ TEST(CSSLayoutTest, margin_top) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeTop, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -70,7 +70,7 @@ TEST(CSSLayoutTest, margin_top) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -87,16 +87,16 @@ TEST(CSSLayoutTest, margin_top) { TEST(CSSLayoutTest, margin_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeEnd, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -108,7 +108,7 @@ TEST(CSSLayoutTest, margin_end) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -125,15 +125,15 @@ TEST(CSSLayoutTest, margin_end) { TEST(CSSLayoutTest, margin_bottom) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); + CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeBottom, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -145,7 +145,7 @@ TEST(CSSLayoutTest, margin_bottom) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -162,15 +162,15 @@ TEST(CSSLayoutTest, margin_bottom) { TEST(CSSLayoutTest, margin_and_flex_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -182,7 +182,7 @@ TEST(CSSLayoutTest, margin_and_flex_row) { ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -204,9 +204,9 @@ TEST(CSSLayoutTest, margin_and_flex_column) { const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeTop, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -218,7 +218,7 @@ TEST(CSSLayoutTest, margin_and_flex_column) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -235,15 +235,15 @@ TEST(CSSLayoutTest, margin_and_flex_column) { TEST(CSSLayoutTest, margin_and_stretch_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeTop, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -255,7 +255,7 @@ TEST(CSSLayoutTest, margin_and_stretch_row) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -277,9 +277,9 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); + CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -291,7 +291,7 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -308,7 +308,7 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { TEST(CSSLayoutTest, margin_with_sibling_row) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -319,7 +319,7 @@ TEST(CSSLayoutTest, margin_with_sibling_row) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -336,7 +336,7 @@ TEST(CSSLayoutTest, margin_with_sibling_row) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -368,7 +368,7 @@ TEST(CSSLayoutTest, margin_with_sibling_column) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -385,7 +385,7 @@ TEST(CSSLayoutTest, margin_with_sibling_column) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index 9378b579..9a9674a0 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -12,37 +12,37 @@ static CSSSize _measureMax(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { int *measureCount = (int *)CSSNodeGetContext(node); (*measureCount)++; return CSSSize { - .width = widthMode == CSSMeasureModeUndefined ? 10 : width, - .height = heightMode == CSSMeasureModeUndefined ? 10 : height, + .width = widthMode == YGMeasureModeUndefined ? 10 : width, + .height = heightMode == YGMeasureModeUndefined ? 10 : height, }; } static CSSSize _measureMin(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { int *measureCount = (int *)CSSNodeGetContext(node); *measureCount = *measureCount + 1; return CSSSize { - .width = widthMode == CSSMeasureModeUndefined || (widthMode == CSSMeasureModeAtMost && width > 10) ? 10 : width, - .height = heightMode == CSSMeasureModeUndefined || (heightMode == CSSMeasureModeAtMost && height > 10) ? 10 : height, + .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, CSSFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -53,7 +53,7 @@ TEST(CSSLayoutTest, measure_once_single_flexible_child) { CSSNodeStyleSetFlexGrow(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, measureCount); @@ -69,8 +69,8 @@ TEST(CSSLayoutTest, remeasure_with_same_exact_width_larger_than_needed_height) { CSSNodeSetMeasureFunc(root_child0, _measureMin); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); - CSSNodeCalculateLayout(root, 100, 50, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); @@ -79,7 +79,7 @@ TEST(CSSLayoutTest, remeasure_with_same_exact_width_larger_than_needed_height) { TEST(CSSLayoutTest, remeasure_with_same_atmost_width_larger_than_needed_height) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); const CSSNodeRef root_child0 = CSSNodeNew(); int measureCount = 0; @@ -87,8 +87,8 @@ TEST(CSSLayoutTest, remeasure_with_same_atmost_width_larger_than_needed_height) CSSNodeSetMeasureFunc(root_child0, _measureMin); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); - CSSNodeCalculateLayout(root, 100, 50, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); @@ -97,7 +97,7 @@ TEST(CSSLayoutTest, remeasure_with_same_atmost_width_larger_than_needed_height) TEST(CSSLayoutTest, remeasure_with_computed_width_larger_than_needed_height) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); const CSSNodeRef root_child0 = CSSNodeNew(); int measureCount = 0; @@ -105,9 +105,9 @@ TEST(CSSLayoutTest, remeasure_with_computed_width_larger_than_needed_height) { CSSNodeSetMeasureFunc(root_child0, _measureMin); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); - CSSNodeStyleSetAlignItems(root, CSSAlignStretch); - CSSNodeCalculateLayout(root, 10, 50, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); + CSSNodeStyleSetAlignItems(root, YGAlignStretch); + CSSNodeCalculateLayout(root, 10, 50, YGDirectionLTR); ASSERT_EQ(1, measureCount); @@ -116,7 +116,7 @@ TEST(CSSLayoutTest, remeasure_with_computed_width_larger_than_needed_height) { TEST(CSSLayoutTest, remeasure_with_atmost_computed_width_undefined_height) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); const CSSNodeRef root_child0 = CSSNodeNew(); int measureCount = 0; @@ -124,8 +124,8 @@ TEST(CSSLayoutTest, remeasure_with_atmost_computed_width_undefined_height) { CSSNodeSetMeasureFunc(root_child0, _measureMin); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, CSSUndefined, CSSDirectionLTR); - CSSNodeCalculateLayout(root, 10, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); + CSSNodeCalculateLayout(root, 10, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, measureCount); diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/CSSLayoutMeasureModeTest.cpp index cc946fc1..df86878c 100644 --- a/tests/CSSLayoutMeasureModeTest.cpp +++ b/tests/CSSLayoutMeasureModeTest.cpp @@ -12,9 +12,9 @@ struct _MeasureConstraint { float width; - CSSMeasureMode widthMode; + YGMeasureMode widthMode; float height; - CSSMeasureMode heightMode; + YGMeasureMode heightMode; }; struct _MeasureConstraintList { @@ -24,9 +24,9 @@ struct _MeasureConstraintList { static CSSSize _measure(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)CSSNodeGetContext(node); struct _MeasureConstraint *constraints = constraintList->constraints; uint32_t currentIndex = constraintList->length; @@ -37,8 +37,8 @@ static CSSSize _measure(CSSNodeRef node, constraintList->length = currentIndex + 1; return CSSSize { - .width = widthMode == CSSMeasureModeUndefined ? 10 : width, - .height = heightMode == CSSMeasureModeUndefined ? 10 : width, + .width = widthMode == YGMeasureModeUndefined ? 10 : width, + .height = heightMode == YGMeasureModeUndefined ? 10 : width, }; } @@ -57,12 +57,12 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_column) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); - ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].widthMode); + ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].widthMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -75,7 +75,7 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -84,12 +84,12 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -110,12 +110,12 @@ TEST(CSSLayoutTest, at_most_main_axis_column) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -128,7 +128,7 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -137,12 +137,12 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -155,7 +155,7 @@ TEST(CSSLayoutTest, at_most_main_axis_row) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -164,12 +164,12 @@ TEST(CSSLayoutTest, at_most_main_axis_row) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -182,8 +182,8 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -192,12 +192,12 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -218,15 +218,15 @@ TEST(CSSLayoutTest, flex_child) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(2, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); ASSERT_FLOAT_EQ(100, constraintList.constraints[1].height); - ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[1].heightMode); + ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[1].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -248,12 +248,12 @@ TEST(CSSLayoutTest, flex_child_with_flex_basis) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -266,8 +266,8 @@ TEST(CSSLayoutTest, overflow_scroll_column) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); - CSSNodeStyleSetOverflow(root, CSSOverflowScroll); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); + CSSNodeStyleSetOverflow(root, YGOverflowScroll); CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetWidth(root, 100); @@ -276,15 +276,15 @@ TEST(CSSLayoutTest, overflow_scroll_column) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].height)); - ASSERT_EQ(CSSMeasureModeUndefined, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); @@ -297,9 +297,9 @@ TEST(CSSLayoutTest, overflow_scroll_row) { }; const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetOverflow(root, CSSOverflowScroll); + CSSNodeStyleSetAlignItems(root, YGAlignFlexStart); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + CSSNodeStyleSetOverflow(root, YGOverflowScroll); CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetWidth(root, 100); @@ -308,15 +308,15 @@ TEST(CSSLayoutTest, overflow_scroll_row) { CSSNodeSetMeasureFunc(root_child0, _measure); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(1, constraintList.length); ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].width)); - ASSERT_EQ(CSSMeasureModeUndefined, constraintList.constraints[0].widthMode); + ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); - ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode); + ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode); free(constraintList.constraints); CSSNodeFreeRecursive(root); diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index 23ff7da3..4e84df94 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -12,9 +12,9 @@ static CSSSize _measure(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { int *measureCount = (int*) CSSNodeGetContext(node); if (measureCount) { (*measureCount)++; @@ -40,7 +40,7 @@ TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) { CSSNodeStyleSetFlexShrink(root_child0, 1); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(0, measureCount); diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index aaf2710a..3683464f 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -21,7 +21,7 @@ TEST(CSSLayoutTest, max_width) { CSSNodeStyleSetMaxWidth(root_child0, 50); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -33,7 +33,7 @@ TEST(CSSLayoutTest, max_width) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -50,7 +50,7 @@ TEST(CSSLayoutTest, max_width) { TEST(CSSLayoutTest, max_height) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -58,7 +58,7 @@ TEST(CSSLayoutTest, max_height) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetMaxHeight(root_child0, 50); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -70,7 +70,7 @@ TEST(CSSLayoutTest, max_height) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -98,7 +98,7 @@ TEST(CSSLayoutTest, min_height) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -115,7 +115,7 @@ TEST(CSSLayoutTest, min_height) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -137,7 +137,7 @@ TEST(CSSLayoutTest, min_height) { TEST(CSSLayoutTest, min_width) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -149,7 +149,7 @@ TEST(CSSLayoutTest, min_width) { const CSSNodeRef root_child1 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child1, 1); CSSNodeInsertChild(root, root_child1, 1); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -166,7 +166,7 @@ TEST(CSSLayoutTest, min_width) { ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -188,7 +188,7 @@ TEST(CSSLayoutTest, min_width) { TEST(CSSLayoutTest, justify_content_min_max) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetMinHeight(root, 100); CSSNodeStyleSetMaxHeight(root, 200); @@ -197,7 +197,7 @@ TEST(CSSLayoutTest, justify_content_min_max) { CSSNodeStyleSetWidth(root_child0, 60); CSSNodeStyleSetHeight(root_child0, 60); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -209,7 +209,7 @@ TEST(CSSLayoutTest, justify_content_min_max) { ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -226,7 +226,7 @@ TEST(CSSLayoutTest, justify_content_min_max) { TEST(CSSLayoutTest, align_items_min_max) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignCenter); + CSSNodeStyleSetAlignItems(root, YGAlignCenter); CSSNodeStyleSetMinWidth(root, 100); CSSNodeStyleSetMaxWidth(root, 200); CSSNodeStyleSetHeight(root, 100); @@ -235,7 +235,7 @@ TEST(CSSLayoutTest, align_items_min_max) { CSSNodeStyleSetWidth(root_child0, 60); CSSNodeStyleSetHeight(root_child0, 60); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -247,7 +247,7 @@ TEST(CSSLayoutTest, align_items_min_max) { ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -264,7 +264,7 @@ TEST(CSSLayoutTest, align_items_min_max) { TEST(CSSLayoutTest, justify_content_overflow_min_max) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); CSSNodeStyleSetMinHeight(root, 100); CSSNodeStyleSetMaxHeight(root, 110); @@ -282,7 +282,7 @@ TEST(CSSLayoutTest, justify_content_overflow_min_max) { CSSNodeStyleSetWidth(root_child2, 50); CSSNodeStyleSetHeight(root_child2, 50); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -304,7 +304,7 @@ TEST(CSSLayoutTest, justify_content_overflow_min_max) { ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -335,7 +335,7 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root_child0, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); CSSNodeStyleSetMaxWidth(root_child0, 100); CSSNodeInsertChild(root, root_child0, 0); @@ -343,7 +343,7 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) { CSSNodeStyleSetFlexGrow(root_child0_child0, 1); CSSNodeStyleSetHeight(root_child0_child0, 20); CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -360,7 +360,7 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -386,7 +386,7 @@ TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root_child0, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); CSSNodeStyleSetMaxWidth(root_child0, 300); CSSNodeInsertChild(root, root_child0, 0); @@ -394,7 +394,7 @@ TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { CSSNodeStyleSetFlexGrow(root_child0_child0, 1); CSSNodeStyleSetHeight(root_child0_child0, 20); CSSNodeInsertChild(root_child0, root_child0_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -411,7 +411,7 @@ TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) { ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 355c7d3c..2b9fae89 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -14,18 +14,18 @@ TEST(CSSLayoutTest, padding_no_size) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); + CSSNodeStyleSetPadding(root, YGEdgeTop, 10); + CSSNodeStyleSetPadding(root, YGEdgeRight, 10); + CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); + CSSNodeCalculateLayout(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)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -37,16 +37,16 @@ TEST(CSSLayoutTest, padding_no_size) { TEST(CSSLayoutTest, padding_container_match_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); + CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); + CSSNodeStyleSetPadding(root, YGEdgeTop, 10); + CSSNodeStyleSetPadding(root, YGEdgeRight, 10); + CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -58,7 +58,7 @@ TEST(CSSLayoutTest, padding_container_match_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -75,10 +75,10 @@ TEST(CSSLayoutTest, padding_container_match_child) { TEST(CSSLayoutTest, padding_flex_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); + CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); + CSSNodeStyleSetPadding(root, YGEdgeTop, 10); + CSSNodeStyleSetPadding(root, YGEdgeRight, 10); + CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -86,7 +86,7 @@ TEST(CSSLayoutTest, padding_flex_child) { CSSNodeStyleSetFlexGrow(root_child0, 1); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -98,7 +98,7 @@ TEST(CSSLayoutTest, padding_flex_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -115,17 +115,17 @@ TEST(CSSLayoutTest, padding_flex_child) { TEST(CSSLayoutTest, padding_stretch_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeTop, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 10); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 10); + CSSNodeStyleSetPadding(root, YGEdgeLeft, 10); + CSSNodeStyleSetPadding(root, YGEdgeTop, 10); + CSSNodeStyleSetPadding(root, YGEdgeRight, 10); + CSSNodeStyleSetPadding(root, YGEdgeBottom, 10); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -137,7 +137,7 @@ TEST(CSSLayoutTest, padding_stretch_child) { ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -154,11 +154,11 @@ TEST(CSSLayoutTest, padding_stretch_child) { TEST(CSSLayoutTest, padding_center_child) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); - CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetPadding(root, CSSEdgeStart, 10); - CSSNodeStyleSetPadding(root, CSSEdgeEnd, 20); - CSSNodeStyleSetPadding(root, CSSEdgeBottom, 20); + CSSNodeStyleSetJustifyContent(root, YGJustifyCenter); + CSSNodeStyleSetAlignItems(root, YGAlignCenter); + CSSNodeStyleSetPadding(root, YGEdgeStart, 10); + CSSNodeStyleSetPadding(root, YGEdgeEnd, 20); + CSSNodeStyleSetPadding(root, YGEdgeBottom, 20); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -166,7 +166,7 @@ TEST(CSSLayoutTest, padding_center_child) { CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -178,7 +178,7 @@ TEST(CSSLayoutTest, padding_center_child) { ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -195,20 +195,20 @@ TEST(CSSLayoutTest, padding_center_child) { TEST(CSSLayoutTest, child_with_padding_align_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); + CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd); + CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd); CSSNodeStyleSetWidth(root, 200); CSSNodeStyleSetHeight(root, 200); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetPadding(root_child0, CSSEdgeLeft, 20); - CSSNodeStyleSetPadding(root_child0, CSSEdgeTop, 20); - CSSNodeStyleSetPadding(root_child0, CSSEdgeRight, 20); - CSSNodeStyleSetPadding(root_child0, CSSEdgeBottom, 20); + 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, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -220,7 +220,7 @@ TEST(CSSLayoutTest, child_with_padding_align_end) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/CSSLayoutRelayoutTest.cpp index ee4adb36..6028ed22 100644 --- a/tests/CSSLayoutRelayoutTest.cpp +++ b/tests/CSSLayoutRelayoutTest.cpp @@ -11,7 +11,7 @@ #include TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); const CSSNodeRef root = CSSNodeNew(); @@ -20,12 +20,12 @@ TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) { CSSNodeStyleSetFlexBasis(root_child0, 20); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, 100, CSSUndefined, CSSDirectionLTR); - CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR); + CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR); + CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0)); CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false); } diff --git a/tests/CSSLayoutRoundingMeasureFuncTest.cpp b/tests/CSSLayoutRoundingMeasureFuncTest.cpp index 85acd10e..afd8deb5 100644 --- a/tests/CSSLayoutRoundingMeasureFuncTest.cpp +++ b/tests/CSSLayoutRoundingMeasureFuncTest.cpp @@ -12,9 +12,9 @@ static CSSSize _measureFloor(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { return CSSSize{ width = 10.2, @@ -24,9 +24,9 @@ static CSSSize _measureFloor(CSSNodeRef node, static CSSSize _measureCeil(CSSNodeRef node, float width, - CSSMeasureMode widthMode, + YGMeasureMode widthMode, float height, - CSSMeasureMode heightMode) { + YGMeasureMode heightMode) { return CSSSize{ width = 10.5, @@ -35,7 +35,7 @@ static CSSSize _measureCeil(CSSNodeRef node, } TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); @@ -43,18 +43,18 @@ TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) { CSSNodeSetMeasureFunc(root_child0, _measureFloor); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); @@ -62,12 +62,12 @@ TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) { CSSNodeSetMeasureFunc(root_child0, _measureCeil); CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0)); CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } diff --git a/tests/CSSLayoutRoundingTest.cpp b/tests/CSSLayoutRoundingTest.cpp index 9991dbaa..635370da 100644 --- a/tests/CSSLayoutRoundingTest.cpp +++ b/tests/CSSLayoutRoundingTest.cpp @@ -13,10 +13,10 @@ #include TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -31,7 +31,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -53,7 +53,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { ASSERT_FLOAT_EQ(33, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -77,14 +77,14 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 113); CSSNodeStyleSetHeight(root, 100); @@ -107,7 +107,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { const CSSNodeRef root_child4 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child4, 1); CSSNodeInsertChild(root, root_child4, 4); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -139,7 +139,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { ASSERT_FLOAT_EQ(23, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child4)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -173,14 +173,14 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow); CSSNodeStyleSetWidth(root, 101); CSSNodeStyleSetHeight(root, 100); @@ -196,7 +196,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { const CSSNodeRef root_child2 = CSSNodeNew(); CSSNodeStyleSetFlexBasis(root_child2, 25); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -218,7 +218,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -242,11 +242,11 @@ TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); @@ -267,7 +267,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -289,7 +289,7 @@ TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -313,11 +313,11 @@ TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_total_fractial) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 87.4f); @@ -338,7 +338,7 @@ TEST(CSSLayoutTest, rounding_total_fractial) { CSSNodeStyleSetFlexGrow(root_child2, 1.1f); CSSNodeStyleSetHeight(root_child2, 10.7f); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -360,7 +360,7 @@ TEST(CSSLayoutTest, rounding_total_fractial) { ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -384,11 +384,11 @@ TEST(CSSLayoutTest, rounding_total_fractial) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_total_fractial_nested) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 87.4f); @@ -403,14 +403,14 @@ TEST(CSSLayoutTest, rounding_total_fractial_nested) { const CSSNodeRef root_child0_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0_child0, 1); CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f); - CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f); + CSSNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); CSSNodeStyleSetHeight(root_child0_child0, 9.9f); CSSNodeInsertChild(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, CSSEdgeTop, 13.3f); + CSSNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); CSSNodeStyleSetHeight(root_child0_child1, 1.1f); CSSNodeInsertChild(root_child0, root_child0_child1, 1); @@ -423,7 +423,7 @@ TEST(CSSLayoutTest, rounding_total_fractial_nested) { CSSNodeStyleSetFlexGrow(root_child2, 1.1f); CSSNodeStyleSetHeight(root_child2, 10.7f); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -455,7 +455,7 @@ TEST(CSSLayoutTest, rounding_total_fractial_nested) { ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -489,11 +489,11 @@ TEST(CSSLayoutTest, rounding_total_fractial_nested) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_fractial_input_1) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); @@ -514,7 +514,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_1) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -536,7 +536,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_1) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -560,11 +560,11 @@ TEST(CSSLayoutTest, rounding_fractial_input_1) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_fractial_input_2) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); @@ -585,7 +585,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_2) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -607,7 +607,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_2) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -631,14 +631,14 @@ TEST(CSSLayoutTest, rounding_fractial_input_2) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_fractial_input_3) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.3f); + CSSNodeStyleSetPosition(root, YGEdgeTop, 0.3f); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 113.4f); @@ -657,7 +657,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_3) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -679,7 +679,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_3) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root)); @@ -703,14 +703,14 @@ TEST(CSSLayoutTest, rounding_fractial_input_3) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } TEST(CSSLayoutTest, rounding_fractial_input_4) { - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true); const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.7f); + CSSNodeStyleSetPosition(root, YGEdgeTop, 0.7f); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 113.4f); @@ -729,7 +729,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_4) { CSSNodeStyleSetFlexGrow(root_child2, 1); CSSNodeStyleSetHeight(root_child2, 10); CSSNodeInsertChild(root, root_child2, 2); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(1, CSSNodeLayoutGetTop(root)); @@ -751,7 +751,7 @@ TEST(CSSLayoutTest, rounding_fractial_input_4) { ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2)); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(1, CSSNodeLayoutGetTop(root)); @@ -775,5 +775,5 @@ TEST(CSSLayoutTest, rounding_fractial_input_4) { CSSNodeFreeRecursive(root); - CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false); + CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false); } diff --git a/tests/CSSLayoutStyleTest.cpp b/tests/CSSLayoutStyleTest.cpp index 0ff51890..fe2a7827 100644 --- a/tests/CSSLayoutStyleTest.cpp +++ b/tests/CSSLayoutStyleTest.cpp @@ -25,16 +25,16 @@ TEST(CSSLayoutTest, copy_style_same) { TEST(CSSLayoutTest, copy_style_modified) { const CSSNodeRef node0 = CSSNodeNew(); ASSERT_FALSE(CSSNodeIsDirty(node0)); - ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0)); + ASSERT_EQ(YGFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0)); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0))); const CSSNodeRef node1 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); CSSNodeStyleSetMaxHeight(node1, 10); CSSNodeCopyStyle(node0, node1); ASSERT_TRUE(CSSNodeIsDirty(node0)); - ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0)); + ASSERT_EQ(YGFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0)); ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0)); CSSNodeFree(node0); @@ -43,13 +43,13 @@ TEST(CSSLayoutTest, copy_style_modified) { TEST(CSSLayoutTest, copy_style_modified_same) { const CSSNodeRef node0 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node0, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(node0, YGFlexDirectionRow); CSSNodeStyleSetMaxHeight(node0, 10); - CSSNodeCalculateLayout(node0, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FALSE(CSSNodeIsDirty(node0)); const CSSNodeRef node1 = CSSNodeNew(); - CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow); + CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); CSSNodeStyleSetMaxHeight(node1, 10); CSSNodeCopyStyle(node0, node1); From b9feb10420d8fb335bdce3e35948d75538fcef08 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 11:18:12 -0800 Subject: [PATCH 093/108] Rename benchmarks Summary: new name Reviewed By: splhack Differential Revision: D4245765 fbshipit-source-id: c524183ead279ad1d9159a1da2f18fc1b96c2b51 --- benchmark/{CSSBenchmark.c => YGBenchmark.c} | 12 ++++++------ benchmark/{CSSBenchmark.h => YGBenchmark.h} | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) rename benchmark/{CSSBenchmark.c => YGBenchmark.c} (94%) rename benchmark/{CSSBenchmark.h => YGBenchmark.h} (95%) diff --git a/benchmark/CSSBenchmark.c b/benchmark/YGBenchmark.c similarity index 94% rename from benchmark/CSSBenchmark.c rename to benchmark/YGBenchmark.c index 79499f29..22d639d8 100644 --- a/benchmark/CSSBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include "CSSBenchmark.h" +#include "YGBenchmark.h" #include @@ -22,9 +22,9 @@ static CSSSize _measure(CSSNodeRef node, }; } -CSS_BENCHMARKS({ +YGBENCHMARKS({ - CSS_BENCHMARK("Stack with flex", { + YGBENCHMARK("Stack with flex", { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -40,7 +40,7 @@ CSS_BENCHMARKS({ CSSNodeFreeRecursive(root); }); - CSS_BENCHMARK("Align stretch in undefined axis", { + YGBENCHMARK("Align stretch in undefined axis", { const CSSNodeRef root = CSSNodeNew(); for (uint32_t i = 0; i < 10; i++) { @@ -54,7 +54,7 @@ CSS_BENCHMARKS({ CSSNodeFreeRecursive(root); }); - CSS_BENCHMARK("Nested flex", { + YGBENCHMARK("Nested flex", { const CSSNodeRef root = CSSNodeNew(); for (uint32_t i = 0; i < 10; i++) { @@ -74,7 +74,7 @@ CSS_BENCHMARKS({ CSSNodeFreeRecursive(root); }); - CSS_BENCHMARK("Huge nested layout", { + YGBENCHMARK("Huge nested layout", { const CSSNodeRef root = CSSNodeNew(); for (uint32_t i = 0; i < 10; i++) { diff --git a/benchmark/CSSBenchmark.h b/benchmark/YGBenchmark.h similarity index 95% rename from benchmark/CSSBenchmark.h rename to benchmark/YGBenchmark.h index f1314e98..4ebd2841 100644 --- a/benchmark/CSSBenchmark.h +++ b/benchmark/YGBenchmark.h @@ -17,7 +17,7 @@ #define NUM_REPETITIONS 1000 -#define CSS_BENCHMARKS(BLOCK) \ +#define YGBENCHMARKS(BLOCK) \ int main(int argc, char const *argv[]) { \ clock_t __start; \ clock_t __endTimes[NUM_REPETITIONS]; \ @@ -25,7 +25,7 @@ return 0; \ } -#define CSS_BENCHMARK(NAME, BLOCK) \ +#define YGBENCHMARK(NAME, BLOCK) \ __start = clock(); \ for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \ { BLOCK } \ From 4bbf35832e93275693c80a4b8c05c5f0384128ed Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 11:18:15 -0800 Subject: [PATCH 094/108] Rename CSSLayoutKit Summary: new name Reviewed By: dshahidehpour Differential Revision: D4245987 fbshipit-source-id: 880f558c694bd041abbedadeb91225a3ca6c14f9 --- .travis.yml | 2 +- CSSLayoutKit/UIView+CSSLayout.h | 72 --------- README.md | 14 +- {CSSLayoutKit => YogaKit}/BUCK | 8 +- {CSSLayoutKit => YogaKit}/Tests/Info.plist | 0 .../Tests/YogaKitTests.m | 152 +++++++++--------- YogaKit/UIView+Yoga.h | 72 +++++++++ .../UIView+Yoga.m | 80 ++++----- 8 files changed, 200 insertions(+), 200 deletions(-) delete mode 100644 CSSLayoutKit/UIView+CSSLayout.h rename {CSSLayoutKit => YogaKit}/BUCK (93%) rename {CSSLayoutKit => YogaKit}/Tests/Info.plist (100%) rename CSSLayoutKit/Tests/CSSLayoutKitTests.m => YogaKit/Tests/YogaKitTests.m (69%) create mode 100644 YogaKit/UIView+Yoga.h rename CSSLayoutKit/UIView+CSSLayout.m => YogaKit/UIView+Yoga.m (80%) diff --git a/.travis.yml b/.travis.yml index f74b3aaf..8e09e9ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_install: script: - buck test //:CSSLayout - buck test //java:java - - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI + - buck test //YogaKit:YogaKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI - sh csharp/tests/Facebook.CSSLayout/test_macos.sh - buck run //benchmark:benchmark - git checkout HEAD^ diff --git a/CSSLayoutKit/UIView+CSSLayout.h b/CSSLayoutKit/UIView+CSSLayout.h deleted file mode 100644 index c88fbfbb..00000000 --- a/CSSLayoutKit/UIView+CSSLayout.h +++ /dev/null @@ -1,72 +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. - */ - -#import -#import - -@interface UIView (CSSLayout) - -/** - The property that decides if we should include this view when calculating layout. Defaults to YES. - */ -@property (nonatomic, readwrite, assign, setter=css_setIncludeInLayout:) BOOL css_includeInLayout; - -/** - The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO. - */ -@property (nonatomic, readwrite, assign, setter=css_setUsesFlexbox:) BOOL css_usesFlexbox; - -- (void)css_setDirection:(YGDirection)direction; -- (void)css_setFlexDirection:(YGFlexDirection)flexDirection; -- (void)css_setJustifyContent:(YGJustify)justifyContent; -- (void)css_setAlignContent:(YGAlign)alignContent; -- (void)css_setAlignItems:(YGAlign)alignItems; -- (void)css_setAlignSelf:(YGAlign)alignSelf; -- (void)css_setPositionType:(YGPositionType)positionType; -- (void)css_setFlexWrap:(YGWrap)flexWrap; - -- (void)css_setFlexGrow:(CGFloat)flexGrow; -- (void)css_setFlexShrink:(CGFloat)flexShrink; -- (void)css_setFlexBasis:(CGFloat)flexBasis; - -- (void)css_setPosition:(CGFloat)position forEdge:(YGEdge)edge; -- (void)css_setMargin:(CGFloat)margin forEdge:(YGEdge)edge; -- (void)css_setPadding:(CGFloat)padding forEdge:(YGEdge)edge; - -- (void)css_setWidth:(CGFloat)width; -- (void)css_setHeight:(CGFloat)height; -- (void)css_setMinWidth:(CGFloat)minWidth; -- (void)css_setMinHeight:(CGFloat)minHeight; -- (void)css_setMaxWidth:(CGFloat)maxWidth; -- (void)css_setMaxHeight:(CGFloat)maxHeight; - -// Yoga specific properties, not compatible with flexbox specification -- (void)css_setAspectRatio:(CGFloat)aspectRatio; - -/** - Get the resolved direction of this node. This won't be YGDirectionInherit - */ -- (YGDirection)css_resolvedDirection; - -/** - Perform a layout calculation and update the frames of the views in the hierarchy with th results - */ -- (void)css_applyLayout; - -/** - Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; - */ -- (CGSize)css_intrinsicSize; - -/** - Returns the number of children that are using Flexbox. - */ -- (NSUInteger)css_numberOfChildren; - -@end diff --git a/README.md b/README.md index c6bd9f37..09941370 100644 --- a/README.md +++ b/README.md @@ -94,23 +94,23 @@ root.getLayoutHeight(); ``` ### UIKit -The full API can be found in `CSSLayoutKit/UIView+CSSLayout.h`. +The full API can be found in `YogaKit/UIView+Yoga.h`. ```objective-c UIView *root = [UIView new]; -[root css_setUsesFlexbox:YES]; -[root css_setWidth:100]; -[root css_setHeight:100]; +[root yg_setUsesYoga:YES]; +[root yg_setWidth:100]; +[root yg_setHeight:100]; for (NSUInteger i = 0; i < 10; i++) { UIView *child = [UIView new]; - [child css_setUsesFlexbox:YES]; - [child css_setHeight:10]; + [child yg_setUsesYoga:YES]; + [child yg_setHeight:10]; [root addSubview:child]; } // Resulting layout will be set on the UIView hierarchy frames. -[root css_applyLayout]; +[root yg_applyLayout]; ``` ### .NET diff --git a/CSSLayoutKit/BUCK b/YogaKit/BUCK similarity index 93% rename from CSSLayoutKit/BUCK rename to YogaKit/BUCK index 224d68b7..fc97569b 100644 --- a/CSSLayoutKit/BUCK +++ b/YogaKit/BUCK @@ -28,9 +28,9 @@ UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ ] apple_library( - name = 'CSSLayoutKit', + name = 'YogaKit', compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, - tests = [':CSSLayoutKitTests'], + tests = [':YogaKitTests'], srcs = glob(['*.m']), exported_headers = glob(['*.h']), frameworks = [ @@ -44,7 +44,7 @@ apple_library( ) apple_test( - name = 'CSSLayoutKitTests', + name = 'YogaKitTests', compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, info_plist = 'Tests/Info.plist', srcs = glob(['Tests/**/*.m']), @@ -53,7 +53,7 @@ apple_test( '$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework', ], deps = [ - ':CSSLayoutKit', + ':YogaKit', ], visibility = ['PUBLIC'], ) diff --git a/CSSLayoutKit/Tests/Info.plist b/YogaKit/Tests/Info.plist similarity index 100% rename from CSSLayoutKit/Tests/Info.plist rename to YogaKit/Tests/Info.plist diff --git a/CSSLayoutKit/Tests/CSSLayoutKitTests.m b/YogaKit/Tests/YogaKitTests.m similarity index 69% rename from CSSLayoutKit/Tests/CSSLayoutKitTests.m rename to YogaKit/Tests/YogaKitTests.m index b125f382..2b31d9ce 100644 --- a/CSSLayoutKit/Tests/CSSLayoutKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -9,12 +9,12 @@ #import -#import "UIView+CSSLayout.h" +#import "UIView+Yoga.h" -@interface CSSLayoutKitTests : XCTestCase +@interface YogaKitTests : XCTestCase @end -@implementation CSSLayoutKitTests +@implementation YogaKitTests #ifndef TRAVIS_CI @@ -23,7 +23,7 @@ XCTAssertEqual(0, CSSNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - [view css_setFlexBasis:1]; + [view yg_setFlexBasis:1]; XCTAssertEqual(1, CSSNodeGetInstanceCount()); view = nil; @@ -35,11 +35,11 @@ XCTAssertEqual(0, CSSNodeGetInstanceCount()); UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - [view css_setFlexBasis:1]; + [view yg_setFlexBasis:1]; for (int i=0; i<10; i++) { UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; - [subview css_setFlexBasis:1]; + [subview yg_setFlexBasis:1]; [view addSubview:subview]; } XCTAssertEqual(11, CSSNodeGetInstanceCount()); @@ -50,49 +50,49 @@ #endif -- (void)testUsesFlexbox +- (void)testUsesYoga { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - XCTAssertFalse([view css_usesFlexbox]); + XCTAssertFalse([view yg_usesYoga]); - [view css_setUsesFlexbox:YES]; - XCTAssertTrue([view css_usesFlexbox]); + [view yg_setUsesYoga:YES]; + XCTAssertTrue([view yg_usesYoga]); - [view css_setUsesFlexbox:NO]; - XCTAssertFalse([view css_usesFlexbox]); + [view yg_setUsesYoga:NO]; + XCTAssertFalse([view yg_usesYoga]); } - (void)testSizeThatFitsAsserts { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){ - XCTAssertThrows([view css_intrinsicSize]); + dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){ + XCTAssertThrows([view yg_intrinsicSize]); }); } - (void)testSizeThatFitsSmoke { UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; - [container css_setAlignItems:YGAlignFlexStart]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; + [container yg_setAlignItems:YGAlignFlexStart]; UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; longTextLabel.text = @"This is a very very very very very very very very long piece of text."; longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail; longTextLabel.numberOfLines = 1; - [longTextLabel css_setUsesFlexbox:YES]; - [longTextLabel css_setFlexShrink:1]; + [longTextLabel yg_setUsesYoga:YES]; + [longTextLabel yg_setFlexShrink:1]; [container addSubview:longTextLabel]; UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero]; - [textBadgeView css_setUsesFlexbox:YES]; - [textBadgeView css_setMargin:3.0 forEdge:YGEdgeLeft]; - [textBadgeView css_setWidth:10]; - [textBadgeView css_setHeight:10]; + [textBadgeView yg_setUsesYoga:YES]; + [textBadgeView yg_setMargin:3.0 forEdge:YGEdgeLeft]; + [textBadgeView yg_setWidth:10]; + [textBadgeView yg_setHeight:10]; [container addSubview:textBadgeView]; - const CGSize containerSize = [container css_intrinsicSize]; + const CGSize containerSize = [container yg_intrinsicSize]; XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize)); } @@ -101,17 +101,17 @@ const CGSize containerSize = CGSizeMake(320, 50); UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; for (int i = 0; i < 3; i++) { UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; - [subview css_setUsesFlexbox:YES]; - [subview css_setFlexGrow:1]; + [subview yg_setUsesYoga:YES]; + [subview yg_setFlexGrow:1]; [container addSubview:subview]; } - [container css_applyLayout]; + [container yg_applyLayout]; XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame)); XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame)); @@ -130,33 +130,33 @@ const CGSize containerSize = CGSizeMake(300, 50); UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview1 css_setUsesFlexbox:YES]; - [subview1 css_setFlexGrow:1]; + [subview1 yg_setUsesYoga:YES]; + [subview1 yg_setFlexGrow:1]; [container addSubview:subview1]; UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview2 css_setUsesFlexbox:YES]; - [subview2 css_setFlexGrow:1]; + [subview2 yg_setUsesYoga:YES]; + [subview2 yg_setFlexGrow:1]; [container addSubview:subview2]; UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview3 css_setUsesFlexbox:YES]; - [subview3 css_setFlexGrow:1]; + [subview3 yg_setUsesYoga:YES]; + [subview3 yg_setFlexGrow:1]; [container addSubview:subview3]; - [container css_applyLayout]; + [container yg_applyLayout]; XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50))); XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame)); XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50))); [container exchangeSubviewAtIndex:2 withSubviewAtIndex:0]; - [subview2 css_setIncludeInLayout:NO]; - [container css_applyLayout]; + [subview2 yg_setIncludeInLayout:NO]; + [container yg_applyLayout]; XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50))); XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50))); @@ -170,32 +170,32 @@ const CGSize containerSize = CGSizeMake(300, 50); UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview1 css_setUsesFlexbox:YES]; - [subview1 css_setFlexGrow:1]; + [subview1 yg_setUsesYoga:YES]; + [subview1 yg_setFlexGrow:1]; [container addSubview:subview1]; UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview2 css_setUsesFlexbox:YES]; - [subview2 css_setFlexGrow:1]; + [subview2 yg_setUsesYoga:YES]; + [subview2 yg_setFlexGrow:1]; [container addSubview:subview2]; UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview3 css_setUsesFlexbox:YES]; - [subview3 css_setFlexGrow:1]; + [subview3 yg_setUsesYoga:YES]; + [subview3 yg_setFlexGrow:1]; [container addSubview:subview3]; - [container css_applyLayout]; + [container yg_applyLayout]; for (UIView *view in container.subviews) { XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size)); } - [subview3 css_setIncludeInLayout:NO]; - [container css_applyLayout]; + [subview3 yg_setIncludeInLayout:NO]; + [container yg_applyLayout]; XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size)); XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size)); @@ -207,62 +207,62 @@ - (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews { UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview1 css_setUsesFlexbox:YES]; - [subview1 css_setIncludeInLayout:NO]; + [subview1 yg_setUsesYoga:YES]; + [subview1 yg_setIncludeInLayout:NO]; [container addSubview:subview1]; UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview2 css_setUsesFlexbox:YES]; - [subview2 css_setIncludeInLayout:NO]; + [subview2 yg_setUsesYoga:YES]; + [subview2 yg_setIncludeInLayout:NO]; [container addSubview:subview2]; UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview3 css_setUsesFlexbox:YES]; - [subview3 css_setIncludeInLayout:YES]; + [subview3 yg_setUsesYoga:YES]; + [subview3 yg_setIncludeInLayout:YES]; [container addSubview:subview3]; - [container css_applyLayout]; - XCTAssertEqual(1, [container css_numberOfChildren]); + [container yg_applyLayout]; + XCTAssertEqual(1, [container yg_numberOfChildren]); - [subview2 css_setIncludeInLayout:YES]; - [container css_applyLayout]; - XCTAssertEqual(2, [container css_numberOfChildren]); + [subview2 yg_setIncludeInLayout:YES]; + [container yg_applyLayout]; + XCTAssertEqual(2, [container yg_numberOfChildren]); } - (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond { UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)]; - [container css_setUsesFlexbox:YES]; - [container css_setFlexDirection:YGFlexDirectionRow]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionRow]; UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview1 css_setUsesFlexbox:YES]; - [subview1 css_setFlexGrow:1]; + [subview1 yg_setUsesYoga:YES]; + [subview1 yg_setFlexGrow:1]; [container addSubview:subview1]; UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview2 css_setUsesFlexbox:YES]; - [subview2 css_setFlexGrow:1]; + [subview2 yg_setUsesYoga:YES]; + [subview2 yg_setFlexGrow:1]; [container addSubview:subview2]; UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero]; - [subview3 css_setUsesFlexbox:YES]; - [subview3 css_setFlexGrow:1]; - [subview3 css_setIncludeInLayout:NO]; + [subview3 yg_setUsesYoga:YES]; + [subview3 yg_setFlexGrow:1]; + [subview3 yg_setIncludeInLayout:NO]; [container addSubview:subview3]; - [container css_applyLayout]; + [container yg_applyLayout]; XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size)); XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size)); XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size)); - [subview3 css_setIncludeInLayout:YES]; - [container css_applyLayout]; + [subview3 yg_setIncludeInLayout:YES]; + [container yg_applyLayout]; for (UIView *view in container.subviews) { XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size)); } diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h new file mode 100644 index 00000000..b23b2027 --- /dev/null +++ b/YogaKit/UIView+Yoga.h @@ -0,0 +1,72 @@ +/** + * 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. + */ + +#import +#import + +@interface UIView (CSSLayout) + +/** + The property that decides if we should include this view when calculating layout. Defaults to YES. + */ +@property (nonatomic, readwrite, assign, setter=yg_setIncludeInLayout:) BOOL yg_includeInLayout; + +/** + The property that decides during layout/sizing whether or not yg_* properties should be applied. Defaults to NO. + */ +@property (nonatomic, readwrite, assign, setter=yg_setUsesYoga:) BOOL yg_usesYoga; + +- (void)yg_setDirection:(YGDirection)direction; +- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection; +- (void)yg_setJustifyContent:(YGJustify)justifyContent; +- (void)yg_setAlignContent:(YGAlign)alignContent; +- (void)yg_setAlignItems:(YGAlign)alignItems; +- (void)yg_setAlignSelf:(YGAlign)alignSelf; +- (void)yg_setPositionType:(YGPositionType)positionType; +- (void)yg_setFlexWrap:(YGWrap)flexWrap; + +- (void)yg_setFlexGrow:(CGFloat)flexGrow; +- (void)yg_setFlexShrink:(CGFloat)flexShrink; +- (void)yg_setFlexBasis:(CGFloat)flexBasis; + +- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge; +- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge; +- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge; + +- (void)yg_setWidth:(CGFloat)width; +- (void)yg_setHeight:(CGFloat)height; +- (void)yg_setMinWidth:(CGFloat)minWidth; +- (void)yg_setMinHeight:(CGFloat)minHeight; +- (void)yg_setMaxWidth:(CGFloat)maxWidth; +- (void)yg_setMaxHeight:(CGFloat)maxHeight; + +// Yoga specific properties, not compatible with flexbox specification +- (void)yg_setAspectRatio:(CGFloat)aspectRatio; + +/** + Get the resolved direction of this node. This won't be YGDirectionInherit + */ +- (YGDirection)yg_resolvedDirection; + +/** + Perform a layout calculation and update the frames of the views in the hierarchy with th results + */ +- (void)yg_applyLayout; + +/** + Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; + */ +- (CGSize)yg_intrinsicSize; + +/** + Returns the number of children that are using Flexbox. + */ +- (NSUInteger)yg_numberOfChildren; + +@end diff --git a/CSSLayoutKit/UIView+CSSLayout.m b/YogaKit/UIView+Yoga.m similarity index 80% rename from CSSLayoutKit/UIView+CSSLayout.m rename to YogaKit/UIView+Yoga.m index 21b4010a..32299d9e 100644 --- a/CSSLayoutKit/UIView+CSSLayout.m +++ b/YogaKit/UIView+Yoga.m @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import "UIView+CSSLayout.h" +#import "UIView+Yoga.h" #import @@ -39,162 +39,162 @@ @implementation UIView (CSSLayout) -- (BOOL)css_usesFlexbox +- (BOOL)yg_usesYoga { - NSNumber *usesFlexbox = objc_getAssociatedObject(self, @selector(css_usesFlexbox)); - return [usesFlexbox boolValue]; + NSNumber *usesYoga = objc_getAssociatedObject(self, @selector(yg_usesYoga)); + return [usesYoga boolValue]; } -- (BOOL)css_includeInLayout +- (BOOL)yg_includeInLayout { - NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(css_includeInLayout)); + NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(yg_includeInLayout)); return (includeInLayout != nil) ? [includeInLayout boolValue] : YES; } -- (NSUInteger)css_numberOfChildren +- (NSUInteger)yg_numberOfChildren { return CSSNodeChildCount([self cssNode]); } #pragma mark - Setters -- (void)css_setIncludeInLayout:(BOOL)includeInLayout +- (void)yg_setIncludeInLayout:(BOOL)includeInLayout { objc_setAssociatedObject( self, - @selector(css_includeInLayout), + @selector(yg_includeInLayout), @(includeInLayout), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (void)css_setUsesFlexbox:(BOOL)enabled +- (void)yg_setUsesYoga:(BOOL)enabled { objc_setAssociatedObject( self, - @selector(css_usesFlexbox), + @selector(yg_usesYoga), @(enabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (void)css_setDirection:(YGDirection)direction +- (void)yg_setDirection:(YGDirection)direction { CSSNodeStyleSetDirection([self cssNode], direction); } -- (void)css_setFlexDirection:(YGFlexDirection)flexDirection +- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection { CSSNodeStyleSetFlexDirection([self cssNode], flexDirection); } -- (void)css_setJustifyContent:(YGJustify)justifyContent +- (void)yg_setJustifyContent:(YGJustify)justifyContent { CSSNodeStyleSetJustifyContent([self cssNode], justifyContent); } -- (void)css_setAlignContent:(YGAlign)alignContent +- (void)yg_setAlignContent:(YGAlign)alignContent { CSSNodeStyleSetAlignContent([self cssNode], alignContent); } -- (void)css_setAlignItems:(YGAlign)alignItems +- (void)yg_setAlignItems:(YGAlign)alignItems { CSSNodeStyleSetAlignItems([self cssNode], alignItems); } -- (void)css_setAlignSelf:(YGAlign)alignSelf +- (void)yg_setAlignSelf:(YGAlign)alignSelf { CSSNodeStyleSetAlignSelf([self cssNode], alignSelf); } -- (void)css_setPositionType:(YGPositionType)positionType +- (void)yg_setPositionType:(YGPositionType)positionType { CSSNodeStyleSetPositionType([self cssNode], positionType); } -- (void)css_setFlexWrap:(YGWrap)flexWrap +- (void)yg_setFlexWrap:(YGWrap)flexWrap { CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); } -- (void)css_setFlexGrow:(CGFloat)flexGrow +- (void)yg_setFlexGrow:(CGFloat)flexGrow { CSSNodeStyleSetFlexGrow([self cssNode], flexGrow); } -- (void)css_setFlexShrink:(CGFloat)flexShrink +- (void)yg_setFlexShrink:(CGFloat)flexShrink { CSSNodeStyleSetFlexShrink([self cssNode], flexShrink); } -- (void)css_setFlexBasis:(CGFloat)flexBasis +- (void)yg_setFlexBasis:(CGFloat)flexBasis { CSSNodeStyleSetFlexBasis([self cssNode], flexBasis); } -- (void)css_setPosition:(CGFloat)position forEdge:(YGEdge)edge +- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge { CSSNodeStyleSetPosition([self cssNode], edge, position); } -- (void)css_setMargin:(CGFloat)margin forEdge:(YGEdge)edge +- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge { CSSNodeStyleSetMargin([self cssNode], edge, margin); } -- (void)css_setPadding:(CGFloat)padding forEdge:(YGEdge)edge +- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge { CSSNodeStyleSetPadding([self cssNode], edge, padding); } -- (void)css_setWidth:(CGFloat)width +- (void)yg_setWidth:(CGFloat)width { CSSNodeStyleSetWidth([self cssNode], width); } -- (void)css_setHeight:(CGFloat)height +- (void)yg_setHeight:(CGFloat)height { CSSNodeStyleSetHeight([self cssNode], height); } -- (void)css_setMinWidth:(CGFloat)minWidth +- (void)yg_setMinWidth:(CGFloat)minWidth { CSSNodeStyleSetMinWidth([self cssNode], minWidth); } -- (void)css_setMinHeight:(CGFloat)minHeight +- (void)yg_setMinHeight:(CGFloat)minHeight { CSSNodeStyleSetMinHeight([self cssNode], minHeight); } -- (void)css_setMaxWidth:(CGFloat)maxWidth +- (void)yg_setMaxWidth:(CGFloat)maxWidth { CSSNodeStyleSetMaxWidth([self cssNode], maxWidth); } -- (void)css_setMaxHeight:(CGFloat)maxHeight +- (void)yg_setMaxHeight:(CGFloat)maxHeight { CSSNodeStyleSetMaxHeight([self cssNode], maxHeight); } -- (void)css_setAspectRatio:(CGFloat)aspectRatio +- (void)yg_setAspectRatio:(CGFloat)aspectRatio { CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio); } #pragma mark - Layout and Sizing -- (YGDirection)css_resolvedDirection +- (YGDirection)yg_resolvedDirection { return CSSNodeLayoutGetDirection([self cssNode]); } -- (void)css_applyLayout +- (void)yg_applyLayout { [self calculateLayoutWithSize:self.bounds.size]; CSSApplyLayoutToViewHierarchy(self); } -- (CGSize)css_intrinsicSize +- (CGSize)yg_intrinsicSize { const CGSize constrainedSize = { .width = YGUndefined, @@ -220,7 +220,7 @@ - (CGSize)calculateLayoutWithSize:(CGSize)size { NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main."); - NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view."); + NSAssert([self yg_usesYoga], @"CSS Layout is not enabled for this view."); CSSAttachNodesFromViewHierachy(self); @@ -280,7 +280,7 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { CSSNodeRef node = [view cssNode]; // Only leaf nodes should have a measure function - if (![view css_usesFlexbox] || view.subviews.count == 0) { + if (![view yg_usesYoga] || view.subviews.count == 0) { CSSNodeSetMeasureFunc(node, CSSMeasureView); CSSRemoveAllChildren(node); } else { @@ -289,7 +289,7 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) { // Create a list of all the subviews that we are going to use for layout. NSMutableArray *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count]; for (UIView *subview in view.subviews) { - if ([subview css_includeInLayout]) { + if ([subview yg_includeInLayout]) { [subviewsToInclude addObject:subview]; } } @@ -342,7 +342,7 @@ static CGFloat CSSRoundPixelValue(CGFloat value) static void CSSApplyLayoutToViewHierarchy(UIView *view) { NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); - if (![view css_includeInLayout]) { + if (![view yg_includeInLayout]) { return; } @@ -368,7 +368,7 @@ static void CSSApplyLayoutToViewHierarchy(UIView *view) { }, }; - const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0; + 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]); From f7cc614d67aee4e5be431fe4bc2d23928156b2d3 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 2 Dec 2016 11:18:16 -0800 Subject: [PATCH 095/108] rename csharp code Summary: new name Reviewed By: splhack Differential Revision: D4247106 fbshipit-source-id: 6e1097de104f3a011c78ae65b33e57865b007711 --- .travis.yml | 2 +- csharp/BUCK | 4 +- ...cebook.CSSLayout.sln => Facebook.Yoga.sln} | 4 +- .../Facebook.Yoga.xproj} | 2 +- .../MeasureFunction.cs | 4 +- .../MeasureOutput.cs | 2 +- .../Native.cs | 12 +- .../Properties/AssemblyInfo.cs | 2 +- .../Spacing.cs | 2 +- .../YogaAlign.cs | 2 +- .../YogaConstants.cs | 2 +- .../YogaDimension.cs | 2 +- .../YogaDirection.cs | 2 +- .../YogaEdge.cs | 2 +- .../YogaExperimentalFeature.cs | 2 +- .../YogaFlexDirection.cs | 2 +- .../YogaJustify.cs | 2 +- .../YogaLogLevel.cs | 2 +- .../YogaLogger.cs} | 6 +- .../YogaMeasureFunc.cs} | 4 +- .../YogaMeasureMode.cs | 2 +- .../YogaNode.Create.cs} | 50 +++--- .../CSSNode.cs => Facebook.Yoga/YogaNode.cs} | 52 +++--- .../YogaOverflow.cs | 2 +- .../YogaPositionType.cs | 2 +- .../YogaPrintOptions.cs | 2 +- .../CSSSize.cs => Facebook.Yoga/YogaSize.cs} | 4 +- .../YogaWrap.cs | 2 +- .../project.json | 0 .../CSSInterop.cpp => Yoga/YGInterop.cpp} | 6 +- .../CSSInterop.h => Yoga/YGInterop.h} | 4 +- .../CSSLayout.vcxproj => Yoga/Yoga.vcxproj} | 8 +- .../Yoga.vcxproj.filters} | 6 +- csharp/{CSSLayout => Yoga}/dllmain.cpp | 0 csharp/{CSSLayout => Yoga}/stdafx.cpp | 2 +- csharp/{CSSLayout => Yoga}/stdafx.h | 0 csharp/{CSSLayout => Yoga}/targetver.h | 0 .../CSSLayoutAbsolutePositionTest.cs | 30 ++-- .../CSSLayoutAlignContentTest.cs | 50 +++--- .../CSSLayoutAlignItemsTest.cs | 18 +-- .../CSSLayoutAlignSelfTest.cs | 18 +-- .../CSSLayoutBorderTest.cs | 20 +-- .../CSSLayoutFlexDirectionTest.cs | 50 +++--- .../CSSLayoutFlexTest.cs | 48 +++--- .../CSSLayoutFlexWrapTest.cs | 42 ++--- .../CSSLayoutJustifyContentTest.cs | 82 +++++----- .../CSSLayoutMarginTest.cs | 46 +++--- .../CSSLayoutMinMaxDimensionTest.cs | 50 +++--- .../CSSLayoutPaddingTest.cs | 24 +-- .../CSSLayoutRoundingTest.cs | 130 +++++++-------- .../YogaNodeCreateTest.cs} | 30 ++-- .../YogaNodeTest.cs} | 152 +++++++++--------- .../test_macos.sh | 6 +- enums.py | 4 +- gentest/gentest-cs.js | 10 +- gentest/gentest.rb | 4 +- 56 files changed, 506 insertions(+), 512 deletions(-) rename csharp/{Facebook.CSSLayout.sln => Facebook.Yoga.sln} (88%) rename csharp/{Facebook.CSSLayout/Facebook.CSSLayout.xproj => Facebook.Yoga/Facebook.Yoga.xproj} (95%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/MeasureFunction.cs (90%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/MeasureOutput.cs (96%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/Native.cs (96%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/Properties/AssemblyInfo.cs (96%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/Spacing.cs (96%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaAlign.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaConstants.cs (94%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaDimension.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaDirection.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaEdge.cs (94%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaExperimentalFeature.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaFlexDirection.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaJustify.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaLogLevel.cs (93%) rename csharp/{Facebook.CSSLayout/CSSLogger.cs => Facebook.Yoga/YogaLogger.cs} (90%) rename csharp/{Facebook.CSSLayout/CSSMeasureFunc.cs => Facebook.Yoga/YogaMeasureFunc.cs} (88%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaMeasureMode.cs (93%) rename csharp/{Facebook.CSSLayout/CSSNode.Create.cs => Facebook.Yoga/YogaNode.Create.cs} (84%) rename csharp/{Facebook.CSSLayout/CSSNode.cs => Facebook.Yoga/YogaNode.cs} (90%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaOverflow.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaPositionType.cs (93%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaPrintOptions.cs (93%) rename csharp/{Facebook.CSSLayout/CSSSize.cs => Facebook.Yoga/YogaSize.cs} (89%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/YogaWrap.cs (92%) rename csharp/{Facebook.CSSLayout => Facebook.Yoga}/project.json (100%) rename csharp/{CSSLayout/CSSInterop.cpp => Yoga/YGInterop.cpp} (83%) rename csharp/{CSSLayout/CSSInterop.h => Yoga/YGInterop.h} (72%) rename csharp/{CSSLayout/CSSLayout.vcxproj => Yoga/Yoga.vcxproj} (96%) rename csharp/{CSSLayout/CSSLayout.vcxproj.filters => Yoga/Yoga.vcxproj.filters} (95%) rename csharp/{CSSLayout => Yoga}/dllmain.cpp (100%) rename csharp/{CSSLayout => Yoga}/stdafx.cpp (91%) rename csharp/{CSSLayout => Yoga}/stdafx.h (100%) rename csharp/{CSSLayout => Yoga}/targetver.h (100%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutAbsolutePositionTest.cs (94%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutAlignContentTest.cs (92%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutAlignItemsTest.cs (93%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutAlignSelfTest.cs (93%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutBorderTest.cs (94%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutFlexDirectionTest.cs (92%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutFlexTest.cs (92%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutFlexWrapTest.cs (92%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutJustifyContentTest.cs (92%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutMarginTest.cs (93%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutMinMaxDimensionTest.cs (93%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutPaddingTest.cs (94%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/CSSLayoutRoundingTest.cs (87%) rename csharp/tests/{Facebook.CSSLayout/CSSNodeCreateTest.cs => Facebook.Yoga/YogaNodeCreateTest.cs} (89%) rename csharp/tests/{Facebook.CSSLayout/CSSNodeTest.cs => Facebook.Yoga/YogaNodeTest.cs} (65%) rename csharp/tests/{Facebook.CSSLayout => Facebook.Yoga}/test_macos.sh (80%) diff --git a/.travis.yml b/.travis.yml index 8e09e9ac..c1ad41cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: - buck test //:CSSLayout - buck test //java:java - buck test //YogaKit:YogaKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI - - sh csharp/tests/Facebook.CSSLayout/test_macos.sh + - sh csharp/tests/Facebook.Yoga/test_macos.sh - buck run //benchmark:benchmark - git checkout HEAD^ - buck run //benchmark:benchmark diff --git a/csharp/BUCK b/csharp/BUCK index 0e88d124..6219ab85 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -7,14 +7,14 @@ csharp_library( name = 'csslibnet46', - dll_name = 'Facebook.CSSLayout.dll', + dll_name = 'Facebook.Yoga.dll', framework_ver = 'net46', srcs = glob(['**/*.cs']), ) csharp_library( name = 'csslibnet45', - dll_name = 'Facebook.CSSLayout.dll', + dll_name = 'Facebook.Yoga.dll', framework_ver = 'net45', srcs = glob(['**/*.cs']), ) diff --git a/csharp/Facebook.CSSLayout.sln b/csharp/Facebook.Yoga.sln similarity index 88% rename from csharp/Facebook.CSSLayout.sln rename to csharp/Facebook.Yoga.sln index 5c67bda9..3e8b4078 100644 --- a/csharp/Facebook.CSSLayout.sln +++ b/csharp/Facebook.Yoga.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSSLayout", "CSSLayout\CSSLayout.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.CSSLayout", "Facebook.CSSLayout\Facebook.CSSLayout.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj b/csharp/Facebook.Yoga/Facebook.Yoga.xproj similarity index 95% rename from csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj rename to csharp/Facebook.Yoga/Facebook.Yoga.xproj index 2f3cd6f2..0341d153 100644 --- a/csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj +++ b/csharp/Facebook.Yoga/Facebook.Yoga.xproj @@ -8,7 +8,7 @@ 75bb7605-e54b-4ede-8f5a-ff1f24464236 - Facebook.CSSLayout + Facebook.Yoga .\obj .\bin\ v4.5.2 diff --git a/csharp/Facebook.CSSLayout/MeasureFunction.cs b/csharp/Facebook.Yoga/MeasureFunction.cs similarity index 90% rename from csharp/Facebook.CSSLayout/MeasureFunction.cs rename to csharp/Facebook.Yoga/MeasureFunction.cs index 3c8128e0..f25ec6da 100644 --- a/csharp/Facebook.CSSLayout/MeasureFunction.cs +++ b/csharp/Facebook.Yoga/MeasureFunction.cs @@ -7,10 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public delegate long MeasureFunction( - CSSNode node, + YogaNode node, float width, YogaMeasureMode widthMode, float height, diff --git a/csharp/Facebook.CSSLayout/MeasureOutput.cs b/csharp/Facebook.Yoga/MeasureOutput.cs similarity index 96% rename from csharp/Facebook.CSSLayout/MeasureOutput.cs rename to csharp/Facebook.Yoga/MeasureOutput.cs index 10d93a33..380b5b2c 100644 --- a/csharp/Facebook.CSSLayout/MeasureOutput.cs +++ b/csharp/Facebook.Yoga/MeasureOutput.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public class MeasureOutput { diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.Yoga/Native.cs similarity index 96% rename from csharp/Facebook.CSSLayout/Native.cs rename to csharp/Facebook.Yoga/Native.cs index 7e910732..b5120822 100644 --- a/csharp/Facebook.CSSLayout/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -10,19 +10,19 @@ using System; using System.Runtime.InteropServices; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { internal static class Native { #if UNITY_IOS && !UNITY_EDITOR private const string DllName = "__Internal"; #else - private const string DllName = "CSSLayout"; + private const string DllName = "yoga"; #endif [DllImport(DllName)] - public static extern void CSSInteropSetLogger( - [MarshalAs(UnmanagedType.FunctionPtr)] CSSLogger.Func func); + public static extern void YGInteropSetLogger( + [MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func); [DllImport(DllName)] public static extern IntPtr CSSNodeNew(); @@ -94,11 +94,11 @@ namespace Facebook.CSSLayout [DllImport(DllName)] public static extern void CSSNodeSetMeasureFunc( IntPtr node, - [MarshalAs(UnmanagedType.FunctionPtr)] CSSMeasureFunc measureFunc); + [MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.FunctionPtr)] - public static extern CSSMeasureFunc CSSNodeGetMeasureFunc(IntPtr node); + public static extern YogaMeasureFunc CSSNodeGetMeasureFunc(IntPtr node); [DllImport(DllName)] public static extern void CSSNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); diff --git a/csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs b/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs similarity index 96% rename from csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs rename to csharp/Facebook.Yoga/Properties/AssemblyInfo.cs index 95d38201..bc0b9929 100644 --- a/csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs +++ b/csharp/Facebook.Yoga/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ using System.Runtime.InteropServices; // associated with an assembly. [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Facebook, Inc.")] -[assembly: AssemblyProduct("Facebook.CSSLayout")] +[assembly: AssemblyProduct("Facebook.Yoga")] [assembly: AssemblyTrademark("Copyright (c) 2014-present, Facebook, Inc.")] // Setting ComVisible to false makes the types in this assembly not visible diff --git a/csharp/Facebook.CSSLayout/Spacing.cs b/csharp/Facebook.Yoga/Spacing.cs similarity index 96% rename from csharp/Facebook.CSSLayout/Spacing.cs rename to csharp/Facebook.Yoga/Spacing.cs index b3cee58c..c1c53c96 100644 --- a/csharp/Facebook.CSSLayout/Spacing.cs +++ b/csharp/Facebook.Yoga/Spacing.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public class Spacing { diff --git a/csharp/Facebook.CSSLayout/YogaAlign.cs b/csharp/Facebook.Yoga/YogaAlign.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaAlign.cs rename to csharp/Facebook.Yoga/YogaAlign.cs index 64932253..80835d73 100644 --- a/csharp/Facebook.CSSLayout/YogaAlign.cs +++ b/csharp/Facebook.Yoga/YogaAlign.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaAlign { diff --git a/csharp/Facebook.CSSLayout/YogaConstants.cs b/csharp/Facebook.Yoga/YogaConstants.cs similarity index 94% rename from csharp/Facebook.CSSLayout/YogaConstants.cs rename to csharp/Facebook.Yoga/YogaConstants.cs index b7fa3399..3e12aa14 100644 --- a/csharp/Facebook.CSSLayout/YogaConstants.cs +++ b/csharp/Facebook.Yoga/YogaConstants.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public static class YogaConstants { diff --git a/csharp/Facebook.CSSLayout/YogaDimension.cs b/csharp/Facebook.Yoga/YogaDimension.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaDimension.cs rename to csharp/Facebook.Yoga/YogaDimension.cs index dd167359..2b011c9d 100644 --- a/csharp/Facebook.CSSLayout/YogaDimension.cs +++ b/csharp/Facebook.Yoga/YogaDimension.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaDimension { diff --git a/csharp/Facebook.CSSLayout/YogaDirection.cs b/csharp/Facebook.Yoga/YogaDirection.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaDirection.cs rename to csharp/Facebook.Yoga/YogaDirection.cs index 4f1317b6..000e37a7 100644 --- a/csharp/Facebook.CSSLayout/YogaDirection.cs +++ b/csharp/Facebook.Yoga/YogaDirection.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaDirection { diff --git a/csharp/Facebook.CSSLayout/YogaEdge.cs b/csharp/Facebook.Yoga/YogaEdge.cs similarity index 94% rename from csharp/Facebook.CSSLayout/YogaEdge.cs rename to csharp/Facebook.Yoga/YogaEdge.cs index 15a7ef75..aaed3d30 100644 --- a/csharp/Facebook.CSSLayout/YogaEdge.cs +++ b/csharp/Facebook.Yoga/YogaEdge.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaEdge { diff --git a/csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs b/csharp/Facebook.Yoga/YogaExperimentalFeature.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs rename to csharp/Facebook.Yoga/YogaExperimentalFeature.cs index b5b09f3a..0f8156cb 100644 --- a/csharp/Facebook.CSSLayout/YogaExperimentalFeature.cs +++ b/csharp/Facebook.Yoga/YogaExperimentalFeature.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaExperimentalFeature { diff --git a/csharp/Facebook.CSSLayout/YogaFlexDirection.cs b/csharp/Facebook.Yoga/YogaFlexDirection.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaFlexDirection.cs rename to csharp/Facebook.Yoga/YogaFlexDirection.cs index d02eeaa9..385a2884 100644 --- a/csharp/Facebook.CSSLayout/YogaFlexDirection.cs +++ b/csharp/Facebook.Yoga/YogaFlexDirection.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaFlexDirection { diff --git a/csharp/Facebook.CSSLayout/YogaJustify.cs b/csharp/Facebook.Yoga/YogaJustify.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaJustify.cs rename to csharp/Facebook.Yoga/YogaJustify.cs index a8a3d3a1..9f1e9163 100644 --- a/csharp/Facebook.CSSLayout/YogaJustify.cs +++ b/csharp/Facebook.Yoga/YogaJustify.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaJustify { diff --git a/csharp/Facebook.CSSLayout/YogaLogLevel.cs b/csharp/Facebook.Yoga/YogaLogLevel.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaLogLevel.cs rename to csharp/Facebook.Yoga/YogaLogLevel.cs index 89fce541..ce41ba48 100644 --- a/csharp/Facebook.CSSLayout/YogaLogLevel.cs +++ b/csharp/Facebook.Yoga/YogaLogLevel.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaLogLevel { diff --git a/csharp/Facebook.CSSLayout/CSSLogger.cs b/csharp/Facebook.Yoga/YogaLogger.cs similarity index 90% rename from csharp/Facebook.CSSLayout/CSSLogger.cs rename to csharp/Facebook.Yoga/YogaLogger.cs index 16718deb..e5d79b79 100644 --- a/csharp/Facebook.CSSLayout/CSSLogger.cs +++ b/csharp/Facebook.Yoga/YogaLogger.cs @@ -10,9 +10,9 @@ using System; using System.Runtime.InteropServices; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { - internal static class CSSLogger + internal static class YogaLogger { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void Func(YogaLogLevel level, string message); @@ -37,7 +37,7 @@ namespace Facebook.CSSLayout throw new InvalidOperationException(message); } }; - Native.CSSInteropSetLogger(_managedLogger); + Native.YGInteropSetLogger(_managedLogger); _initialized = true; } } diff --git a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs b/csharp/Facebook.Yoga/YogaMeasureFunc.cs similarity index 88% rename from csharp/Facebook.CSSLayout/CSSMeasureFunc.cs rename to csharp/Facebook.Yoga/YogaMeasureFunc.cs index 6864c280..0474292a 100644 --- a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs +++ b/csharp/Facebook.Yoga/YogaMeasureFunc.cs @@ -10,10 +10,10 @@ using System; using System.Runtime.InteropServices; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate CSSSize CSSMeasureFunc( + public delegate YogaSize YogaMeasureFunc( IntPtr node, float width, YogaMeasureMode widthMode, diff --git a/csharp/Facebook.CSSLayout/YogaMeasureMode.cs b/csharp/Facebook.Yoga/YogaMeasureMode.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaMeasureMode.cs rename to csharp/Facebook.Yoga/YogaMeasureMode.cs index 28d837f3..f044b266 100644 --- a/csharp/Facebook.CSSLayout/YogaMeasureMode.cs +++ b/csharp/Facebook.Yoga/YogaMeasureMode.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaMeasureMode { diff --git a/csharp/Facebook.CSSLayout/CSSNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs similarity index 84% rename from csharp/Facebook.CSSLayout/CSSNode.Create.cs rename to csharp/Facebook.Yoga/YogaNode.Create.cs index 31a52c85..a7df02d0 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -9,11 +9,11 @@ using System; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { - public partial class CSSNode + public partial class YogaNode { - public static CSSNode Create( + public static YogaNode Create( YogaDirection? styleDirection = null, YogaFlexDirection? flexDirection = null, YogaJustify? justifyContent = null, @@ -31,15 +31,14 @@ namespace Facebook.CSSLayout Spacing margin = null, Spacing padding = null, Spacing border = null, - float? width = null, - float? height = null, - float? maxWidth = null, - float? maxHeight = null, - float? minWidth = null, - float? minHeight = null, - float? aspectRatio = null) + float? Width = null, + float? Height = null, + float? MaxWidth = null, + float? MaxHeight = null, + float? MinWidth = null, + float? MinHeight = null) { - CSSNode node = new CSSNode(); + YogaNode node = new YogaNode(); if (styleDirection.HasValue) { @@ -198,39 +197,34 @@ namespace Facebook.CSSLayout } } - if (width.HasValue) + if (Width.HasValue) { - node.Width = width.Value; + node.Width = Width.Value; } - if (height.HasValue) + if (Height.HasValue) { - node.Height = height.Value; + node.Height = Height.Value; } - if (minWidth.HasValue) + if (MinWidth.HasValue) { - node.MinWidth = minWidth.Value; + node.MinWidth = MinWidth.Value; } - if (minHeight.HasValue) + if (MinHeight.HasValue) { - node.MinHeight = minHeight.Value; + node.MinHeight = MinHeight.Value; } - if (maxWidth.HasValue) + if (MaxWidth.HasValue) { - node.MaxWidth = maxWidth.Value; + node.MaxWidth = MaxWidth.Value; } - if (maxHeight.HasValue) + if (MaxHeight.HasValue) { - node.MaxHeight = maxHeight.Value; - } - - if (aspectRatio.HasValue) - { - node.AspectRatio = aspectRatio.Value; + node.MaxHeight = MaxHeight.Value; } return node; diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.Yoga/YogaNode.cs similarity index 90% rename from csharp/Facebook.CSSLayout/CSSNode.cs rename to csharp/Facebook.Yoga/YogaNode.cs index 73694f6f..8d1b5a6b 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -13,20 +13,20 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { - public partial class CSSNode : IEnumerable + public partial class YogaNode : IEnumerable { private IntPtr _cssNode; private WeakReference _parent; - private List _children; + private List _children; private MeasureFunction _measureFunction; - private CSSMeasureFunc _cssMeasureFunc; + private YogaMeasureFunc _cssMeasureFunc; private object _data; - public CSSNode() + public YogaNode() { - CSSLogger.Initialize(); + YogaLogger.Initialize(); _cssNode = Native.CSSNodeNew(); if (_cssNode == IntPtr.Zero) @@ -35,7 +35,7 @@ namespace Facebook.CSSLayout } } - ~CSSNode() + ~YogaNode() { Native.CSSNodeFree(_cssNode); } @@ -74,11 +74,11 @@ namespace Facebook.CSSLayout Native.CSSNodeSetHasNewLayout(_cssNode, true); } - public CSSNode Parent + public YogaNode Parent { get { - return _parent != null ? _parent.Target as CSSNode : null; + return _parent != null ? _parent.Target as YogaNode : null; } } @@ -90,7 +90,7 @@ namespace Facebook.CSSLayout } } - public void CopyStyle(CSSNode srcNode) + public void CopyStyle(YogaNode srcNode) { Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode); } @@ -364,7 +364,7 @@ namespace Facebook.CSSLayout } } - public float AspectRatio + public float StyleAspectRatio { get { @@ -443,7 +443,7 @@ namespace Facebook.CSSLayout } } - public CSSNode this[int index] + public YogaNode this[int index] { get { @@ -474,11 +474,11 @@ namespace Facebook.CSSLayout return Math.Abs(f2 - f1) < float.Epsilon; } - public void Insert(int index, CSSNode node) + public void Insert(int index, YogaNode node) { if (_children == null) { - _children = new List(4); + _children = new List(4); } _children.Insert(index, node); node._parent = new WeakReference(this); @@ -504,7 +504,7 @@ namespace Facebook.CSSLayout } } - public int IndexOf(CSSNode node) + public int IndexOf(YogaNode node) { return _children != null ? _children.IndexOf(node) : -1; } @@ -512,7 +512,7 @@ namespace Facebook.CSSLayout public void SetMeasureFunction(MeasureFunction measureFunction) { _measureFunction = measureFunction; - _cssMeasureFunc = measureFunction != null ? MeasureInternal : (CSSMeasureFunc)null; + _cssMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null; Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc); } @@ -525,7 +525,7 @@ namespace Facebook.CSSLayout Native.CSSNodeStyleGetDirection(_cssNode)); } - private CSSSize MeasureInternal( + private YogaSize MeasureInternal( IntPtr node, float width, YogaMeasureMode widthMode, @@ -538,30 +538,30 @@ namespace Facebook.CSSLayout } long output = _measureFunction(this, width, widthMode, height, heightMode); - return new CSSSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) }; + return new YogaSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) }; } public string Print(YogaPrintOptions options = YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children) { StringBuilder sb = new StringBuilder(); - CSSLogger.Func orig = CSSLogger.Logger; - CSSLogger.Logger = (level, message) => {sb.Append(message);}; + YogaLogger.Func orig = YogaLogger.Logger; + YogaLogger.Logger = (level, message) => {sb.Append(message);}; Native.CSSNodePrint(_cssNode, options); - CSSLogger.Logger = orig; + YogaLogger.Logger = orig; return sb.ToString(); } - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() { - return _children != null ? ((IEnumerable)_children).GetEnumerator() : - System.Linq.Enumerable.Empty().GetEnumerator(); + return _children != null ? ((IEnumerable)_children).GetEnumerator() : + System.Linq.Enumerable.Empty().GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { - return _children != null ? ((IEnumerable)_children).GetEnumerator() : - System.Linq.Enumerable.Empty().GetEnumerator(); + return _children != null ? ((IEnumerable)_children).GetEnumerator() : + System.Linq.Enumerable.Empty().GetEnumerator(); } public static int GetInstanceCount() diff --git a/csharp/Facebook.CSSLayout/YogaOverflow.cs b/csharp/Facebook.Yoga/YogaOverflow.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaOverflow.cs rename to csharp/Facebook.Yoga/YogaOverflow.cs index 89bef500..29b2a5de 100644 --- a/csharp/Facebook.CSSLayout/YogaOverflow.cs +++ b/csharp/Facebook.Yoga/YogaOverflow.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaOverflow { diff --git a/csharp/Facebook.CSSLayout/YogaPositionType.cs b/csharp/Facebook.Yoga/YogaPositionType.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaPositionType.cs rename to csharp/Facebook.Yoga/YogaPositionType.cs index 7f76b6a3..8225b3f4 100644 --- a/csharp/Facebook.CSSLayout/YogaPositionType.cs +++ b/csharp/Facebook.Yoga/YogaPositionType.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaPositionType { diff --git a/csharp/Facebook.CSSLayout/YogaPrintOptions.cs b/csharp/Facebook.Yoga/YogaPrintOptions.cs similarity index 93% rename from csharp/Facebook.CSSLayout/YogaPrintOptions.cs rename to csharp/Facebook.Yoga/YogaPrintOptions.cs index a52f38e8..be3723f0 100644 --- a/csharp/Facebook.CSSLayout/YogaPrintOptions.cs +++ b/csharp/Facebook.Yoga/YogaPrintOptions.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaPrintOptions { diff --git a/csharp/Facebook.CSSLayout/CSSSize.cs b/csharp/Facebook.Yoga/YogaSize.cs similarity index 89% rename from csharp/Facebook.CSSLayout/CSSSize.cs rename to csharp/Facebook.Yoga/YogaSize.cs index 5fd3a291..d46f82fb 100644 --- a/csharp/Facebook.CSSLayout/CSSSize.cs +++ b/csharp/Facebook.Yoga/YogaSize.cs @@ -9,10 +9,10 @@ using System.Runtime.InteropServices; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [StructLayout(LayoutKind.Sequential)] - public struct CSSSize + public struct YogaSize { public float width; public float height; diff --git a/csharp/Facebook.CSSLayout/YogaWrap.cs b/csharp/Facebook.Yoga/YogaWrap.cs similarity index 92% rename from csharp/Facebook.CSSLayout/YogaWrap.cs rename to csharp/Facebook.Yoga/YogaWrap.cs index df6d30bb..3d88ad04 100644 --- a/csharp/Facebook.CSSLayout/YogaWrap.cs +++ b/csharp/Facebook.Yoga/YogaWrap.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { public enum YogaWrap { diff --git a/csharp/Facebook.CSSLayout/project.json b/csharp/Facebook.Yoga/project.json similarity index 100% rename from csharp/Facebook.CSSLayout/project.json rename to csharp/Facebook.Yoga/project.json diff --git a/csharp/CSSLayout/CSSInterop.cpp b/csharp/Yoga/YGInterop.cpp similarity index 83% rename from csharp/CSSLayout/CSSInterop.cpp rename to csharp/Yoga/YGInterop.cpp index 7995cab2..04c849cd 100644 --- a/csharp/CSSLayout/CSSInterop.cpp +++ b/csharp/Yoga/YGInterop.cpp @@ -7,9 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include "CSSInterop.h" +#include "YGInterop.h" -static CSSInteropLoggerFunc gManagedFunc; +static YGInteropLoggerFunc gManagedFunc; static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { int result = 0; @@ -21,7 +21,7 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) { return result; } -void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc) { +void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) { gManagedFunc = managedFunc; CSSLayoutSetLogger(&unmanagedLogger); } diff --git a/csharp/CSSLayout/CSSInterop.h b/csharp/Yoga/YGInterop.h similarity index 72% rename from csharp/CSSLayout/CSSInterop.h rename to csharp/Yoga/YGInterop.h index daa82247..546bf46b 100644 --- a/csharp/CSSLayout/CSSInterop.h +++ b/csharp/Yoga/YGInterop.h @@ -13,8 +13,8 @@ CSS_EXTERN_C_BEGIN -typedef void (*CSSInteropLoggerFunc)(YGLogLevel level, const char *message); +typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message); -WIN_EXPORT void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc); +WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc); CSS_EXTERN_C_END diff --git a/csharp/CSSLayout/CSSLayout.vcxproj b/csharp/Yoga/Yoga.vcxproj similarity index 96% rename from csharp/CSSLayout/CSSLayout.vcxproj rename to csharp/Yoga/Yoga.vcxproj index 199eb3e8..b6029218 100755 --- a/csharp/CSSLayout/CSSLayout.vcxproj +++ b/csharp/Yoga/Yoga.vcxproj @@ -21,7 +21,7 @@ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5} Win32Proj - CSSLayout + Yoga 10.0.14393.0 @@ -153,14 +153,14 @@ - + - + false @@ -180,4 +180,4 @@ - \ No newline at end of file + diff --git a/csharp/CSSLayout/CSSLayout.vcxproj.filters b/csharp/Yoga/Yoga.vcxproj.filters similarity index 95% rename from csharp/CSSLayout/CSSLayout.vcxproj.filters rename to csharp/Yoga/Yoga.vcxproj.filters index 07197766..65c4b19c 100755 --- a/csharp/CSSLayout/CSSLayout.vcxproj.filters +++ b/csharp/Yoga/Yoga.vcxproj.filters @@ -30,7 +30,7 @@ Header Files - + Header Files @@ -47,8 +47,8 @@ Source Files - + Source Files - \ No newline at end of file + diff --git a/csharp/CSSLayout/dllmain.cpp b/csharp/Yoga/dllmain.cpp similarity index 100% rename from csharp/CSSLayout/dllmain.cpp rename to csharp/Yoga/dllmain.cpp diff --git a/csharp/CSSLayout/stdafx.cpp b/csharp/Yoga/stdafx.cpp similarity index 91% rename from csharp/CSSLayout/stdafx.cpp rename to csharp/Yoga/stdafx.cpp index 53e7c346..cdee8426 100644 --- a/csharp/CSSLayout/stdafx.cpp +++ b/csharp/Yoga/stdafx.cpp @@ -8,7 +8,7 @@ */ // stdafx.cpp : source file that includes just the standard includes -// CSSLayout.pch will be the pre-compiled header +// Yoga.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" diff --git a/csharp/CSSLayout/stdafx.h b/csharp/Yoga/stdafx.h similarity index 100% rename from csharp/CSSLayout/stdafx.h rename to csharp/Yoga/stdafx.h diff --git a/csharp/CSSLayout/targetver.h b/csharp/Yoga/targetver.h similarity index 100% rename from csharp/CSSLayout/targetver.h rename to csharp/Yoga/targetver.h diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs similarity index 94% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs index d058942c..ba377250 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutAbsolutePositionTest @@ -20,11 +20,11 @@ namespace Facebook.CSSLayout [Test] public void Test_absolute_layout_width_height_start_top() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Top, 10f); @@ -61,11 +61,11 @@ namespace Facebook.CSSLayout [Test] public void Test_absolute_layout_width_height_end_bottom() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.End, 10f); root_child0.SetPosition(YogaEdge.Bottom, 10f); @@ -102,11 +102,11 @@ namespace Facebook.CSSLayout [Test] public void Test_absolute_layout_start_top_end_bottom() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Top, 10f); @@ -143,11 +143,11 @@ namespace Facebook.CSSLayout [Test] public void Test_absolute_layout_width_height_start_top_end_bottom() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Top, 10f); @@ -186,19 +186,19 @@ namespace Facebook.CSSLayout [Test] public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Overflow = YogaOverflow.Hidden; root.Width = 50f; root.Height = 50f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Start, 0f); root_child0.SetPosition(YogaEdge.Top, 0f); root.Insert(0, root_child0); - CSSNode root_child0_child0 = new CSSNode(); + YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.Width = 100f; root_child0_child0.Height = 100f; root_child0.Insert(0, root_child0_child0); @@ -242,7 +242,7 @@ namespace Facebook.CSSLayout [Test] public void Test_absolute_layout_within_border() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetMargin(YogaEdge.Left, 10f); root.SetMargin(YogaEdge.Top, 10f); root.SetMargin(YogaEdge.Right, 10f); @@ -258,7 +258,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.PositionType = YogaPositionType.Absolute; root_child0.SetPosition(YogaEdge.Left, 0f); root_child0.SetPosition(YogaEdge.Top, 0f); @@ -266,7 +266,7 @@ namespace Facebook.CSSLayout root_child0.Height = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.PositionType = YogaPositionType.Absolute; root_child1.SetPosition(YogaEdge.Right, 0f); root_child1.SetPosition(YogaEdge.Bottom, 0f); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs similarity index 92% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs index c17d2b0a..2fd26b95 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutAlignContentTest @@ -20,32 +20,32 @@ namespace Facebook.CSSLayout [Test] public void Test_align_content_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 50f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root_child2.Height = 10f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 50f; root_child3.Height = 10f; root.Insert(3, root_child3); - CSSNode root_child4 = new CSSNode(); + YogaNode root_child4 = new YogaNode(); root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); @@ -119,33 +119,33 @@ namespace Facebook.CSSLayout [Test] public void Test_align_content_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 50f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root_child2.Height = 10f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 50f; root_child3.Height = 10f; root.Insert(3, root_child3); - CSSNode root_child4 = new CSSNode(); + YogaNode root_child4 = new YogaNode(); root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); @@ -219,33 +219,33 @@ namespace Facebook.CSSLayout [Test] public void Test_align_content_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 50f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root_child2.Height = 10f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 50f; root_child3.Height = 10f; root.Insert(3, root_child3); - CSSNode root_child4 = new CSSNode(); + YogaNode root_child4 = new YogaNode(); root_child4.Width = 50f; root_child4.Height = 10f; root.Insert(4, root_child4); @@ -319,29 +319,29 @@ namespace Facebook.CSSLayout [Test] public void Test_align_content_stretch() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignContent = YogaAlign.Stretch; root.Wrap = YogaWrap.Wrap; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 50f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 50f; root.Insert(3, root_child3); - CSSNode root_child4 = new CSSNode(); + YogaNode root_child4 = new YogaNode(); root_child4.Width = 50f; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs similarity index 93% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs index cf2ac0ed..54101754 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutAlignItemsTest @@ -20,11 +20,11 @@ namespace Facebook.CSSLayout [Test] public void Test_align_items_stretch() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -57,12 +57,12 @@ namespace Facebook.CSSLayout [Test] public void Test_align_items_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -96,12 +96,12 @@ namespace Facebook.CSSLayout [Test] public void Test_align_items_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -135,12 +135,12 @@ namespace Facebook.CSSLayout [Test] public void Test_align_items_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexEnd; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs similarity index 93% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs index c7fdc958..00a8246f 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutAlignSelfTest @@ -20,11 +20,11 @@ namespace Facebook.CSSLayout [Test] public void Test_align_self_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.Center; root_child0.Width = 10f; root_child0.Height = 10f; @@ -59,11 +59,11 @@ namespace Facebook.CSSLayout [Test] public void Test_align_self_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10f; root_child0.Height = 10f; @@ -98,11 +98,11 @@ namespace Facebook.CSSLayout [Test] public void Test_align_self_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexStart; root_child0.Width = 10f; root_child0.Height = 10f; @@ -137,12 +137,12 @@ namespace Facebook.CSSLayout [Test] public void Test_align_self_flex_end_override_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.FlexStart; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.Width = 10f; root_child0.Height = 10f; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs similarity index 94% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs index fab4b731..1182b777 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutBorderTest @@ -20,7 +20,7 @@ namespace Facebook.CSSLayout [Test] public void Test_border_no_size() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Right, 10f); @@ -45,13 +45,13 @@ namespace Facebook.CSSLayout [Test] public void Test_border_container_match_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Bottom, 10f); - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout [Test] public void Test_border_flex_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Right, 10f); @@ -93,7 +93,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.Width = 10f; root.Insert(0, root_child0); @@ -127,7 +127,7 @@ namespace Facebook.CSSLayout [Test] public void Test_border_stretch_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Right, 10f); @@ -135,7 +135,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -168,7 +168,7 @@ namespace Facebook.CSSLayout [Test] public void Test_border_center_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.SetBorder(YogaEdge.Start, 10f); @@ -177,7 +177,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs similarity index 92% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs index 81d639b0..abd749b7 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutFlexDirectionTest @@ -20,18 +20,18 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_column_no_height() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -84,19 +84,19 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_row_no_width() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -149,19 +149,19 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -214,20 +214,20 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -280,20 +280,20 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_column_reverse() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.ColumnReverse; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -346,20 +346,20 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_direction_row_reverse() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.RowReverse; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs similarity index 92% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs index 995eec52..69ee52a1 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutFlexTest @@ -20,16 +20,16 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_basis_flex_grow_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -72,17 +72,17 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_basis_flex_grow_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -125,16 +125,16 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_basis_flex_shrink_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1f; root_child0.FlexBasis = 100f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexBasis = 50f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -177,17 +177,17 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_basis_flex_shrink_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1f; root_child0.FlexBasis = 100f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexBasis = 50f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -230,21 +230,21 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_shrink_to_zero() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Height = 75f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root_child0.Height = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexShrink = 1f; root_child1.Width = 50f; root_child1.Height = 50f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root_child2.Height = 50f; root.Insert(2, root_child2); @@ -298,22 +298,22 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_basis_overrides_main_size() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -367,14 +367,14 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_grow_shrink_at_most() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root.Insert(0, root_child0); - CSSNode root_child0_child0 = new CSSNode(); + YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexShrink = 1f; root_child0.Insert(0, root_child0_child0); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs similarity index 92% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs index 7ea50ec3..bf8c4ac8 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutFlexWrapTest @@ -20,26 +20,26 @@ namespace Facebook.CSSLayout [Test] public void Test_wrap_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Wrap = YogaWrap.Wrap; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 30f; root_child0.Height = 30f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 30f; root_child1.Height = 30f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 30f; root_child2.Height = 30f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); @@ -103,27 +103,27 @@ namespace Facebook.CSSLayout [Test] public void Test_wrap_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Wrap = YogaWrap.Wrap; root.Width = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 30f; root_child0.Height = 30f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 30f; root_child1.Height = 30f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 30f; root_child2.Height = 30f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); @@ -187,28 +187,28 @@ namespace Facebook.CSSLayout [Test] public void Test_wrap_row_align_items_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.FlexEnd; root.Wrap = YogaWrap.Wrap; root.Width = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 30f; root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 30f; root_child1.Height = 20f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 30f; root_child2.Height = 30f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); @@ -272,28 +272,28 @@ namespace Facebook.CSSLayout [Test] public void Test_wrap_row_align_items_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.AlignItems = YogaAlign.Center; root.Wrap = YogaWrap.Wrap; root.Width = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 30f; root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 30f; root_child1.Height = 20f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 30f; root_child2.Height = 30f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.Width = 30f; root_child3.Height = 30f; root.Insert(3, root_child3); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs similarity index 92% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs index 1a2a3ea7..86d8d50f 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutJustifyContentTest @@ -20,20 +20,20 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_row_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -86,21 +86,21 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_row_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -153,21 +153,21 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_row_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.Center; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -220,21 +220,21 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_row_space_between() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -287,21 +287,21 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_row_space_around() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -354,18 +354,18 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_column_flex_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -418,20 +418,20 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_column_flex_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -484,20 +484,20 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_column_center() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -550,20 +550,20 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_column_space_between() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceBetween; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -616,20 +616,20 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_column_space_around() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.SpaceAround; root.Width = 102f; root.Height = 102f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Height = 10f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs similarity index 93% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs index e6030df8..c2eb8123 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutMarginTest @@ -20,12 +20,12 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_start() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.SetMargin(YogaEdge.Start, 10f); root_child0.Width = 10f; root.Insert(0, root_child0); @@ -59,11 +59,11 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_top() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.SetMargin(YogaEdge.Top, 10f); root_child0.Height = 10f; root.Insert(0, root_child0); @@ -97,13 +97,13 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.SetMargin(YogaEdge.End, 10f); root_child0.Width = 10f; root.Insert(0, root_child0); @@ -137,12 +137,12 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_bottom() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.SetMargin(YogaEdge.Bottom, 10f); root_child0.Height = 10f; root.Insert(0, root_child0); @@ -176,12 +176,12 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_and_flex_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.SetMargin(YogaEdge.Start, 10f); root.Insert(0, root_child0); @@ -215,11 +215,11 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_and_flex_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.SetMargin(YogaEdge.Top, 10f); root.Insert(0, root_child0); @@ -253,12 +253,12 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_and_stretch_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.SetMargin(YogaEdge.Top, 10f); root.Insert(0, root_child0); @@ -292,11 +292,11 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_and_stretch_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.SetMargin(YogaEdge.Start, 10f); root.Insert(0, root_child0); @@ -330,16 +330,16 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_with_sibling_row() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -382,15 +382,15 @@ namespace Facebook.CSSLayout [Test] public void Test_margin_with_sibling_column() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs similarity index 93% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs index dcfa7f1a..6d8b7ba9 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutMinMaxDimensionTest @@ -20,11 +20,11 @@ namespace Facebook.CSSLayout [Test] public void Test_max_width() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.MaxWidth = 50f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -58,12 +58,12 @@ namespace Facebook.CSSLayout [Test] public void Test_max_height() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.MaxHeight = 50f; root.Insert(0, root_child0); @@ -97,16 +97,16 @@ namespace Facebook.CSSLayout [Test] public void Test_min_height() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.MinHeight = 60f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -149,17 +149,17 @@ namespace Facebook.CSSLayout [Test] public void Test_min_width() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.MinWidth = 60f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); root.StyleDirection = YogaDirection.LTR; @@ -202,13 +202,13 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_min_max() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.Width = 100f; root.MinHeight = 100f; root.MaxHeight = 200f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 60f; root_child0.Height = 60f; root.Insert(0, root_child0); @@ -242,13 +242,13 @@ namespace Facebook.CSSLayout [Test] public void Test_align_items_min_max() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.AlignItems = YogaAlign.Center; root.MinWidth = 100f; root.MaxWidth = 200f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 60f; root_child0.Height = 60f; root.Insert(0, root_child0); @@ -282,22 +282,22 @@ namespace Facebook.CSSLayout [Test] public void Test_justify_content_overflow_min_max() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.MinHeight = 100f; root.MaxHeight = 110f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 50f; root_child0.Height = 50f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.Width = 50f; root_child1.Height = 50f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.Width = 50f; root_child2.Height = 50f; root.Insert(2, root_child2); @@ -351,16 +351,16 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_grow_within_max_width() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 200f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 100f; root.Insert(0, root_child0); - CSSNode root_child0_child0 = new CSSNode(); + YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); @@ -404,16 +404,16 @@ namespace Facebook.CSSLayout [Test] public void Test_flex_grow_within_constrained_max_width() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 200f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.MaxWidth = 300f; root.Insert(0, root_child0); - CSSNode root_child0_child0 = new CSSNode(); + YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.Height = 20f; root_child0.Insert(0, root_child0_child0); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs similarity index 94% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs index c9ec0ae6..47f04155 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutPaddingTest @@ -20,7 +20,7 @@ namespace Facebook.CSSLayout [Test] public void Test_padding_no_size() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Right, 10f); @@ -45,13 +45,13 @@ namespace Facebook.CSSLayout [Test] public void Test_padding_container_match_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Bottom, 10f); - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -85,7 +85,7 @@ namespace Facebook.CSSLayout [Test] public void Test_padding_flex_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Right, 10f); @@ -93,7 +93,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.Width = 10f; root.Insert(0, root_child0); @@ -127,7 +127,7 @@ namespace Facebook.CSSLayout [Test] public void Test_padding_stretch_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Right, 10f); @@ -135,7 +135,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Height = 10f; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -168,7 +168,7 @@ namespace Facebook.CSSLayout [Test] public void Test_padding_center_child() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; root.SetPadding(YogaEdge.Start, 10f); @@ -177,7 +177,7 @@ namespace Facebook.CSSLayout root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.Width = 10f; root_child0.Height = 10f; root.Insert(0, root_child0); @@ -211,13 +211,13 @@ namespace Facebook.CSSLayout [Test] public void Test_child_with_padding_align_end() { - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.JustifyContent = YogaJustify.FlexEnd; root.AlignItems = YogaAlign.FlexEnd; root.Width = 200f; root.Height = 200f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.SetPadding(YogaEdge.Left, 20f); root_child0.SetPadding(YogaEdge.Top, 20f); root_child0.SetPadding(YogaEdge.Right, 20f); diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs b/csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs similarity index 87% rename from csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs rename to csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs index 36b255de..570b00be 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs @@ -12,7 +12,7 @@ using System; using NUnit.Framework; -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] public class CSSLayoutRoundingTest @@ -20,22 +20,22 @@ namespace Facebook.CSSLayout [Test] public void Test_rounding_flex_basis_flex_grow_row_width_of_100() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 100f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -84,36 +84,36 @@ namespace Facebook.CSSLayout Assert.AreEqual(33f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_grow_row_prime_number_width() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 113f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root.Insert(2, root_child2); - CSSNode root_child3 = new CSSNode(); + YogaNode root_child3 = new YogaNode(); root_child3.FlexGrow = 1f; root.Insert(3, root_child3); - CSSNode root_child4 = new CSSNode(); + YogaNode root_child4 = new YogaNode(); root_child4.FlexGrow = 1f; root.Insert(4, root_child4); root.StyleDirection = YogaDirection.LTR; @@ -182,29 +182,29 @@ namespace Facebook.CSSLayout Assert.AreEqual(23f, root_child4.LayoutWidth); Assert.AreEqual(100f, root_child4.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_flex_shrink_row() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.FlexDirection = YogaFlexDirection.Row; root.Width = 101f; root.Height = 100f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexShrink = 1f; root_child0.FlexBasis = 100f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexBasis = 25f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexBasis = 25f; root.Insert(2, root_child2); root.StyleDirection = YogaDirection.LTR; @@ -253,30 +253,30 @@ namespace Facebook.CSSLayout Assert.AreEqual(25f, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_flex_basis_overrides_main_size() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 113f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -326,30 +326,30 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 87.4f; root.Height = 113.4f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; root_child0.Height = 20.3f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); @@ -399,44 +399,44 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_total_fractial_nested() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 87.4f; root.Height = 113.4f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 0.7f; root_child0.FlexBasis = 50.3f; root_child0.Height = 20.3f; root.Insert(0, root_child0); - CSSNode root_child0_child0 = new CSSNode(); + YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexBasis = 0.3f; root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f); root_child0_child0.Height = 9.9f; root_child0.Insert(0, root_child0_child0); - CSSNode root_child0_child1 = new CSSNode(); + YogaNode root_child0_child1 = new YogaNode(); root_child0_child1.FlexGrow = 4f; root_child0_child1.FlexBasis = 0.3f; root_child0_child1.SetPosition(YogaEdge.Top, 13.3f); root_child0_child1.Height = 1.1f; root_child0.Insert(1, root_child0_child1); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1.6f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1.1f; root_child2.Height = 10.7f; root.Insert(2, root_child2); @@ -506,30 +506,30 @@ namespace Facebook.CSSLayout Assert.AreEqual(87f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_1() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 113.4f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -579,30 +579,30 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_2() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.Width = 100f; root.Height = 113.6f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -652,31 +652,31 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(25f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_3() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPosition(YogaEdge.Top, 0.3f); root.Width = 100f; root.Height = 113.4f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -726,31 +726,31 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } [Test] public void Test_rounding_fractial_input_4() { - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); - CSSNode root = new CSSNode(); + YogaNode root = new YogaNode(); root.SetPosition(YogaEdge.Top, 0.7f); root.Width = 100f; root.Height = 113.4f; - CSSNode root_child0 = new CSSNode(); + YogaNode root_child0 = new YogaNode(); root_child0.FlexGrow = 1f; root_child0.FlexBasis = 50f; root_child0.Height = 20f; root.Insert(0, root_child0); - CSSNode root_child1 = new CSSNode(); + YogaNode root_child1 = new YogaNode(); root_child1.FlexGrow = 1f; root_child1.Height = 10f; root.Insert(1, root_child1); - CSSNode root_child2 = new CSSNode(); + YogaNode root_child2 = new YogaNode(); root_child2.FlexGrow = 1f; root_child2.Height = 10f; root.Insert(2, root_child2); @@ -800,7 +800,7 @@ namespace Facebook.CSSLayout Assert.AreEqual(100f, root_child2.LayoutWidth); Assert.AreEqual(24f, root_child2.LayoutHeight); - CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); + YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false); } } diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs similarity index 89% rename from csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs rename to csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs index e2e8363d..d7cd8d8e 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs @@ -11,18 +11,18 @@ using NUnit.Framework; using System; /** - * Tests for {@link CSSNode}. + * Tests for {@link YogaNode}. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] - public class CSSNodeCreateTest + public class YogaNodeCreateTest { [Test] public void TestSimple() { - CSSNode nodeDefault = new CSSNode(); - CSSNode nodeCreated = CSSNode.Create(flexDirection: YogaFlexDirection.Row); + YogaNode nodeDefault = new YogaNode(); + YogaNode nodeCreated = YogaNode.Create(flexDirection: YogaFlexDirection.Row); Assert.AreEqual(YogaFlexDirection.Row, nodeCreated.FlexDirection); Assert.IsFalse(nodeDefault.IsDirty); nodeDefault.CopyStyle(nodeCreated); @@ -32,8 +32,8 @@ namespace Facebook.CSSLayout [Test] public void TestSame() { - CSSNode nodeDefault = new CSSNode(); - CSSNode nodeCreated = CSSNode.Create(); + YogaNode nodeDefault = new YogaNode(); + YogaNode nodeCreated = YogaNode.Create(); Assert.IsFalse(nodeDefault.IsDirty); nodeDefault.CopyStyle(nodeCreated); Assert.IsFalse(nodeDefault.IsDirty); @@ -42,7 +42,7 @@ namespace Facebook.CSSLayout [Test] public void TestMultiple() { - CSSNode node = CSSNode.Create( + YogaNode node = YogaNode.Create( positionType: YogaPositionType.Absolute, wrap: YogaWrap.Wrap, position: new Spacing(top:6, right:4), @@ -64,7 +64,7 @@ namespace Facebook.CSSLayout [Test] public void TestFull() { - CSSNode node = CSSNode.Create( + YogaNode node = YogaNode.Create( styleDirection: YogaDirection.RTL, flexDirection: YogaFlexDirection.RowReverse, @@ -87,12 +87,12 @@ namespace Facebook.CSSLayout padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), - width: 21, - height: 22, - minWidth: 23, - minHeight: 24, - maxWidth: 25, - maxHeight: 26); + Width: 21, + Height: 22, + MinWidth: 23, + MinHeight: 24, + MaxWidth: 25, + MaxHeight: 26); Assert.AreEqual(YogaDirection.RTL, node.StyleDirection); Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection); diff --git a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs similarity index 65% rename from csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs rename to csharp/tests/Facebook.Yoga/YogaNodeTest.cs index 42e83d39..5cf1002b 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -11,18 +11,18 @@ using NUnit.Framework; using System; /** - * Tests for {@link CSSNode}. + * Tests for {@link YogaNode}. */ -namespace Facebook.CSSLayout +namespace Facebook.Yoga { [TestFixture] - public class CSSNodeTest + public class YogaNodeTest { [Test] public void TestAddChildGetParent() { - CSSNode parent = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); Assert.IsNull(child.Parent); Assert.AreEqual(0, parent.Count); @@ -42,22 +42,22 @@ namespace Facebook.CSSLayout [Test] public void TestChildren() { - CSSNode parent = new CSSNode(); - foreach (CSSNode node in parent) { + YogaNode parent = new YogaNode(); + foreach (YogaNode node in parent) { Assert.Fail(node.ToString()); } - CSSNode child0 = new CSSNode(); + YogaNode child0 = new YogaNode(); Assert.AreEqual(-1, parent.IndexOf(child0)); parent.Insert(0, child0); - foreach (CSSNode node in parent) { + foreach (YogaNode node in parent) { Assert.AreEqual(0, parent.IndexOf(node)); } - CSSNode child1 = new CSSNode(); + YogaNode child1 = new YogaNode(); parent.Insert(1, child1); int index = 0; - foreach (CSSNode node in parent) { + foreach (YogaNode node in parent) { Assert.AreEqual(index++, parent.IndexOf(node)); } @@ -76,7 +76,7 @@ namespace Facebook.CSSLayout [ExpectedException("System.NullReferenceException")] public void TestRemoveAtFromEmpty() { - CSSNode parent = new CSSNode(); + YogaNode parent = new YogaNode(); parent.RemoveAt(0); } @@ -84,8 +84,8 @@ namespace Facebook.CSSLayout [ExpectedException("System.ArgumentOutOfRangeException")] public void TestRemoveAtOutOfRange() { - CSSNode parent = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); parent.Insert(0, child); parent.RemoveAt(1); } @@ -94,9 +94,9 @@ namespace Facebook.CSSLayout [ExpectedException("System.InvalidOperationException")] public void TestCannotAddChildToMultipleParents() { - CSSNode parent1 = new CSSNode(); - CSSNode parent2 = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode parent1 = new YogaNode(); + YogaNode parent2 = new YogaNode(); + YogaNode child = new YogaNode(); parent1.Insert(0, child); parent2.Insert(0, child); @@ -105,19 +105,19 @@ namespace Facebook.CSSLayout [Test] public void TestReset() { - int instanceCount = CSSNode.GetInstanceCount(); - CSSNode node = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); node.Reset(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); } [Test] [ExpectedException("System.InvalidOperationException")] public void TestResetParent() { - CSSNode parent = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); parent.Insert(0, child); parent.Reset(); } @@ -126,8 +126,8 @@ namespace Facebook.CSSLayout [ExpectedException("System.InvalidOperationException")] public void TestResetChild() { - CSSNode parent = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); parent.Insert(0, child); child.Reset(); } @@ -135,24 +135,24 @@ namespace Facebook.CSSLayout [Test] public void TestClear() { - int instanceCount = CSSNode.GetInstanceCount(); - CSSNode parent = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); - CSSNode child = new CSSNode(); - Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount()); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); parent.Insert(0, child); Assert.AreEqual(1, parent.Count); Assert.AreEqual(parent, child.Parent); parent.Clear(); Assert.AreEqual(0, parent.Count); Assert.IsNull(child.Parent); - Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); } [Test] public void TestMeasureFunc() { - CSSNode node = new CSSNode(); + YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return MeasureOutput.Make(100, 150); }); @@ -164,7 +164,7 @@ namespace Facebook.CSSLayout [Test] public void TestMeasureFuncWithFloat() { - CSSNode node = new CSSNode(); + YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return MeasureOutput.Make(123.4f, 81.7f); }); @@ -177,11 +177,11 @@ namespace Facebook.CSSLayout [ExpectedException("System.InvalidOperationException")] public void TestChildWithMeasureFunc() { - CSSNode node = new CSSNode(); + YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return MeasureOutput.Make(100, 150); }); - CSSNode child = new CSSNode(); + YogaNode child = new YogaNode(); node.Insert(0, child); } @@ -189,8 +189,8 @@ namespace Facebook.CSSLayout [ExpectedException("System.InvalidOperationException")] public void TestMeasureFuncWithChild() { - CSSNode node = new CSSNode(); - CSSNode child = new CSSNode(); + YogaNode node = new YogaNode(); + YogaNode child = new YogaNode(); node.Insert(0, child); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return MeasureOutput.Make(100, 150); @@ -200,13 +200,13 @@ namespace Facebook.CSSLayout [Test] public void TestPrint() { - CSSNode parent = new CSSNode(); + YogaNode parent = new YogaNode(); parent.Width = 100; parent.Height = 120; - CSSNode child0 = new CSSNode(); + YogaNode child0 = new YogaNode(); child0.Width = 30; child0.Height = 40; - CSSNode child1 = new CSSNode(); + YogaNode child1 = new YogaNode(); child1.Width = 35; child1.Height = 45; parent.Insert(0, child0); @@ -218,10 +218,10 @@ namespace Facebook.CSSLayout [Test] public void TestCopyStyle() { - CSSNode node0 = new CSSNode(); + YogaNode node0 = new YogaNode(); Assert.IsTrue(YogaConstants.IsUndefined(node0.MaxHeight)); - CSSNode node1 = new CSSNode(); + YogaNode node1 = new YogaNode(); node1.MaxHeight = 100; node0.CopyStyle(node1); @@ -239,17 +239,17 @@ namespace Facebook.CSSLayout public void TestDestructor() { ForceGC(); - int instanceCount = CSSNode.GetInstanceCount(); + int instanceCount = YogaNode.GetInstanceCount(); TestDestructorForGC(instanceCount); ForceGC(); - Assert.AreEqual(instanceCount, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount()); } private void TestDestructorForGC(int instanceCount) { - CSSNode node = new CSSNode(); + YogaNode node = new YogaNode(); Assert.IsNotNull(node); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); node = null; } @@ -257,32 +257,32 @@ namespace Facebook.CSSLayout public void TestDestructorWithChildren() { ForceGC(); - int instanceCount = CSSNode.GetInstanceCount(); + int instanceCount = YogaNode.GetInstanceCount(); TestDestructorWithChildrenForGC1(instanceCount); ForceGC(); - Assert.AreEqual(instanceCount, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount()); } private void TestDestructorWithChildrenForGC1(int instanceCount) { - CSSNode node = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); TestDestructorWithChildrenForGC2(node, instanceCount + 1); ForceGC(); - Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); TestDestructorWithChildrenForGC2(node, instanceCount + 2); ForceGC(); - Assert.AreEqual(instanceCount + 3, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 3, YogaNode.GetInstanceCount()); node = null; } - private void TestDestructorWithChildrenForGC2(CSSNode parent, int instanceCount) + private void TestDestructorWithChildrenForGC2(YogaNode parent, int instanceCount) { - CSSNode child = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); parent.Insert(0, child); child = null; @@ -292,21 +292,21 @@ namespace Facebook.CSSLayout public void TestParentDestructor() { ForceGC(); - int instanceCount = CSSNode.GetInstanceCount(); - CSSNode child = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); TestParentDestructorForGC(child, instanceCount + 1); ForceGC(); Assert.IsNull(child.Parent); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); } - private void TestParentDestructorForGC(CSSNode child, int instanceCount) + private void TestParentDestructorForGC(YogaNode child, int instanceCount) { - CSSNode parent = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); parent.Insert(0, child); } @@ -314,22 +314,22 @@ namespace Facebook.CSSLayout public void TestClearWithChildDestructor() { ForceGC(); - int instanceCount = CSSNode.GetInstanceCount(); - CSSNode node = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); TestClearWithChildDestructorForGC(node, instanceCount + 1); ForceGC(); - Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); node.Clear(); Assert.AreEqual(0, node.Count); ForceGC(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); } - private void TestClearWithChildDestructorForGC(CSSNode parent, int instanceCount) + private void TestClearWithChildDestructorForGC(YogaNode parent, int instanceCount) { - CSSNode child = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); parent.Insert(0, child); } @@ -337,20 +337,20 @@ namespace Facebook.CSSLayout public void TestMeasureFuncWithDestructor() { ForceGC(); - int instanceCount = CSSNode.GetInstanceCount(); - CSSNode parent = new CSSNode(); - Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount()); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); TestMeasureFuncWithDestructorForGC(parent); ForceGC(); - Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount()); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); parent.CalculateLayout(); Assert.AreEqual(120, (int)parent.LayoutWidth); Assert.AreEqual(130, (int)parent.LayoutHeight); } - private void TestMeasureFuncWithDestructorForGC(CSSNode parent) + private void TestMeasureFuncWithDestructorForGC(YogaNode parent) { - CSSNode child = new CSSNode(); + YogaNode child = new YogaNode(); parent.Insert(0, child); child.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return MeasureOutput.Make(120, 130); diff --git a/csharp/tests/Facebook.CSSLayout/test_macos.sh b/csharp/tests/Facebook.Yoga/test_macos.sh similarity index 80% rename from csharp/tests/Facebook.CSSLayout/test_macos.sh rename to csharp/tests/Facebook.Yoga/test_macos.sh index 566170e4..9a3ad14f 100755 --- a/csharp/tests/Facebook.CSSLayout/test_macos.sh +++ b/csharp/tests/Facebook.Yoga/test_macos.sh @@ -28,6 +28,6 @@ if [ -d $NUNIT \ rm NUnit-2.6.4.zip fi -clang -g -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp -mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs -MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll +clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../CSSLayout/*.c ../../Yoga/YGInterop.cpp +mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs +MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll diff --git a/enums.py b/enums.py index e54e49d6..8360da49 100644 --- a/enums.py +++ b/enums.py @@ -175,9 +175,9 @@ for name, values in ENUMS.items(): # write out csharp files for name, values in ENUMS.items(): - with open(root + '/csharp/Facebook.CSSLayout/Yoga%s.cs' % name, 'w') as f: + with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f: f.write(LICENSE) - f.write('namespace Facebook.CSSLayout\n{\n') + f.write('namespace Facebook.Yoga\n{\n') f.write(' public enum Yoga%s\n {\n' % name) for value in values: if isinstance(value, tuple): diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 49c8e7cd..32a36173 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -19,13 +19,13 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { 'using System;', 'using NUnit.Framework;', '', - 'namespace Facebook.CSSLayout', + 'namespace Facebook.Yoga', '{', ]); this.pushIndent(); this.push([ '[TestFixture]', - 'public class CSSNodeLayoutTest', + 'public class YogaTest', '{', ]); this.pushIndent(); @@ -39,21 +39,21 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);'); + this.push('YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);'); } this.push(''); } }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('CSSNode ' + nodeName + ' = new CSSNode();'); + this.push('YogaNode ' + nodeName + ' = new YogaNode();'); }}, emitTestEpilogue:{value:function(experiments) { if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', false);'); + this.push('YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', false);'); } } diff --git a/gentest/gentest.rb b/gentest/gentest.rb index 1ee0c78b..1d3300ac 100644 --- a/gentest/gentest.rb +++ b/gentest/gentest.rb @@ -44,8 +44,8 @@ Dir['fixtures/*.html'].each do |file| f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('CSSNodeLayoutTest', name) f.close - f = File.open("../csharp/tests/Facebook.CSSLayout/#{name}.cs", 'w') - f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('CSSNodeLayoutTest', name) + f = File.open("../csharp/tests/Facebook.Yoga/#{name}.cs", 'w') + f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name) f.close end File.delete('test.html') From dda24b1e23fe2ab5e5e046126093dfc8290dc830 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Sat, 3 Dec 2016 04:40:18 -0800 Subject: [PATCH 096/108] Rename C api Summary: This renames the core C api to use the new Yoga branding. Differential Revision: D4259190 fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9 --- CSSLayout/CSSLayout.h | 183 -- CSSLayout/CSSNodeList.c | 104 - CSSLayout/CSSNodeList.h | 33 - CSSLayout/{CSSEnums.h => YGEnums.h} | 0 CSSLayout/{CSSMacros.h => YGMacros.h} | 22 +- CSSLayout/YGNodeList.c | 104 + CSSLayout/YGNodeList.h | 33 + CSSLayout/{CSSLayout.c => Yoga.c} | 1761 +++++++++-------- CSSLayout/Yoga.h | 181 ++ YogaKit/Tests/YogaKitTests.m | 12 +- YogaKit/UIView+Yoga.h | 4 +- YogaKit/UIView+Yoga.m | 152 +- benchmark/YGBenchmark.c | 108 +- csharp/Facebook.Yoga/Native.cs | 162 +- csharp/Facebook.Yoga/YogaNode.cs | 150 +- csharp/Yoga/YGInterop.cpp | 2 +- csharp/Yoga/YGInterop.h | 6 +- csharp/Yoga/Yoga.vcxproj | 18 +- csharp/Yoga/Yoga.vcxproj.filters | 10 +- enums.py | 2 +- gentest/gentest-cpp.js | 68 +- java/com/facebook/csslayout/CSSNode.java | 248 +-- java/jni/CSSJNI.cpp | 340 ---- java/jni/YGJNI.cpp | 333 ++++ .../com/facebook/csslayout/CSSNodeTest.java | 8 +- tests/CSSLayoutAbsolutePositionTest.cpp | 444 ++--- tests/CSSLayoutAlignContentTest.cpp | 606 +++--- tests/CSSLayoutAlignItemsTest.cpp | 222 +-- tests/CSSLayoutAlignSelfTest.cpp | 228 +-- tests/CSSLayoutAspectRatioTest.cpp | 560 +++--- tests/CSSLayoutBorderTest.cpp | 280 +-- tests/CSSLayoutDefaultValuesTest.cpp | 110 +- tests/CSSLayoutDirtyMarkingTest.cpp | 122 +- tests/CSSLayoutEdgeTest.cpp | 232 +-- tests/CSSLayoutFlexDirectionTest.cpp | 582 +++--- tests/CSSLayoutFlexTest.cpp | 590 +++--- tests/CSSLayoutFlexWrapTest.cpp | 516 ++--- tests/CSSLayoutJustifyContentTest.cpp | 986 ++++----- tests/CSSLayoutMarginTest.cpp | 596 +++--- tests/CSSLayoutMeasureCacheTest.cpp | 120 +- tests/CSSLayoutMeasureModeTest.cpp | 234 +-- tests/CSSLayoutMeasureTest.cpp | 70 +- tests/CSSLayoutMemoryFuncTest.cpp | 48 +- tests/CSSLayoutMinMaxDimensionTest.cpp | 642 +++--- tests/CSSLayoutPaddingTest.cpp | 346 ++-- tests/CSSLayoutRelayoutTest.cpp | 26 +- tests/CSSLayoutRoundingMeasureFuncTest.cpp | 54 +- tests/CSSLayoutRoundingTest.cpp | 1170 +++++------ tests/CSSLayoutStyleTest.cpp | 72 +- 49 files changed, 6459 insertions(+), 6441 deletions(-) delete mode 100644 CSSLayout/CSSLayout.h delete mode 100644 CSSLayout/CSSNodeList.c delete mode 100644 CSSLayout/CSSNodeList.h rename CSSLayout/{CSSEnums.h => YGEnums.h} (100%) rename CSSLayout/{CSSMacros.h => YGMacros.h} (60%) create mode 100644 CSSLayout/YGNodeList.c create mode 100644 CSSLayout/YGNodeList.h rename CSSLayout/{CSSLayout.c => Yoga.c} (50%) create mode 100644 CSSLayout/Yoga.h delete mode 100644 java/jni/CSSJNI.cpp create mode 100644 java/jni/YGJNI.cpp 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); } From 6339467b6d50fa66a9ba3cc5e0b7490557191996 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Sat, 3 Dec 2016 04:40:21 -0800 Subject: [PATCH 097/108] Rename tests Summary: Rename test files to use new name Reviewed By: gkassabli Differential Revision: D4265235 fbshipit-source-id: 0090d3949828058baf7435f33d4068de92756bad --- ...itionTest.cs => YGAbsolutePositionTest.cs} | 4 +- ...gnContentTest.cs => YGAlignContentTest.cs} | 4 +- ...tAlignItemsTest.cs => YGAlignItemsTest.cs} | 4 +- ...outAlignSelfTest.cs => YGAlignSelfTest.cs} | 4 +- ...CSSLayoutBorderTest.cs => YGBorderTest.cs} | 4 +- ...irectionTest.cs => YGFlexDirectionTest.cs} | 4 +- .../{CSSLayoutFlexTest.cs => YGFlexTest.cs} | 4 +- ...ayoutFlexWrapTest.cs => YGFlexWrapTest.cs} | 4 +- ...ContentTest.cs => YGJustifyContentTest.cs} | 4 +- ...CSSLayoutMarginTest.cs => YGMarginTest.cs} | 4 +- ...ensionTest.cs => YGMinMaxDimensionTest.cs} | 4 +- ...SLayoutPaddingTest.cs => YGPaddingTest.cs} | 4 +- ...ayoutRoundingTest.cs => YGRoundingTest.cs} | 4 +- ...nTest.html => YGAbsolutePositionTest.html} | 0 ...ntentTest.html => YGAlignContentTest.html} | 0 ...gnItemsTest.html => YGAlignItemsTest.html} | 0 ...lignSelfTest.html => YGAlignSelfTest.html} | 0 ...ayoutBorderTest.html => YGBorderTest.html} | 0 ...tionTest.html => YGFlexDirectionTest.html} | 0 ...CSSLayoutFlexTest.html => YGFlexTest.html} | 0 ...tFlexWrapTest.html => YGFlexWrapTest.html} | 0 ...entTest.html => YGJustifyContentTest.html} | 0 ...ayoutMarginTest.html => YGMarginTest.html} | 0 ...onTest.html => YGMinMaxDimensionTest.html} | 0 ...outPaddingTest.html => YGPaddingTest.html} | 0 ...tRoundingTest.html => YGRoundingTest.html} | 0 gentest/gentest-cpp.js | 56 +++++----- gentest/gentest-cs.js | 56 +++++----- gentest/gentest-java.js | 58 +++++----- gentest/gentest.js | 102 +++++++++--------- gentest/gentest.rb | 2 +- ...nTest.java => YGAbsolutePositionTest.java} | 4 +- ...ntentTest.java => YGAlignContentTest.java} | 4 +- ...gnItemsTest.java => YGAlignItemsTest.java} | 4 +- ...lignSelfTest.java => YGAlignSelfTest.java} | 4 +- ...ayoutBorderTest.java => YGBorderTest.java} | 4 +- ...tionTest.java => YGFlexDirectionTest.java} | 4 +- ...CSSLayoutFlexTest.java => YGFlexTest.java} | 4 +- ...tFlexWrapTest.java => YGFlexWrapTest.java} | 4 +- ...entTest.java => YGJustifyContentTest.java} | 4 +- ...ayoutMarginTest.java => YGMarginTest.java} | 4 +- ...onTest.java => YGMinMaxDimensionTest.java} | 4 +- ...outPaddingTest.java => YGPaddingTest.java} | 4 +- ...tRoundingTest.java => YGRoundingTest.java} | 4 +- .../{CSSNodeTest.java => YogaNodeTest.java} | 2 +- ...ionTest.cpp => YGAbsolutePositionTest.cpp} | 2 +- ...ContentTest.cpp => YGAlignContentTest.cpp} | 2 +- ...lignItemsTest.cpp => YGAlignItemsTest.cpp} | 2 +- ...tAlignSelfTest.cpp => YGAlignSelfTest.cpp} | 2 +- ...SLayoutBorderTest.cpp => YGBorderTest.cpp} | 2 +- ...MarkingTest.cpp => YGDirtyMarkingTest.cpp} | 0 .../{CSSLayoutEdgeTest.cpp => YGEdgeTest.cpp} | 0 ...ectionTest.cpp => YGFlexDirectionTest.cpp} | 2 +- .../{CSSLayoutFlexTest.cpp => YGFlexTest.cpp} | 2 +- ...outFlexWrapTest.cpp => YGFlexWrapTest.cpp} | 2 +- ...ntentTest.cpp => YGJustifyContentTest.cpp} | 2 +- ...ioTest.cpp => YGLayoutAspectRatioTest.cpp} | 0 ...Test.cpp => YGLayoutDefaultValuesTest.cpp} | 0 ...SLayoutMarginTest.cpp => YGMarginTest.cpp} | 2 +- ...reCacheTest.cpp => YGMeasureCacheTest.cpp} | 0 ...sureModeTest.cpp => YGMeasureModeTest.cpp} | 0 ...ayoutMeasureTest.cpp => YGMeasureTest.cpp} | 0 ...emoryFuncTest.cpp => YGMemoryFuncTest.cpp} | 0 ...sionTest.cpp => YGMinMaxDimensionTest.cpp} | 2 +- ...ayoutPaddingTest.cpp => YGPaddingTest.cpp} | 2 +- ...outRelayoutTest.cpp => YGRelayoutTest.cpp} | 0 ...Test.cpp => YGRoundingMeasureFuncTest.cpp} | 0 ...outRoundingTest.cpp => YGRoundingTest.cpp} | 2 +- ...CSSLayoutStyleTest.cpp => YGStyleTest.cpp} | 0 69 files changed, 203 insertions(+), 203 deletions(-) rename csharp/tests/Facebook.Yoga/{CSSLayoutAbsolutePositionTest.cs => YGAbsolutePositionTest.cs} (98%) rename csharp/tests/Facebook.Yoga/{CSSLayoutAlignContentTest.cs => YGAlignContentTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutAlignItemsTest.cs => YGAlignItemsTest.cs} (97%) rename csharp/tests/Facebook.Yoga/{CSSLayoutAlignSelfTest.cs => YGAlignSelfTest.cs} (98%) rename csharp/tests/Facebook.Yoga/{CSSLayoutBorderTest.cs => YGBorderTest.cs} (98%) rename csharp/tests/Facebook.Yoga/{CSSLayoutFlexDirectionTest.cs => YGFlexDirectionTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutFlexTest.cs => YGFlexTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutFlexWrapTest.cs => YGFlexWrapTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutJustifyContentTest.cs => YGJustifyContentTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutMarginTest.cs => YGMarginTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutMinMaxDimensionTest.cs => YGMinMaxDimensionTest.cs} (99%) rename csharp/tests/Facebook.Yoga/{CSSLayoutPaddingTest.cs => YGPaddingTest.cs} (98%) rename csharp/tests/Facebook.Yoga/{CSSLayoutRoundingTest.cs => YGRoundingTest.cs} (99%) rename gentest/fixtures/{CSSLayoutAbsolutePositionTest.html => YGAbsolutePositionTest.html} (100%) rename gentest/fixtures/{CSSLayoutAlignContentTest.html => YGAlignContentTest.html} (100%) rename gentest/fixtures/{CSSLayoutAlignItemsTest.html => YGAlignItemsTest.html} (100%) rename gentest/fixtures/{CSSLayoutAlignSelfTest.html => YGAlignSelfTest.html} (100%) rename gentest/fixtures/{CSSLayoutBorderTest.html => YGBorderTest.html} (100%) rename gentest/fixtures/{CSSLayoutFlexDirectionTest.html => YGFlexDirectionTest.html} (100%) rename gentest/fixtures/{CSSLayoutFlexTest.html => YGFlexTest.html} (100%) rename gentest/fixtures/{CSSLayoutFlexWrapTest.html => YGFlexWrapTest.html} (100%) rename gentest/fixtures/{CSSLayoutJustifyContentTest.html => YGJustifyContentTest.html} (100%) rename gentest/fixtures/{CSSLayoutMarginTest.html => YGMarginTest.html} (100%) rename gentest/fixtures/{CSSLayoutMinMaxDimensionTest.html => YGMinMaxDimensionTest.html} (100%) rename gentest/fixtures/{CSSLayoutPaddingTest.html => YGPaddingTest.html} (100%) rename gentest/fixtures/{CSSLayoutRoundingTest.html => YGRoundingTest.html} (100%) rename java/tests/com/facebook/csslayout/{CSSLayoutAbsolutePositionTest.java => YGAbsolutePositionTest.java} (98%) rename java/tests/com/facebook/csslayout/{CSSLayoutAlignContentTest.java => YGAlignContentTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutAlignItemsTest.java => YGAlignItemsTest.java} (97%) rename java/tests/com/facebook/csslayout/{CSSLayoutAlignSelfTest.java => YGAlignSelfTest.java} (97%) rename java/tests/com/facebook/csslayout/{CSSLayoutBorderTest.java => YGBorderTest.java} (98%) rename java/tests/com/facebook/csslayout/{CSSLayoutFlexDirectionTest.java => YGFlexDirectionTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutFlexTest.java => YGFlexTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutFlexWrapTest.java => YGFlexWrapTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutJustifyContentTest.java => YGJustifyContentTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutMarginTest.java => YGMarginTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutMinMaxDimensionTest.java => YGMinMaxDimensionTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSLayoutPaddingTest.java => YGPaddingTest.java} (98%) rename java/tests/com/facebook/csslayout/{CSSLayoutRoundingTest.java => YGRoundingTest.java} (99%) rename java/tests/com/facebook/csslayout/{CSSNodeTest.java => YogaNodeTest.java} (98%) rename tests/{CSSLayoutAbsolutePositionTest.cpp => YGAbsolutePositionTest.cpp} (99%) rename tests/{CSSLayoutAlignContentTest.cpp => YGAlignContentTest.cpp} (99%) rename tests/{CSSLayoutAlignItemsTest.cpp => YGAlignItemsTest.cpp} (98%) rename tests/{CSSLayoutAlignSelfTest.cpp => YGAlignSelfTest.cpp} (98%) rename tests/{CSSLayoutBorderTest.cpp => YGBorderTest.cpp} (98%) rename tests/{CSSLayoutDirtyMarkingTest.cpp => YGDirtyMarkingTest.cpp} (100%) rename tests/{CSSLayoutEdgeTest.cpp => YGEdgeTest.cpp} (100%) rename tests/{CSSLayoutFlexDirectionTest.cpp => YGFlexDirectionTest.cpp} (99%) rename tests/{CSSLayoutFlexTest.cpp => YGFlexTest.cpp} (99%) rename tests/{CSSLayoutFlexWrapTest.cpp => YGFlexWrapTest.cpp} (99%) rename tests/{CSSLayoutJustifyContentTest.cpp => YGJustifyContentTest.cpp} (99%) rename tests/{CSSLayoutAspectRatioTest.cpp => YGLayoutAspectRatioTest.cpp} (100%) rename tests/{CSSLayoutDefaultValuesTest.cpp => YGLayoutDefaultValuesTest.cpp} (100%) rename tests/{CSSLayoutMarginTest.cpp => YGMarginTest.cpp} (99%) rename tests/{CSSLayoutMeasureCacheTest.cpp => YGMeasureCacheTest.cpp} (100%) rename tests/{CSSLayoutMeasureModeTest.cpp => YGMeasureModeTest.cpp} (100%) rename tests/{CSSLayoutMeasureTest.cpp => YGMeasureTest.cpp} (100%) rename tests/{CSSLayoutMemoryFuncTest.cpp => YGMemoryFuncTest.cpp} (100%) rename tests/{CSSLayoutMinMaxDimensionTest.cpp => YGMinMaxDimensionTest.cpp} (99%) rename tests/{CSSLayoutPaddingTest.cpp => YGPaddingTest.cpp} (99%) rename tests/{CSSLayoutRelayoutTest.cpp => YGRelayoutTest.cpp} (100%) rename tests/{CSSLayoutRoundingMeasureFuncTest.cpp => YGRoundingMeasureFuncTest.cpp} (100%) rename tests/{CSSLayoutRoundingTest.cpp => YGRoundingTest.cpp} (99%) rename tests/{CSSLayoutStyleTest.cpp => YGStyleTest.cpp} (100%) diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs similarity index 98% rename from csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs rename to csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index ba377250..c9d49cc0 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutAbsolutePositionTest + public class YGAbsolutePositionTest { [Test] public void Test_absolute_layout_width_height_start_top() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs rename to csharp/tests/Facebook.Yoga/YGAlignContentTest.cs index 2fd26b95..598b1dd7 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutAlignContentTest + public class YGAlignContentTest { [Test] public void Test_align_content_flex_start() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs similarity index 97% rename from csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs rename to csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index 54101754..33b4c0d2 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutAlignItemsTest + public class YGAlignItemsTest { [Test] public void Test_align_items_stretch() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs similarity index 98% rename from csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs rename to csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs index 00a8246f..c564cf93 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutAlignSelfTest + public class YGAlignSelfTest { [Test] public void Test_align_self_center() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs similarity index 98% rename from csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs rename to csharp/tests/Facebook.Yoga/YGBorderTest.cs index 1182b777..613fe115 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutBorderTest + public class YGBorderTest { [Test] public void Test_border_no_size() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs rename to csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs index abd749b7..10a1257a 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutFlexDirectionTest + public class YGFlexDirectionTest { [Test] public void Test_flex_direction_column_no_height() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs b/csharp/tests/Facebook.Yoga/YGFlexTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs rename to csharp/tests/Facebook.Yoga/YGFlexTest.cs index 69ee52a1..05036680 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutFlexTest + public class YGFlexTest { [Test] public void Test_flex_basis_flex_grow_column() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs rename to csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs index bf8c4ac8..d5c88f7f 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutFlexWrapTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutFlexWrapTest + public class YGFlexWrapTest { [Test] public void Test_wrap_column() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs rename to csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs index 86d8d50f..7c8bb4d1 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutJustifyContentTest + public class YGJustifyContentTest { [Test] public void Test_justify_content_row_flex_start() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs rename to csharp/tests/Facebook.Yoga/YGMarginTest.cs index c2eb8123..fa9ddee2 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutMarginTest + public class YGMarginTest { [Test] public void Test_margin_start() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs rename to csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index 6d8b7ba9..04413d41 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutMinMaxDimensionTest + public class YGMinMaxDimensionTest { [Test] public void Test_max_width() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs similarity index 98% rename from csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs rename to csharp/tests/Facebook.Yoga/YGPaddingTest.cs index 47f04155..7fde4e5e 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutPaddingTest + public class YGPaddingTest { [Test] public void Test_padding_no_size() diff --git a/csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs similarity index 99% rename from csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs rename to csharp/tests/Facebook.Yoga/YGRoundingTest.cs index 570b00be..62da0f0c 100644 --- a/csharp/tests/Facebook.Yoga/CSSLayoutRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html using System; using NUnit.Framework; @@ -15,7 +15,7 @@ using NUnit.Framework; namespace Facebook.Yoga { [TestFixture] - public class CSSLayoutRoundingTest + public class YGRoundingTest { [Test] public void Test_rounding_flex_basis_flex_grow_row_width_of_100() diff --git a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html b/gentest/fixtures/YGAbsolutePositionTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutAbsolutePositionTest.html rename to gentest/fixtures/YGAbsolutePositionTest.html diff --git a/gentest/fixtures/CSSLayoutAlignContentTest.html b/gentest/fixtures/YGAlignContentTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutAlignContentTest.html rename to gentest/fixtures/YGAlignContentTest.html diff --git a/gentest/fixtures/CSSLayoutAlignItemsTest.html b/gentest/fixtures/YGAlignItemsTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutAlignItemsTest.html rename to gentest/fixtures/YGAlignItemsTest.html diff --git a/gentest/fixtures/CSSLayoutAlignSelfTest.html b/gentest/fixtures/YGAlignSelfTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutAlignSelfTest.html rename to gentest/fixtures/YGAlignSelfTest.html diff --git a/gentest/fixtures/CSSLayoutBorderTest.html b/gentest/fixtures/YGBorderTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutBorderTest.html rename to gentest/fixtures/YGBorderTest.html diff --git a/gentest/fixtures/CSSLayoutFlexDirectionTest.html b/gentest/fixtures/YGFlexDirectionTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutFlexDirectionTest.html rename to gentest/fixtures/YGFlexDirectionTest.html diff --git a/gentest/fixtures/CSSLayoutFlexTest.html b/gentest/fixtures/YGFlexTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutFlexTest.html rename to gentest/fixtures/YGFlexTest.html diff --git a/gentest/fixtures/CSSLayoutFlexWrapTest.html b/gentest/fixtures/YGFlexWrapTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutFlexWrapTest.html rename to gentest/fixtures/YGFlexWrapTest.html diff --git a/gentest/fixtures/CSSLayoutJustifyContentTest.html b/gentest/fixtures/YGJustifyContentTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutJustifyContentTest.html rename to gentest/fixtures/YGJustifyContentTest.html diff --git a/gentest/fixtures/CSSLayoutMarginTest.html b/gentest/fixtures/YGMarginTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutMarginTest.html rename to gentest/fixtures/YGMarginTest.html diff --git a/gentest/fixtures/CSSLayoutMinMaxDimensionTest.html b/gentest/fixtures/YGMinMaxDimensionTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html rename to gentest/fixtures/YGMinMaxDimensionTest.html diff --git a/gentest/fixtures/CSSLayoutPaddingTest.html b/gentest/fixtures/YGPaddingTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutPaddingTest.html rename to gentest/fixtures/YGPaddingTest.html diff --git a/gentest/fixtures/CSSLayoutRoundingTest.html b/gentest/fixtures/YGRoundingTest.html similarity index 100% rename from gentest/fixtures/CSSLayoutRoundingTest.html rename to gentest/fixtures/YGRoundingTest.html diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index ea49d995..f4db36ed 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -108,115 +108,115 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGUndefined:{value:'YGUndefined'}, - CSSNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir) { this.push('YGNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');'); }}, - CSSNodeInsertChild:{value:function(parentName, nodeName, index) { + YGNodeInsertChild:{value:function(parentName, nodeName, index) { this.push('YGNodeInsertChild(' + parentName + ', ' + nodeName + ', ' + index + ');'); }}, - CSSNodeLayoutGetLeft:{value:function(nodeName) { + YGNodeLayoutGetLeft:{value:function(nodeName) { return 'YGNodeLayoutGetLeft(' + nodeName + ')'; }}, - CSSNodeLayoutGetTop:{value:function(nodeName) { + YGNodeLayoutGetTop:{value:function(nodeName) { return 'YGNodeLayoutGetTop(' + nodeName + ')'; }}, - CSSNodeLayoutGetWidth:{value:function(nodeName) { + YGNodeLayoutGetWidth:{value:function(nodeName) { return 'YGNodeLayoutGetWidth(' + nodeName + ')'; }}, - CSSNodeLayoutGetHeight:{value:function(nodeName) { + YGNodeLayoutGetHeight:{value:function(nodeName) { return 'YGNodeLayoutGetHeight(' + nodeName + ')'; }}, - CSSNodeStyleSetAlignContent:{value:function(nodeName, value) { + YGNodeStyleSetAlignContent:{value:function(nodeName, value) { this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetAlignItems:{value:function(nodeName, value) { + YGNodeStyleSetAlignItems:{value:function(nodeName, value) { this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) { + YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { + YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetDirection:{value:function(nodeName, value) { + YGNodeStyleSetDirection:{value:function(nodeName, value) { this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { + YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { + YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { + YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { + YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { + YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetHeight:{value:function(nodeName, value) { + YGNodeStyleSetHeight:{value:function(nodeName, value) { this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { + YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { + YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { + YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { + YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { + YGNodeStyleSetMinHeight:{value:function(nodeName, value) { this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { + YGNodeStyleSetMinWidth:{value:function(nodeName, value) { this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetOverflow:{value:function(nodeName, value) { + YGNodeStyleSetOverflow:{value:function(nodeName, value) { this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { + YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { + YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); }}, - CSSNodeStyleSetPositionType:{value:function(nodeName, value) { + YGNodeStyleSetPositionType:{value:function(nodeName, value) { this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');'); }}, - CSSNodeStyleSetWidth:{value:function(nodeName, value) { + YGNodeStyleSetWidth:{value:function(nodeName, value) { this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); }}, }); diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 32a36173..0dbbb498 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -117,116 +117,116 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { YGWrapNoWrap:{value:'YogaWrap.NoWrap'}, YGWrapWrap:{value:'YogaWrap.Wrap'}, - CSSNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.StyleDirection = ' + dir + ';'); this.push(node + '.CalculateLayout();'); }}, - CSSNodeInsertChild:{value:function(parentName, nodeName, index) { + YGNodeInsertChild:{value:function(parentName, nodeName, index) { this.push(parentName + '.Insert(' + index + ', ' + nodeName + ');'); }}, - CSSNodeLayoutGetLeft:{value:function(nodeName) { + YGNodeLayoutGetLeft:{value:function(nodeName) { return nodeName + '.LayoutX'; }}, - CSSNodeLayoutGetTop:{value:function(nodeName) { + YGNodeLayoutGetTop:{value:function(nodeName) { return nodeName + '.LayoutY'; }}, - CSSNodeLayoutGetWidth:{value:function(nodeName) { + YGNodeLayoutGetWidth:{value:function(nodeName) { return nodeName + '.LayoutWidth'; }}, - CSSNodeLayoutGetHeight:{value:function(nodeName) { + YGNodeLayoutGetHeight:{value:function(nodeName) { return nodeName + '.LayoutHeight'; }}, - CSSNodeStyleSetAlignContent:{value:function(nodeName, value) { + YGNodeStyleSetAlignContent:{value:function(nodeName, value) { this.push(nodeName + '.AlignContent = ' + value + ';'); }}, - CSSNodeStyleSetAlignItems:{value:function(nodeName, value) { + YGNodeStyleSetAlignItems:{value:function(nodeName, value) { this.push(nodeName + '.AlignItems = ' + value + ';'); }}, - CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) { + YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { this.push(nodeName + '.AlignSelf = ' + value + ';'); }}, - CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { + YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetDirection:{value:function(nodeName, value) { + YGNodeStyleSetDirection:{value:function(nodeName, value) { this.push(nodeName + '.StyleDirection = ' + value + ';'); }}, - CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { + YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { this.push(nodeName + '.FlexBasis = ' + value + 'f;'); }}, - CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { + YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { this.push(nodeName + '.FlexDirection = ' + value + ';'); }}, - CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { + YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { this.push(nodeName + '.FlexGrow = ' + value + 'f;'); }}, - CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { + YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { this.push(nodeName + '.FlexShrink = ' + value + 'f;'); }}, - CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { + YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { this.push(nodeName + '.Wrap = ' + value + ';'); }}, - CSSNodeStyleSetHeight:{value:function(nodeName, value) { + YGNodeStyleSetHeight:{value:function(nodeName, value) { this.push(nodeName + '.Height = ' + value + 'f;'); }}, - CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { + YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { this.push(nodeName + '.JustifyContent = ' + value + ';'); }}, - CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { + YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { + YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { this.push(nodeName + '.MaxHeight = ' + value + 'f;'); }}, - CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { + YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { this.push(nodeName + '.MaxWidth = ' + value + 'f;'); }}, - CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { + YGNodeStyleSetMinHeight:{value:function(nodeName, value) { this.push(nodeName + '.MinHeight = ' + value + 'f;'); }}, - CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { + YGNodeStyleSetMinWidth:{value:function(nodeName, value) { this.push(nodeName + '.MinWidth = ' + value + 'f;'); }}, - CSSNodeStyleSetOverflow:{value:function(nodeName, value) { + YGNodeStyleSetOverflow:{value:function(nodeName, value) { this.push(nodeName + '.Overflow = ' + value + ';'); }}, - CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { + YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { + YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetPositionType:{value:function(nodeName, value) { + YGNodeStyleSetPositionType:{value:function(nodeName, value) { this.push(nodeName + '.PositionType = ' + value + ';'); }}, - CSSNodeStyleSetWidth:{value:function(nodeName, value) { + YGNodeStyleSetWidth:{value:function(nodeName, value) { this.push(nodeName + '.Width = ' + value + 'f;'); }}, }); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 48b2b82c..6dc8f5b8 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -34,7 +34,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { '', 'import static org.junit.Assert.assertEquals;', '', - 'public class CSSNodeLayoutTest {', + 'public class YogaTest {', ]); this.pushIndent(); }}, @@ -122,116 +122,116 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { YGWrapNoWrap:{value:'YogaWrap.NO_WRAP'}, YGWrapWrap:{value:'YogaWrap.WRAP'}, - CSSNodeCalculateLayout:{value:function(node, dir) { + YGNodeCalculateLayout:{value:function(node, dir) { this.push(node + '.setDirection(' + dir + ');'); this.push(node + '.calculateLayout();'); }}, - CSSNodeInsertChild:{value:function(parentName, nodeName, index) { + YGNodeInsertChild:{value:function(parentName, nodeName, index) { this.push(parentName + '.addChildAt(' + nodeName + ', ' + index + ');'); }}, - CSSNodeLayoutGetLeft:{value:function(nodeName) { + YGNodeLayoutGetLeft:{value:function(nodeName) { return nodeName + '.getLayoutX()'; }}, - CSSNodeLayoutGetTop:{value:function(nodeName) { + YGNodeLayoutGetTop:{value:function(nodeName) { return nodeName + '.getLayoutY()'; }}, - CSSNodeLayoutGetWidth:{value:function(nodeName) { + YGNodeLayoutGetWidth:{value:function(nodeName) { return nodeName + '.getLayoutWidth()'; }}, - CSSNodeLayoutGetHeight:{value:function(nodeName) { + YGNodeLayoutGetHeight:{value:function(nodeName) { return nodeName + '.getLayoutHeight()'; }}, - CSSNodeStyleSetAlignContent:{value:function(nodeName, value) { + YGNodeStyleSetAlignContent:{value:function(nodeName, value) { this.push(nodeName + '.setAlignContent(' + value + ');'); }}, - CSSNodeStyleSetAlignItems:{value:function(nodeName, value) { + YGNodeStyleSetAlignItems:{value:function(nodeName, value) { this.push(nodeName + '.setAlignItems(' + value + ');'); }}, - CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) { + YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { this.push(nodeName + '.setAlignSelf(' + value + ');'); }}, - CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { + YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetDirection:{value:function(nodeName, value) { + YGNodeStyleSetDirection:{value:function(nodeName, value) { this.push(nodeName + '.setDirection(' + value + ');'); }}, - CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { + YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { this.push(nodeName + '.setFlexBasis(' + value + 'f);'); }}, - CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { + YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { this.push(nodeName + '.setFlexDirection(' + value + ');'); }}, - CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { + YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { this.push(nodeName + '.setFlexGrow(' + value + 'f);'); }}, - CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { + YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { this.push(nodeName + '.setFlexShrink(' + value + 'f);'); }}, - CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { + YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { this.push(nodeName + '.setWrap(' + value + ');'); }}, - CSSNodeStyleSetHeight:{value:function(nodeName, value) { + YGNodeStyleSetHeight:{value:function(nodeName, value) { this.push(nodeName + '.setHeight(' + value + 'f);'); }}, - CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { + YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { this.push(nodeName + '.setJustifyContent(' + value + ');'); }}, - CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { + YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { + YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { this.push(nodeName + '.setMaxHeight(' + value + 'f);'); }}, - CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { + YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { this.push(nodeName + '.setMaxWidth(' + value + 'f);'); }}, - CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { + YGNodeStyleSetMinHeight:{value:function(nodeName, value) { this.push(nodeName + '.setMinHeight(' + value + 'f);'); }}, - CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { + YGNodeStyleSetMinWidth:{value:function(nodeName, value) { this.push(nodeName + '.setMinWidth(' + value + 'f);'); }}, - CSSNodeStyleSetOverflow:{value:function(nodeName, value) { + YGNodeStyleSetOverflow:{value:function(nodeName, value) { this.push(nodeName + '.setOverflow(' + value + ');'); }}, - CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { + YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { this.push(nodeName + '.setPadding(' + edge + ', ' + value + ');'); }}, - CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { + YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);'); }}, - CSSNodeStyleSetPositionType:{value:function(nodeName, value) { + YGNodeStyleSetPositionType:{value:function(nodeName, value) { this.push(nodeName + '.setPositionType(' + value + ');'); }}, - CSSNodeStyleSetWidth:{value:function(nodeName, value) { + YGNodeStyleSetWidth:{value:function(nodeName, value) { this.push(nodeName + '.setWidth(' + value + 'f);'); }}, }); diff --git a/gentest/gentest.js b/gentest/gentest.js index ed6fd6b9..196a8c1e 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -87,13 +87,13 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) { 'root', null); - e.CSSNodeCalculateLayout('root', e.YGDirectionLTR); + e.YGNodeCalculateLayout('root', e.YGDirectionLTR); e.push(''); assertTestTree(e, LTRLayoutTree[i], 'root', null); e.push(''); - e.CSSNodeCalculateLayout('root', e.YGDirectionRTL); + e.YGNodeCalculateLayout('root', e.YGDirectionRTL); e.push(''); assertTestTree(e, RTLLayoutTree[i], 'root', null); @@ -106,10 +106,10 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) { } function assertTestTree(e, node, nodeName, parentName) { - e.AssertEQ(node.left, e.CSSNodeLayoutGetLeft(nodeName)); - e.AssertEQ(node.top, e.CSSNodeLayoutGetTop(nodeName)); - e.AssertEQ(node.width, e.CSSNodeLayoutGetWidth(nodeName)); - e.AssertEQ(node.height, e.CSSNodeLayoutGetHeight(nodeName)); + e.AssertEQ(node.left, e.YGNodeLayoutGetLeft(nodeName)); + e.AssertEQ(node.top, e.YGNodeLayoutGetTop(nodeName)); + e.AssertEQ(node.width, e.YGNodeLayoutGetWidth(nodeName)); + e.AssertEQ(node.height, e.YGNodeLayoutGetHeight(nodeName)); for (var i = 0; i < node.children.length; i++) { e.push(''); @@ -159,147 +159,147 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index if (node.style[style] !== getDefaultStyleValue(style)) { switch (style) { case 'direction': - e.CSSNodeStyleSetDirection(nodeName, directionValue(e, node.style[style])); + e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style])); break; case 'flex-direction': - e.CSSNodeStyleSetFlexDirection(nodeName, flexDirectionValue(e, node.style[style])); + e.YGNodeStyleSetFlexDirection(nodeName, flexDirectionValue(e, node.style[style])); break; case 'justify-content': - e.CSSNodeStyleSetJustifyContent(nodeName, justifyValue(e, node.style[style])); + e.YGNodeStyleSetJustifyContent(nodeName, justifyValue(e, node.style[style])); break; case 'align-content': - e.CSSNodeStyleSetAlignContent(nodeName, alignValue(e, node.style[style])); + e.YGNodeStyleSetAlignContent(nodeName, alignValue(e, node.style[style])); break; case 'align-items': - e.CSSNodeStyleSetAlignItems(nodeName, alignValue(e, node.style[style])); + e.YGNodeStyleSetAlignItems(nodeName, alignValue(e, node.style[style])); break; case 'align-self': if (!parent || node.style[style] !== parent.style['align-items']) { - e.CSSNodeStyleSetAlignSelf(nodeName, alignValue(e, node.style[style])); + e.YGNodeStyleSetAlignSelf(nodeName, alignValue(e, node.style[style])); } break; case 'position': - e.CSSNodeStyleSetPositionType(nodeName, positionValue(e, node.style[style])); + e.YGNodeStyleSetPositionType(nodeName, positionValue(e, node.style[style])); break; case 'flex-wrap': - e.CSSNodeStyleSetFlexWrap(nodeName, wrapValue(e, node.style[style])); + e.YGNodeStyleSetFlexWrap(nodeName, wrapValue(e, node.style[style])); break; case 'overflow': - e.CSSNodeStyleSetOverflow(nodeName, overflowValue(e, node.style[style])); + e.YGNodeStyleSetOverflow(nodeName, overflowValue(e, node.style[style])); break; case 'flex-grow': - e.CSSNodeStyleSetFlexGrow(nodeName, node.style[style]); + e.YGNodeStyleSetFlexGrow(nodeName, node.style[style]); break; case 'flex-shrink': - e.CSSNodeStyleSetFlexShrink(nodeName, node.style[style]); + e.YGNodeStyleSetFlexShrink(nodeName, node.style[style]); break; case 'flex-basis': - e.CSSNodeStyleSetFlexBasis(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetFlexBasis(nodeName, pixelValue(e, node.style[style])); break; case 'left': if (genericNode.rawStyle.indexOf('start:') >= 0) { - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'top': - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'right': if (genericNode.rawStyle.indexOf('end:') >= 0) { - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'bottom': - e.CSSNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'margin-left': if (genericNode.rawStyle.indexOf('margin-start:') >= 0) { - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'margin-top': - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'margin-right': if (genericNode.rawStyle.indexOf('margin-end:') >= 0) { - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'margin-bottom': - e.CSSNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'padding-left': if (genericNode.rawStyle.indexOf('padding-start:') >= 0) { - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'padding-top': - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'padding-right': if (genericNode.rawStyle.indexOf('padding-end:') >= 0) { - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'padding-bottom': - e.CSSNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'border-left-width': if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) { - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); } break; case 'border-top-width': - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); break; case 'border-right-width': if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) { - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); } else { - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); } break; case 'border-bottom-width': - e.CSSNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); break; case 'width': - e.CSSNodeStyleSetWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetWidth(nodeName, pixelValue(e, node.style[style])); break; case 'min-width': - e.CSSNodeStyleSetMinWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMinWidth(nodeName, pixelValue(e, node.style[style])); break; case 'max-width': - e.CSSNodeStyleSetMaxWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMaxWidth(nodeName, pixelValue(e, node.style[style])); break; case 'height': - e.CSSNodeStyleSetHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetHeight(nodeName, pixelValue(e, node.style[style])); break; case 'min-height': - e.CSSNodeStyleSetMinHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMinHeight(nodeName, pixelValue(e, node.style[style])); break; case 'max-height': - e.CSSNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style])); break; } } } if (parentName) { - e.CSSNodeInsertChild(parentName, nodeName, index); + e.YGNodeInsertChild(parentName, nodeName, index); } for (var i = 0; i < node.children.length; i++) { @@ -411,7 +411,7 @@ function calculateTree(root) { width: child.offsetWidth, height: child.offsetHeight, children: calculateTree(child), - style: getCSSLayoutStyle(child), + style: getYogaStyle(child), declaredStyle: child.style, rawStyle: child.getAttribute('style'), experiments: child.getAttribute('experiments') @@ -423,7 +423,7 @@ function calculateTree(root) { return rootLayout; } -function getCSSLayoutStyle(node) { +function getYogaStyle(node) { return [ 'direction', 'flex-direction', diff --git a/gentest/gentest.rb b/gentest/gentest.rb index 1d3300ac..88191ce0 100644 --- a/gentest/gentest.rb +++ b/gentest/gentest.rb @@ -41,7 +41,7 @@ Dir['fixtures/*.html'].each do |file| f.close f = File.open("../java/tests/com/facebook/csslayout/#{name}.java", 'w') - f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('CSSNodeLayoutTest', name) + f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('YogaTest', name) f.close f = File.open("../csharp/tests/Facebook.Yoga/#{name}.cs", 'w') diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java similarity index 98% rename from java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java rename to java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java index c3ba26c7..0d135b84 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutAbsolutePositionTest { +public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java b/java/tests/com/facebook/csslayout/YGAlignContentTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java rename to java/tests/com/facebook/csslayout/YGAlignContentTest.java index 0c81f46d..c60b0fef 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignContentTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutAlignContentTest { +public class YGAlignContentTest { @Test public void test_align_content_flex_start() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java similarity index 97% rename from java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java rename to java/tests/com/facebook/csslayout/YGAlignItemsTest.java index 4dcdcea4..df922b98 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutAlignItemsTest { +public class YGAlignItemsTest { @Test public void test_align_items_stretch() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java similarity index 97% rename from java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java rename to java/tests/com/facebook/csslayout/YGAlignSelfTest.java index 3651e5b3..f5e3d0d5 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutAlignSelfTest { +public class YGAlignSelfTest { @Test public void test_align_self_center() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java b/java/tests/com/facebook/csslayout/YGBorderTest.java similarity index 98% rename from java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java rename to java/tests/com/facebook/csslayout/YGBorderTest.java index 1e1ac2ca..8973ec93 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java +++ b/java/tests/com/facebook/csslayout/YGBorderTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutBorderTest { +public class YGBorderTest { @Test public void test_border_no_size() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java rename to java/tests/com/facebook/csslayout/YGFlexDirectionTest.java index 73b1a98e..350b3081 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutFlexDirectionTest { +public class YGFlexDirectionTest { @Test public void test_flex_direction_column_no_height() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java b/java/tests/com/facebook/csslayout/YGFlexTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java rename to java/tests/com/facebook/csslayout/YGFlexTest.java index 3d4f1b84..fa408766 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutFlexTest { +public class YGFlexTest { @Test public void test_flex_basis_flex_grow_column() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java rename to java/tests/com/facebook/csslayout/YGFlexWrapTest.java index 8df07243..b3432c43 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutFlexWrapTest { +public class YGFlexWrapTest { @Test public void test_wrap_column() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java rename to java/tests/com/facebook/csslayout/YGJustifyContentTest.java index 2f486e6f..49637ead 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutJustifyContentTest { +public class YGJustifyContentTest { @Test public void test_justify_content_row_flex_start() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java b/java/tests/com/facebook/csslayout/YGMarginTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java rename to java/tests/com/facebook/csslayout/YGMarginTest.java index f265ef7b..8ee1a0e9 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java +++ b/java/tests/com/facebook/csslayout/YGMarginTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutMarginTest { +public class YGMarginTest { @Test public void test_margin_start() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java rename to java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java index d509e6a2..6f95748b 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutMinMaxDimensionTest { +public class YGMinMaxDimensionTest { @Test public void test_max_width() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java b/java/tests/com/facebook/csslayout/YGPaddingTest.java similarity index 98% rename from java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java rename to java/tests/com/facebook/csslayout/YGPaddingTest.java index a50ac8b5..b8c31960 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java +++ b/java/tests/com/facebook/csslayout/YGPaddingTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutPaddingTest { +public class YGPaddingTest { @Test public void test_padding_no_size() { final CSSNode root = new CSSNode(); diff --git a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java b/java/tests/com/facebook/csslayout/YGRoundingTest.java similarity index 99% rename from java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java rename to java/tests/com/facebook/csslayout/YGRoundingTest.java index e3e6543b..dfe2d4ef 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutRoundingTest.java +++ b/java/tests/com/facebook/csslayout/YGRoundingTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html package com.facebook.csslayout; @@ -15,7 +15,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CSSLayoutRoundingTest { +public class YGRoundingTest { @Test public void test_rounding_flex_basis_flex_grow_row_width_of_100() { CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); diff --git a/java/tests/com/facebook/csslayout/CSSNodeTest.java b/java/tests/com/facebook/csslayout/YogaNodeTest.java similarity index 98% rename from java/tests/com/facebook/csslayout/CSSNodeTest.java rename to java/tests/com/facebook/csslayout/YogaNodeTest.java index 16bc3977..9a39d052 100644 --- a/java/tests/com/facebook/csslayout/CSSNodeTest.java +++ b/java/tests/com/facebook/csslayout/YogaNodeTest.java @@ -14,7 +14,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class CSSNodeTest { +public class YogaNodeTest { @Test public void testInit() { diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp similarity index 99% rename from tests/CSSLayoutAbsolutePositionTest.cpp rename to tests/YGAbsolutePositionTest.cpp index 8e3ce96b..fb59f1c8 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html #include #include diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/YGAlignContentTest.cpp similarity index 99% rename from tests/CSSLayoutAlignContentTest.cpp rename to tests/YGAlignContentTest.cpp index 30c9b36e..5a2c6abf 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html #include #include diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp similarity index 98% rename from tests/CSSLayoutAlignItemsTest.cpp rename to tests/YGAlignItemsTest.cpp index 1092582c..fb5857f8 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html #include #include diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp similarity index 98% rename from tests/CSSLayoutAlignSelfTest.cpp rename to tests/YGAlignSelfTest.cpp index 008f30c7..d369dd64 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html #include #include diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/YGBorderTest.cpp similarity index 98% rename from tests/CSSLayoutBorderTest.cpp rename to tests/YGBorderTest.cpp index e4dc1bc5..0224276c 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html #include #include diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp similarity index 100% rename from tests/CSSLayoutDirtyMarkingTest.cpp rename to tests/YGDirtyMarkingTest.cpp diff --git a/tests/CSSLayoutEdgeTest.cpp b/tests/YGEdgeTest.cpp similarity index 100% rename from tests/CSSLayoutEdgeTest.cpp rename to tests/YGEdgeTest.cpp diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp similarity index 99% rename from tests/CSSLayoutFlexDirectionTest.cpp rename to tests/YGFlexDirectionTest.cpp index 786073a9..4f279e70 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html #include #include diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/YGFlexTest.cpp similarity index 99% rename from tests/CSSLayoutFlexTest.cpp rename to tests/YGFlexTest.cpp index 5035a049..fecc30ee 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html #include #include diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp similarity index 99% rename from tests/CSSLayoutFlexWrapTest.cpp rename to tests/YGFlexWrapTest.cpp index 0be05d5c..c2d13b77 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html #include #include diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp similarity index 99% rename from tests/CSSLayoutJustifyContentTest.cpp rename to tests/YGJustifyContentTest.cpp index 5a60b8c3..af0052fa 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html #include #include diff --git a/tests/CSSLayoutAspectRatioTest.cpp b/tests/YGLayoutAspectRatioTest.cpp similarity index 100% rename from tests/CSSLayoutAspectRatioTest.cpp rename to tests/YGLayoutAspectRatioTest.cpp diff --git a/tests/CSSLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp similarity index 100% rename from tests/CSSLayoutDefaultValuesTest.cpp rename to tests/YGLayoutDefaultValuesTest.cpp diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/YGMarginTest.cpp similarity index 99% rename from tests/CSSLayoutMarginTest.cpp rename to tests/YGMarginTest.cpp index 5d09ebdd..74f1bae0 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html #include #include diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/YGMeasureCacheTest.cpp similarity index 100% rename from tests/CSSLayoutMeasureCacheTest.cpp rename to tests/YGMeasureCacheTest.cpp diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp similarity index 100% rename from tests/CSSLayoutMeasureModeTest.cpp rename to tests/YGMeasureModeTest.cpp diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/YGMeasureTest.cpp similarity index 100% rename from tests/CSSLayoutMeasureTest.cpp rename to tests/YGMeasureTest.cpp diff --git a/tests/CSSLayoutMemoryFuncTest.cpp b/tests/YGMemoryFuncTest.cpp similarity index 100% rename from tests/CSSLayoutMemoryFuncTest.cpp rename to tests/YGMemoryFuncTest.cpp diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp similarity index 99% rename from tests/CSSLayoutMinMaxDimensionTest.cpp rename to tests/YGMinMaxDimensionTest.cpp index bd5a7dd8..2b51ae3d 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html #include #include diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/YGPaddingTest.cpp similarity index 99% rename from tests/CSSLayoutPaddingTest.cpp rename to tests/YGPaddingTest.cpp index d5aa6820..359d0235 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html #include #include diff --git a/tests/CSSLayoutRelayoutTest.cpp b/tests/YGRelayoutTest.cpp similarity index 100% rename from tests/CSSLayoutRelayoutTest.cpp rename to tests/YGRelayoutTest.cpp diff --git a/tests/CSSLayoutRoundingMeasureFuncTest.cpp b/tests/YGRoundingMeasureFuncTest.cpp similarity index 100% rename from tests/CSSLayoutRoundingMeasureFuncTest.cpp rename to tests/YGRoundingMeasureFuncTest.cpp diff --git a/tests/CSSLayoutRoundingTest.cpp b/tests/YGRoundingTest.cpp similarity index 99% rename from tests/CSSLayoutRoundingTest.cpp rename to tests/YGRoundingTest.cpp index 9a14ea26..00d6eedf 100644 --- a/tests/CSSLayoutRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html + // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html #include #include diff --git a/tests/CSSLayoutStyleTest.cpp b/tests/YGStyleTest.cpp similarity index 100% rename from tests/CSSLayoutStyleTest.cpp rename to tests/YGStyleTest.cpp From c6100d077185d667ec007acfe418a385f48f5d24 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Sat, 3 Dec 2016 04:40:23 -0800 Subject: [PATCH 098/108] Rename java API Summary: Rename java api to new use yoga naming Reviewed By: IanChilds Differential Revision: D4265345 fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5 --- gentest/gentest-java.js | 6 +- java/BUCK | 2 +- .../{CSSLogger.java => YogaLogger.java} | 4 +- .../csslayout/YogaMeasureFunction.java | 26 ++++ ...sureOutput.java => YogaMeasureOutput.java} | 2 +- .../csslayout/{CSSNode.java => YogaNode.java} | 32 ++--- .../{CSSNodeAPI.java => YogaNodeAPI.java} | 30 ++-- java/jni/YGJNI.cpp | 6 +- .../csslayout/YGAbsolutePositionTest.java | 28 ++-- .../csslayout/YGAlignContentTest.java | 48 +++---- .../facebook/csslayout/YGAlignItemsTest.java | 16 +-- .../facebook/csslayout/YGAlignSelfTest.java | 16 +-- .../com/facebook/csslayout/YGBorderTest.java | 18 +-- .../csslayout/YGFlexDirectionTest.java | 48 +++---- .../com/facebook/csslayout/YGFlexTest.java | 46 +++---- .../facebook/csslayout/YGFlexWrapTest.java | 40 +++--- .../csslayout/YGJustifyContentTest.java | 80 +++++------ .../com/facebook/csslayout/YGMarginTest.java | 44 +++--- .../csslayout/YGMinMaxDimensionTest.java | 48 +++---- .../com/facebook/csslayout/YGPaddingTest.java | 22 +-- .../facebook/csslayout/YGRoundingTest.java | 128 +++++++++--------- .../com/facebook/csslayout/YogaNodeTest.java | 28 ++-- 22 files changed, 366 insertions(+), 352 deletions(-) rename java/com/facebook/csslayout/{CSSLogger.java => YogaLogger.java} (90%) create mode 100644 java/com/facebook/csslayout/YogaMeasureFunction.java rename java/com/facebook/csslayout/{MeasureOutput.java => YogaMeasureOutput.java} (96%) rename java/com/facebook/csslayout/{CSSNode.java => YogaNode.java} (95%) rename java/com/facebook/csslayout/{CSSNodeAPI.java => YogaNodeAPI.java} (78%) diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 6dc8f5b8..0ae39fa7 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -46,21 +46,21 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { if (experiments.length > 0) { for (var i in experiments) { - this.push('CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); + this.push('YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);'); } this.push(''); } }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('final CSSNode ' + nodeName + ' = new CSSNode();'); + this.push('final YogaNode ' + nodeName + ' = new YogaNode();'); }}, emitTestEpilogue:{value:function(experiments) { if (experiments.length > 0) { this.push(''); for (var i in experiments) { - this.push('CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); + this.push('YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);'); } } diff --git a/java/BUCK b/java/BUCK index 1588edd4..3c48166d 100644 --- a/java/BUCK +++ b/java/BUCK @@ -9,7 +9,7 @@ include_defs('//YOGA_DEFS') cxx_library( name = 'jni', - soname = 'libcsslayout.$(ext)', + soname = 'libyoga.$(ext)', srcs = glob(['jni/*.cpp']), header_namespace = '', compiler_flags = [ diff --git a/java/com/facebook/csslayout/CSSLogger.java b/java/com/facebook/csslayout/YogaLogger.java similarity index 90% rename from java/com/facebook/csslayout/CSSLogger.java rename to java/com/facebook/csslayout/YogaLogger.java index c751768f..82bd19b6 100644 --- a/java/com/facebook/csslayout/CSSLogger.java +++ b/java/com/facebook/csslayout/YogaLogger.java @@ -12,11 +12,11 @@ package com.facebook.csslayout; import com.facebook.proguard.annotations.DoNotStrip; /** - * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); + * Inteface for recieving logs from native layer. Use by setting YogaNode.setLogger(myLogger); * See YogaLogLevel for the different log levels. */ @DoNotStrip -public interface CSSLogger { +public interface YogaLogger { @DoNotStrip void log(YogaLogLevel level, String message); } diff --git a/java/com/facebook/csslayout/YogaMeasureFunction.java b/java/com/facebook/csslayout/YogaMeasureFunction.java new file mode 100644 index 00000000..84a48521 --- /dev/null +++ b/java/com/facebook/csslayout/YogaMeasureFunction.java @@ -0,0 +1,26 @@ +/** + * 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. + */ + +package com.facebook.csslayout; + +import com.facebook.proguard.annotations.DoNotStrip; + +@DoNotStrip +public interface YogaMeasureFunction { + /** + * Return a value created by YogaMeasureOutput.make(width, height); + */ + @DoNotStrip + long measure( + YogaNodeAPI node, + float width, + YogaMeasureMode widthMode, + float height, + YogaMeasureMode heightMode); +} diff --git a/java/com/facebook/csslayout/MeasureOutput.java b/java/com/facebook/csslayout/YogaMeasureOutput.java similarity index 96% rename from java/com/facebook/csslayout/MeasureOutput.java rename to java/com/facebook/csslayout/YogaMeasureOutput.java index 5ec9fe35..6c968008 100644 --- a/java/com/facebook/csslayout/MeasureOutput.java +++ b/java/com/facebook/csslayout/YogaMeasureOutput.java @@ -12,7 +12,7 @@ package com.facebook.csslayout; /** * Helpers for building measure output value. */ -public class MeasureOutput { +public class YogaMeasureOutput { public static long make(float width, float height) { return make((int) width, (int) height); diff --git a/java/com/facebook/csslayout/CSSNode.java b/java/com/facebook/csslayout/YogaNode.java similarity index 95% rename from java/com/facebook/csslayout/CSSNode.java rename to java/com/facebook/csslayout/YogaNode.java index 90fe4676..99314b02 100644 --- a/java/com/facebook/csslayout/CSSNode.java +++ b/java/com/facebook/csslayout/YogaNode.java @@ -18,10 +18,10 @@ import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.soloader.SoLoader; @DoNotStrip -public class CSSNode implements CSSNodeAPI { +public class YogaNode implements YogaNodeAPI { static { - SoLoader.loadLibrary("csslayout"); + SoLoader.loadLibrary("yoga"); } /** @@ -31,7 +31,7 @@ public class CSSNode implements CSSNodeAPI { static native void jni_YGLog(int level, String message); private static native void jni_YGSetLogger(Object logger); - public static void setLogger(CSSLogger logger) { + public static void setLogger(YogaLogger logger) { jni_YGSetLogger(logger); } @@ -49,9 +49,9 @@ public class CSSNode implements CSSNodeAPI { return jni_YGIsExperimentalFeatureEnabled(feature.intValue()); } - private CSSNode mParent; - private List mChildren; - private MeasureFunction mMeasureFunction; + private YogaNode mParent; + private List mChildren; + private YogaMeasureFunction mMeasureFunction; private long mNativePointer; private Object mData; @@ -72,7 +72,7 @@ public class CSSNode implements CSSNodeAPI { private int mLayoutDirection = 0; private native long jni_YGNodeNew(); - public CSSNode() { + public YogaNode() { mNativePointer = jni_YGNodeNew(); if (mNativePointer == 0) { throw new IllegalStateException("Failed to allocate native memory"); @@ -115,13 +115,13 @@ public class CSSNode implements CSSNodeAPI { } @Override - public CSSNode getChildAt(int i) { + public YogaNode getChildAt(int i) { return mChildren.get(i); } private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index); @Override - public void addChildAt(CSSNode child, int i) { + public void addChildAt(YogaNode child, int i) { if (child.mParent != null) { throw new IllegalStateException("Child already has a parent, it must be removed first."); } @@ -136,9 +136,9 @@ public class CSSNode implements CSSNodeAPI { private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer); @Override - public CSSNode removeChildAt(int i) { + public YogaNode removeChildAt(int i) { - final CSSNode child = mChildren.remove(i); + final YogaNode child = mChildren.remove(i); child.mParent = null; jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer); return child; @@ -146,12 +146,12 @@ public class CSSNode implements CSSNodeAPI { @Override public @Nullable - CSSNode getParent() { + YogaNode getParent() { return mParent; } @Override - public int indexOf(CSSNode child) { + public int indexOf(YogaNode child) { return mChildren == null ? -1 : mChildren.indexOf(child); } @@ -187,7 +187,7 @@ public class CSSNode implements CSSNodeAPI { private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer); @Override - public void copyStyle(CSSNode srcNode) { + public void copyStyle(YogaNode srcNode) { jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer); } @@ -508,14 +508,14 @@ public class CSSNode implements CSSNodeAPI { private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc); @Override - public void setMeasureFunction(MeasureFunction measureFunction) { + public void setMeasureFunction(YogaMeasureFunction measureFunction) { mMeasureFunction = measureFunction; jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null); } // Implementation Note: Why this method needs to stay final // - // We cache the jmethodid for this method in CSSLayout code. This means that even if a subclass + // We cache the jmethodid for this method in Yoga code. This means that even if a subclass // were to override measure, we'd still call this implementation from layout code since the // overriding method will have a different jmethodid. This is final to prevent that mistake. @DoNotStrip diff --git a/java/com/facebook/csslayout/CSSNodeAPI.java b/java/com/facebook/csslayout/YogaNodeAPI.java similarity index 78% rename from java/com/facebook/csslayout/CSSNodeAPI.java rename to java/com/facebook/csslayout/YogaNodeAPI.java index 3c13015a..f56401e7 100644 --- a/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/java/com/facebook/csslayout/YogaNodeAPI.java @@ -9,34 +9,22 @@ package com.facebook.csslayout; -public interface CSSNodeAPI { - - interface MeasureFunction { - /** - * Return a value created by MeasureOutput.make(width, height); - */ - long measure( - CSSNodeAPI node, - float width, - YogaMeasureMode widthMode, - float height, - YogaMeasureMode heightMode); - } - +// This only exists for legacy reasons. It will be removed sometime in the near future. +public interface YogaNodeAPI { int getChildCount(); - CSSNodeType getChildAt(int i); - void addChildAt(CSSNodeType child, int i); - CSSNodeType removeChildAt(int i); - CSSNodeType getParent(); - int indexOf(CSSNodeType child); - void setMeasureFunction(MeasureFunction measureFunction); + YogaNodeType getChildAt(int i); + void addChildAt(YogaNodeType child, int i); + YogaNodeType removeChildAt(int i); + YogaNodeType getParent(); + int indexOf(YogaNodeType child); + void setMeasureFunction(YogaMeasureFunction measureFunction); boolean isMeasureDefined(); void calculateLayout(); boolean isDirty(); boolean hasNewLayout(); void dirty(); void markLayoutSeen(); - void copyStyle(CSSNodeType srcNode); + void copyStyle(YogaNodeType srcNode); YogaDirection getStyleDirection(); void setDirection(YogaDirection direction); YogaFlexDirection getFlexDirection(); diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index a7d6d81b..085ba5b9 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -58,7 +58,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node, float height, YGMeasureMode heightMode) { if (auto obj = YGNodeJobject(node)->lockLocal()) { - static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode") + static auto measureFunc = findClassLocal("com/facebook/csslayout/YogaNode") ->getMethod("measure"); YGTransferLayoutDirection(node, obj); @@ -89,7 +89,7 @@ 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") + static auto logFunc = findClassLocal("com/facebook/csslayout/YogaLogger") ->getMethod, jstring)>("log"); static auto logLevelFromInt = @@ -261,7 +261,7 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); jint JNI_OnLoad(JavaVM *vm, void *) { return initialize(vm, [] { - registerNatives("com/facebook/csslayout/CSSNode", + registerNatives("com/facebook/csslayout/YogaNode", { YGMakeNativeMethod(jni_YGNodeNew), YGMakeNativeMethod(jni_YGNodeFree), diff --git a/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java index 0d135b84..743d1ccc 100644 --- a/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertEquals; public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -58,11 +58,11 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_end_bottom() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.END, 10f); root_child0.setPosition(YogaEdge.BOTTOM, 10f); @@ -98,11 +98,11 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_start_top_end_bottom() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -138,11 +138,11 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_width_height_start_top_end_bottom() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 10f); root_child0.setPosition(YogaEdge.TOP, 10f); @@ -180,19 +180,19 @@ public class YGAbsolutePositionTest { @Test public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setOverflow(YogaOverflow.HIDDEN); root.setWidth(50f); root.setHeight(50f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.START, 0f); root_child0.setPosition(YogaEdge.TOP, 0f); root.addChildAt(root_child0, 0); - final CSSNode root_child0_child0 = new CSSNode(); + final YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.setWidth(100f); root_child0_child0.setHeight(100f); root_child0.addChildAt(root_child0_child0, 0); @@ -235,7 +235,7 @@ public class YGAbsolutePositionTest { @Test public void test_absolute_layout_within_border() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setMargin(YogaEdge.LEFT, 10f); root.setMargin(YogaEdge.TOP, 10f); root.setMargin(YogaEdge.RIGHT, 10f); @@ -251,7 +251,7 @@ public class YGAbsolutePositionTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPositionType(YogaPositionType.ABSOLUTE); root_child0.setPosition(YogaEdge.LEFT, 0f); root_child0.setPosition(YogaEdge.TOP, 0f); @@ -259,7 +259,7 @@ public class YGAbsolutePositionTest { root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setPositionType(YogaPositionType.ABSOLUTE); root_child1.setPosition(YogaEdge.RIGHT, 0f); root_child1.setPosition(YogaEdge.BOTTOM, 0f); diff --git a/java/tests/com/facebook/csslayout/YGAlignContentTest.java b/java/tests/com/facebook/csslayout/YGAlignContentTest.java index c60b0fef..c135cfdf 100644 --- a/java/tests/com/facebook/csslayout/YGAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignContentTest.java @@ -18,32 +18,32 @@ import static org.junit.Assert.assertEquals; public class YGAlignContentTest { @Test public void test_align_content_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final CSSNode root_child4 = new CSSNode(); + final YogaNode root_child4 = new YogaNode(); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -116,33 +116,33 @@ public class YGAlignContentTest { @Test public void test_align_content_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignContent(YogaAlign.FLEX_END); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final CSSNode root_child4 = new CSSNode(); + final YogaNode root_child4 = new YogaNode(); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -215,33 +215,33 @@ public class YGAlignContentTest { @Test public void test_align_content_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignContent(YogaAlign.CENTER); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(50f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(50f); root_child3.setHeight(10f); root.addChildAt(root_child3, 3); - final CSSNode root_child4 = new CSSNode(); + final YogaNode root_child4 = new YogaNode(); root_child4.setWidth(50f); root_child4.setHeight(10f); root.addChildAt(root_child4, 4); @@ -314,29 +314,29 @@ public class YGAlignContentTest { @Test public void test_align_content_stretch() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignContent(YogaAlign.STRETCH); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(50f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(50f); root.addChildAt(root_child3, 3); - final CSSNode root_child4 = new CSSNode(); + final YogaNode root_child4 = new YogaNode(); root_child4.setWidth(50f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/csslayout/YGAlignItemsTest.java b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java index df922b98..6e070a34 100644 --- a/java/tests/com/facebook/csslayout/YGAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertEquals; public class YGAlignItemsTest { @Test public void test_align_items_stretch() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -54,12 +54,12 @@ public class YGAlignItemsTest { @Test public void test_align_items_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignItems(YogaAlign.CENTER); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -92,12 +92,12 @@ public class YGAlignItemsTest { @Test public void test_align_items_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -130,12 +130,12 @@ public class YGAlignItemsTest { @Test public void test_align_items_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); diff --git a/java/tests/com/facebook/csslayout/YGAlignSelfTest.java b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java index f5e3d0d5..4cd7fd94 100644 --- a/java/tests/com/facebook/csslayout/YGAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertEquals; public class YGAlignSelfTest { @Test public void test_align_self_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setAlignSelf(YogaAlign.CENTER); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -56,11 +56,11 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -94,11 +94,11 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setAlignSelf(YogaAlign.FLEX_START); root_child0.setWidth(10f); root_child0.setHeight(10f); @@ -132,12 +132,12 @@ public class YGAlignSelfTest { @Test public void test_align_self_flex_end_override_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignItems(YogaAlign.FLEX_START); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setAlignSelf(YogaAlign.FLEX_END); root_child0.setWidth(10f); root_child0.setHeight(10f); diff --git a/java/tests/com/facebook/csslayout/YGBorderTest.java b/java/tests/com/facebook/csslayout/YGBorderTest.java index 8973ec93..2d660f2b 100644 --- a/java/tests/com/facebook/csslayout/YGBorderTest.java +++ b/java/tests/com/facebook/csslayout/YGBorderTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; public class YGBorderTest { @Test public void test_border_no_size() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -42,13 +42,13 @@ public class YGBorderTest { @Test public void test_border_container_match_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); root.setBorder(YogaEdge.BOTTOM, 10f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -81,7 +81,7 @@ public class YGBorderTest { @Test public void test_border_flex_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -89,7 +89,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -122,7 +122,7 @@ public class YGBorderTest { @Test public void test_border_stretch_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setBorder(YogaEdge.LEFT, 10f); root.setBorder(YogaEdge.TOP, 10f); root.setBorder(YogaEdge.RIGHT, 10f); @@ -130,7 +130,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -162,7 +162,7 @@ public class YGBorderTest { @Test public void test_border_center_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setBorder(YogaEdge.START, 10f); @@ -171,7 +171,7 @@ public class YGBorderTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); diff --git a/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java index 350b3081..0e24b26c 100644 --- a/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java @@ -18,18 +18,18 @@ import static org.junit.Assert.assertEquals; public class YGFlexDirectionTest { @Test public void test_flex_direction_column_no_height() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -81,19 +81,19 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row_no_width() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -145,19 +145,19 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -209,20 +209,20 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -274,20 +274,20 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_column_reverse() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -339,20 +339,20 @@ public class YGFlexDirectionTest { @Test public void test_flex_direction_row_reverse() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW_REVERSE); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/csslayout/YGFlexTest.java b/java/tests/com/facebook/csslayout/YGFlexTest.java index fa408766..11508e2f 100644 --- a/java/tests/com/facebook/csslayout/YGFlexTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexTest.java @@ -18,16 +18,16 @@ import static org.junit.Assert.assertEquals; public class YGFlexTest { @Test public void test_flex_basis_flex_grow_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -69,17 +69,17 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_grow_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -121,16 +121,16 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_shrink_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -172,17 +172,17 @@ public class YGFlexTest { @Test public void test_flex_basis_flex_shrink_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexBasis(50f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -224,21 +224,21 @@ public class YGFlexTest { @Test public void test_flex_shrink_to_zero() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setHeight(75f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexShrink(1f); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -291,22 +291,22 @@ public class YGFlexTest { @Test public void test_flex_basis_overrides_main_size() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -359,14 +359,14 @@ public class YGFlexTest { @Test public void test_flex_grow_shrink_at_most() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root.addChildAt(root_child0, 0); - final CSSNode root_child0_child0 = new CSSNode(); + final YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexShrink(1f); root_child0.addChildAt(root_child0_child0, 0); diff --git a/java/tests/com/facebook/csslayout/YGFlexWrapTest.java b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java index b3432c43..c05f1f55 100644 --- a/java/tests/com/facebook/csslayout/YGFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java @@ -18,26 +18,26 @@ import static org.junit.Assert.assertEquals; public class YGFlexWrapTest { @Test public void test_wrap_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWrap(YogaWrap.WRAP); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(30f); root_child0.setHeight(30f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(30f); root_child1.setHeight(30f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -100,27 +100,27 @@ public class YGFlexWrapTest { @Test public void test_wrap_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(30f); root_child0.setHeight(30f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(30f); root_child1.setHeight(30f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -183,28 +183,28 @@ public class YGFlexWrapTest { @Test public void test_wrap_row_align_items_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.FLEX_END); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); @@ -267,28 +267,28 @@ public class YGFlexWrapTest { @Test public void test_wrap_row_align_items_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setAlignItems(YogaAlign.CENTER); root.setWrap(YogaWrap.WRAP); root.setWidth(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(30f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(30f); root_child1.setHeight(20f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(30f); root_child2.setHeight(30f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setWidth(30f); root_child3.setHeight(30f); root.addChildAt(root_child3, 3); diff --git a/java/tests/com/facebook/csslayout/YGJustifyContentTest.java b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java index 49637ead..8dc6d078 100644 --- a/java/tests/com/facebook/csslayout/YGJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java @@ -18,20 +18,20 @@ import static org.junit.Assert.assertEquals; public class YGJustifyContentTest { @Test public void test_justify_content_row_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -83,21 +83,21 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -149,21 +149,21 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -215,21 +215,21 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_space_between() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -281,21 +281,21 @@ public class YGJustifyContentTest { @Test public void test_justify_content_row_space_around() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -347,18 +347,18 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_flex_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -410,20 +410,20 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_flex_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -475,20 +475,20 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_center() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -540,20 +540,20 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_space_between() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.SPACE_BETWEEN); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -605,20 +605,20 @@ public class YGJustifyContentTest { @Test public void test_justify_content_column_space_around() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.SPACE_AROUND); root.setWidth(102f); root.setHeight(102f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/csslayout/YGMarginTest.java b/java/tests/com/facebook/csslayout/YGMarginTest.java index 8ee1a0e9..0f2cae7a 100644 --- a/java/tests/com/facebook/csslayout/YGMarginTest.java +++ b/java/tests/com/facebook/csslayout/YGMarginTest.java @@ -18,12 +18,12 @@ import static org.junit.Assert.assertEquals; public class YGMarginTest { @Test public void test_margin_start() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setMargin(YogaEdge.START, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -56,11 +56,11 @@ public class YGMarginTest { @Test public void test_margin_top() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setMargin(YogaEdge.TOP, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -93,13 +93,13 @@ public class YGMarginTest { @Test public void test_margin_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setMargin(YogaEdge.END, 10f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -132,12 +132,12 @@ public class YGMarginTest { @Test public void test_margin_bottom() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.FLEX_END); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setMargin(YogaEdge.BOTTOM, 10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -170,12 +170,12 @@ public class YGMarginTest { @Test public void test_margin_and_flex_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.START, 10f); root.addChildAt(root_child0, 0); @@ -208,11 +208,11 @@ public class YGMarginTest { @Test public void test_margin_and_flex_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.TOP, 10f); root.addChildAt(root_child0, 0); @@ -245,12 +245,12 @@ public class YGMarginTest { @Test public void test_margin_and_stretch_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.TOP, 10f); root.addChildAt(root_child0, 0); @@ -283,11 +283,11 @@ public class YGMarginTest { @Test public void test_margin_and_stretch_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMargin(YogaEdge.START, 10f); root.addChildAt(root_child0, 0); @@ -320,16 +320,16 @@ public class YGMarginTest { @Test public void test_margin_with_sibling_row() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -371,15 +371,15 @@ public class YGMarginTest { @Test public void test_margin_with_sibling_column() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); diff --git a/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java index 6f95748b..9dc7ce30 100644 --- a/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertEquals; public class YGMinMaxDimensionTest { @Test public void test_max_width() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setMaxWidth(50f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -55,12 +55,12 @@ public class YGMinMaxDimensionTest { @Test public void test_max_height() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setMaxHeight(50f); root.addChildAt(root_child0, 0); @@ -93,16 +93,16 @@ public class YGMinMaxDimensionTest { @Test public void test_min_height() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMinHeight(60f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -144,17 +144,17 @@ public class YGMinMaxDimensionTest { @Test public void test_min_width() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setMinWidth(60f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); root.setDirection(YogaDirection.LTR); @@ -196,13 +196,13 @@ public class YGMinMaxDimensionTest { @Test public void test_justify_content_min_max() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.CENTER); root.setWidth(100f); root.setMinHeight(100f); root.setMaxHeight(200f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); @@ -235,13 +235,13 @@ public class YGMinMaxDimensionTest { @Test public void test_align_items_min_max() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setAlignItems(YogaAlign.CENTER); root.setMinWidth(100f); root.setMaxWidth(200f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(60f); root_child0.setHeight(60f); root.addChildAt(root_child0, 0); @@ -274,22 +274,22 @@ public class YGMinMaxDimensionTest { @Test public void test_justify_content_overflow_min_max() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.CENTER); root.setMinHeight(100f); root.setMaxHeight(110f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(50f); root_child0.setHeight(50f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setWidth(50f); root_child1.setHeight(50f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setWidth(50f); root_child2.setHeight(50f); root.addChildAt(root_child2, 2); @@ -342,16 +342,16 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_max_width() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(200f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(100f); root.addChildAt(root_child0, 0); - final CSSNode root_child0_child0 = new CSSNode(); + final YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); @@ -394,16 +394,16 @@ public class YGMinMaxDimensionTest { @Test public void test_flex_grow_within_constrained_max_width() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(200f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0.setMaxWidth(300f); root.addChildAt(root_child0, 0); - final CSSNode root_child0_child0 = new CSSNode(); + final YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setHeight(20f); root_child0.addChildAt(root_child0_child0, 0); diff --git a/java/tests/com/facebook/csslayout/YGPaddingTest.java b/java/tests/com/facebook/csslayout/YGPaddingTest.java index b8c31960..2ea21f69 100644 --- a/java/tests/com/facebook/csslayout/YGPaddingTest.java +++ b/java/tests/com/facebook/csslayout/YGPaddingTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; public class YGPaddingTest { @Test public void test_padding_no_size() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -42,13 +42,13 @@ public class YGPaddingTest { @Test public void test_padding_container_match_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); root.setPadding(YogaEdge.BOTTOM, 10); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -81,7 +81,7 @@ public class YGPaddingTest { @Test public void test_padding_flex_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -89,7 +89,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setWidth(10f); root.addChildAt(root_child0, 0); @@ -122,7 +122,7 @@ public class YGPaddingTest { @Test public void test_padding_stretch_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPadding(YogaEdge.LEFT, 10); root.setPadding(YogaEdge.TOP, 10); root.setPadding(YogaEdge.RIGHT, 10); @@ -130,7 +130,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); root.setDirection(YogaDirection.LTR); @@ -162,7 +162,7 @@ public class YGPaddingTest { @Test public void test_padding_center_child() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.CENTER); root.setAlignItems(YogaAlign.CENTER); root.setPadding(YogaEdge.START, 10); @@ -171,7 +171,7 @@ public class YGPaddingTest { root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setWidth(10f); root_child0.setHeight(10f); root.addChildAt(root_child0, 0); @@ -204,13 +204,13 @@ public class YGPaddingTest { @Test public void test_child_with_padding_align_end() { - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setJustifyContent(YogaJustify.FLEX_END); root.setAlignItems(YogaAlign.FLEX_END); root.setWidth(200f); root.setHeight(200f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setPadding(YogaEdge.LEFT, 20); root_child0.setPadding(YogaEdge.TOP, 20); root_child0.setPadding(YogaEdge.RIGHT, 20); diff --git a/java/tests/com/facebook/csslayout/YGRoundingTest.java b/java/tests/com/facebook/csslayout/YGRoundingTest.java index dfe2d4ef..ae478b9e 100644 --- a/java/tests/com/facebook/csslayout/YGRoundingTest.java +++ b/java/tests/com/facebook/csslayout/YGRoundingTest.java @@ -18,22 +18,22 @@ import static org.junit.Assert.assertEquals; public class YGRoundingTest { @Test public void test_rounding_flex_basis_flex_grow_row_width_of_100() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(100f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -82,35 +82,35 @@ public class YGRoundingTest { assertEquals(33f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_grow_row_prime_number_width() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(113f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root.addChildAt(root_child2, 2); - final CSSNode root_child3 = new CSSNode(); + final YogaNode root_child3 = new YogaNode(); root_child3.setFlexGrow(1f); root.addChildAt(root_child3, 3); - final CSSNode root_child4 = new CSSNode(); + final YogaNode root_child4 = new YogaNode(); root_child4.setFlexGrow(1f); root.addChildAt(root_child4, 4); root.setDirection(YogaDirection.LTR); @@ -179,28 +179,28 @@ public class YGRoundingTest { assertEquals(23f, root_child4.getLayoutWidth(), 0.0f); assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_flex_shrink_row() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setFlexDirection(YogaFlexDirection.ROW); root.setWidth(101f); root.setHeight(100f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexShrink(1f); root_child0.setFlexBasis(100f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexBasis(25f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexBasis(25f); root.addChildAt(root_child2, 2); root.setDirection(YogaDirection.LTR); @@ -249,29 +249,29 @@ public class YGRoundingTest { assertEquals(25f, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_flex_basis_overrides_main_size() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(113f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -321,29 +321,29 @@ public class YGRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(87.4f); root.setHeight(113.4f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1.6f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); @@ -393,43 +393,43 @@ public class YGRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_total_fractial_nested() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(87.4f); root.setHeight(113.4f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(0.7f); root_child0.setFlexBasis(50.3f); root_child0.setHeight(20.3f); root.addChildAt(root_child0, 0); - final CSSNode root_child0_child0 = new CSSNode(); + final YogaNode root_child0_child0 = new YogaNode(); root_child0_child0.setFlexGrow(1f); root_child0_child0.setFlexBasis(0.3f); root_child0_child0.setPosition(YogaEdge.BOTTOM, 13.3f); root_child0_child0.setHeight(9.9f); root_child0.addChildAt(root_child0_child0, 0); - final CSSNode root_child0_child1 = new CSSNode(); + final YogaNode root_child0_child1 = new YogaNode(); root_child0_child1.setFlexGrow(4f); root_child0_child1.setFlexBasis(0.3f); root_child0_child1.setPosition(YogaEdge.TOP, 13.3f); root_child0_child1.setHeight(1.1f); root_child0.addChildAt(root_child0_child1, 1); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1.6f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1.1f); root_child2.setHeight(10.7f); root.addChildAt(root_child2, 2); @@ -499,29 +499,29 @@ public class YGRoundingTest { assertEquals(87f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_1() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(113.4f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -571,29 +571,29 @@ public class YGRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_2() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setWidth(100f); root.setHeight(113.6f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -643,30 +643,30 @@ public class YGRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(25f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_3() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPosition(YogaEdge.TOP, 0.3f); root.setWidth(100f); root.setHeight(113.4f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -716,30 +716,30 @@ public class YGRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } @Test public void test_rounding_fractial_input_4() { - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true); - final CSSNode root = new CSSNode(); + final YogaNode root = new YogaNode(); root.setPosition(YogaEdge.TOP, 0.7f); root.setWidth(100f); root.setHeight(113.4f); - final CSSNode root_child0 = new CSSNode(); + final YogaNode root_child0 = new YogaNode(); root_child0.setFlexGrow(1f); root_child0.setFlexBasis(50f); root_child0.setHeight(20f); root.addChildAt(root_child0, 0); - final CSSNode root_child1 = new CSSNode(); + final YogaNode root_child1 = new YogaNode(); root_child1.setFlexGrow(1f); root_child1.setHeight(10f); root.addChildAt(root_child1, 1); - final CSSNode root_child2 = new CSSNode(); + final YogaNode root_child2 = new YogaNode(); root_child2.setFlexGrow(1f); root_child2.setHeight(10f); root.addChildAt(root_child2, 2); @@ -789,7 +789,7 @@ public class YGRoundingTest { assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); assertEquals(24f, root_child2.getLayoutHeight(), 0.0f); - CSSNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); + YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false); } } diff --git a/java/tests/com/facebook/csslayout/YogaNodeTest.java b/java/tests/com/facebook/csslayout/YogaNodeTest.java index 9a39d052..3dc8339e 100644 --- a/java/tests/com/facebook/csslayout/YogaNodeTest.java +++ b/java/tests/com/facebook/csslayout/YogaNodeTest.java @@ -18,22 +18,22 @@ public class YogaNodeTest { @Test public void testInit() { - final int refCount = CSSNode.jni_YGNodeGetInstanceCount(); - final CSSNode node = new CSSNode(); - assertEquals(refCount + 1, CSSNode.jni_YGNodeGetInstanceCount()); + final int refCount = YogaNode.jni_YGNodeGetInstanceCount(); + final YogaNode node = new YogaNode(); + assertEquals(refCount + 1, YogaNode.jni_YGNodeGetInstanceCount()); } @Test public void testMeasure() { - final CSSNode node = new CSSNode(); - node.setMeasureFunction(new CSSNodeAPI.MeasureFunction() { + final YogaNode node = new YogaNode(); + node.setMeasureFunction(new YogaMeasureFunction() { public long measure( - CSSNodeAPI node, + YogaNodeAPI node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { - return MeasureOutput.make(100, 100); + return YogaMeasureOutput.make(100, 100); } }); node.calculateLayout(); @@ -46,39 +46,39 @@ public class YogaNodeTest { @Test public void testLogger() { - CSSNode.setLogger(new CSSLogger() { + YogaNode.setLogger(new YogaLogger() { public void log(YogaLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello"); + YogaNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello"); assertEquals(YogaLogLevel.DEBUG, mLogLevel); assertEquals("Hello", mLogMessage); } @Test public void testUpdateLogger() { - CSSNode.setLogger(new CSSLogger() { + YogaNode.setLogger(new YogaLogger() { public void log(YogaLogLevel level, String message) {} }); - CSSNode.setLogger(new CSSLogger() { + YogaNode.setLogger(new YogaLogger() { public void log(YogaLogLevel level, String message) { mLogLevel = level; mLogMessage = message; } }); - CSSNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox"); + YogaNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox"); assertEquals(YogaLogLevel.VERBOSE, mLogLevel); assertEquals("Flexbox", mLogMessage); } @Test public void testCopyStyle() { - final CSSNode node0 = new CSSNode(); + final YogaNode node0 = new YogaNode(); assertTrue(YogaConstants.isUndefined(node0.getMaxHeight())); - final CSSNode node1 = new CSSNode(); + final YogaNode node1 = new YogaNode(); node1.setMaxHeight(100); node0.copyStyle(node1); From 1b7ae2ed3dc2c354763f5aa20686412a38e75d02 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 5 Dec 2016 02:56:20 -0800 Subject: [PATCH 099/108] Update java package name to yoga Summary: Update package name of java code to refer to yoga instead of csslayout. Still need to change the name of the folder where this code resides but that requires update github sync scripts etc so it is safer and easier to split these diffs apart. Differential Revision: D4271420 fbshipit-source-id: b3cf150569a2331868410339cd19e5c694f2059e --- enums.py | 2 +- gentest/gentest-java.js | 2 +- java/com/facebook/csslayout/YogaAlign.java | 2 +- java/com/facebook/csslayout/YogaConstants.java | 2 +- java/com/facebook/csslayout/YogaDimension.java | 2 +- java/com/facebook/csslayout/YogaDirection.java | 2 +- java/com/facebook/csslayout/YogaEdge.java | 2 +- java/com/facebook/csslayout/YogaExperimentalFeature.java | 2 +- java/com/facebook/csslayout/YogaFlexDirection.java | 2 +- java/com/facebook/csslayout/YogaJustify.java | 2 +- java/com/facebook/csslayout/YogaLogLevel.java | 2 +- java/com/facebook/csslayout/YogaLogger.java | 2 +- java/com/facebook/csslayout/YogaMeasureFunction.java | 2 +- java/com/facebook/csslayout/YogaMeasureMode.java | 2 +- java/com/facebook/csslayout/YogaMeasureOutput.java | 2 +- java/com/facebook/csslayout/YogaNode.java | 2 +- java/com/facebook/csslayout/YogaNodeAPI.java | 2 +- java/com/facebook/csslayout/YogaOverflow.java | 2 +- java/com/facebook/csslayout/YogaPositionType.java | 2 +- java/com/facebook/csslayout/YogaPrintOptions.java | 2 +- java/com/facebook/csslayout/YogaWrap.java | 2 +- java/jni/YGJNI.cpp | 8 ++++---- .../com/facebook/csslayout/YGAbsolutePositionTest.java | 2 +- java/tests/com/facebook/csslayout/YGAlignContentTest.java | 2 +- java/tests/com/facebook/csslayout/YGAlignItemsTest.java | 2 +- java/tests/com/facebook/csslayout/YGAlignSelfTest.java | 2 +- java/tests/com/facebook/csslayout/YGBorderTest.java | 2 +- .../tests/com/facebook/csslayout/YGFlexDirectionTest.java | 2 +- java/tests/com/facebook/csslayout/YGFlexTest.java | 2 +- java/tests/com/facebook/csslayout/YGFlexWrapTest.java | 2 +- .../com/facebook/csslayout/YGJustifyContentTest.java | 2 +- java/tests/com/facebook/csslayout/YGMarginTest.java | 2 +- .../com/facebook/csslayout/YGMinMaxDimensionTest.java | 2 +- java/tests/com/facebook/csslayout/YGPaddingTest.java | 2 +- java/tests/com/facebook/csslayout/YGRoundingTest.java | 2 +- java/tests/com/facebook/csslayout/YogaNodeTest.java | 2 +- 36 files changed, 39 insertions(+), 39 deletions(-) diff --git a/enums.py b/enums.py index 00dbdbc7..a94aef4e 100644 --- a/enums.py +++ b/enums.py @@ -134,7 +134,7 @@ with open(root + '/CSSLayout/YGEnums.h', 'w') as f: for name, values in ENUMS.items(): with open(root + '/java/com/facebook/csslayout/Yoga%s.java' % name, 'w') as f: f.write(LICENSE) - f.write('package com.facebook.csslayout;\n\n') + f.write('package com.facebook.yoga;\n\n') f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n') f.write('@DoNotStrip\n') f.write('public enum Yoga%s {\n' % name) diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 0ae39fa7..7034c617 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -28,7 +28,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { emitPrologue:{value:function() { this.push([ - 'package com.facebook.csslayout;', + 'package com.facebook.yoga;', '', 'import org.junit.Test;', '', diff --git a/java/com/facebook/csslayout/YogaAlign.java b/java/com/facebook/csslayout/YogaAlign.java index 0ad38450..74bcde73 100644 --- a/java/com/facebook/csslayout/YogaAlign.java +++ b/java/com/facebook/csslayout/YogaAlign.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaConstants.java b/java/com/facebook/csslayout/YogaConstants.java index 03db3feb..93dc9f81 100644 --- a/java/com/facebook/csslayout/YogaConstants.java +++ b/java/com/facebook/csslayout/YogaConstants.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; public class YogaConstants { diff --git a/java/com/facebook/csslayout/YogaDimension.java b/java/com/facebook/csslayout/YogaDimension.java index a73f49c8..dfa3c093 100644 --- a/java/com/facebook/csslayout/YogaDimension.java +++ b/java/com/facebook/csslayout/YogaDimension.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaDirection.java b/java/com/facebook/csslayout/YogaDirection.java index 2c0473aa..f0955bd7 100644 --- a/java/com/facebook/csslayout/YogaDirection.java +++ b/java/com/facebook/csslayout/YogaDirection.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaEdge.java b/java/com/facebook/csslayout/YogaEdge.java index 811297f0..8c6c7a74 100644 --- a/java/com/facebook/csslayout/YogaEdge.java +++ b/java/com/facebook/csslayout/YogaEdge.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaExperimentalFeature.java b/java/com/facebook/csslayout/YogaExperimentalFeature.java index f0d91f0b..19c540ca 100644 --- a/java/com/facebook/csslayout/YogaExperimentalFeature.java +++ b/java/com/facebook/csslayout/YogaExperimentalFeature.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaFlexDirection.java b/java/com/facebook/csslayout/YogaFlexDirection.java index b16128db..d01cc96a 100644 --- a/java/com/facebook/csslayout/YogaFlexDirection.java +++ b/java/com/facebook/csslayout/YogaFlexDirection.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaJustify.java b/java/com/facebook/csslayout/YogaJustify.java index eb328dd4..be481bf3 100644 --- a/java/com/facebook/csslayout/YogaJustify.java +++ b/java/com/facebook/csslayout/YogaJustify.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaLogLevel.java b/java/com/facebook/csslayout/YogaLogLevel.java index 75d74e08..b6b33caa 100644 --- a/java/com/facebook/csslayout/YogaLogLevel.java +++ b/java/com/facebook/csslayout/YogaLogLevel.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaLogger.java b/java/com/facebook/csslayout/YogaLogger.java index 82bd19b6..a856b7be 100644 --- a/java/com/facebook/csslayout/YogaLogger.java +++ b/java/com/facebook/csslayout/YogaLogger.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaMeasureFunction.java b/java/com/facebook/csslayout/YogaMeasureFunction.java index 84a48521..6570e5b5 100644 --- a/java/com/facebook/csslayout/YogaMeasureFunction.java +++ b/java/com/facebook/csslayout/YogaMeasureFunction.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaMeasureMode.java b/java/com/facebook/csslayout/YogaMeasureMode.java index 6ea9d038..68fb6c5d 100644 --- a/java/com/facebook/csslayout/YogaMeasureMode.java +++ b/java/com/facebook/csslayout/YogaMeasureMode.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaMeasureOutput.java b/java/com/facebook/csslayout/YogaMeasureOutput.java index 6c968008..7bb845a0 100644 --- a/java/com/facebook/csslayout/YogaMeasureOutput.java +++ b/java/com/facebook/csslayout/YogaMeasureOutput.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; /** * Helpers for building measure output value. diff --git a/java/com/facebook/csslayout/YogaNode.java b/java/com/facebook/csslayout/YogaNode.java index 99314b02..2aa11faa 100644 --- a/java/com/facebook/csslayout/YogaNode.java +++ b/java/com/facebook/csslayout/YogaNode.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import javax.annotation.Nullable; diff --git a/java/com/facebook/csslayout/YogaNodeAPI.java b/java/com/facebook/csslayout/YogaNodeAPI.java index f56401e7..cb3b5be8 100644 --- a/java/com/facebook/csslayout/YogaNodeAPI.java +++ b/java/com/facebook/csslayout/YogaNodeAPI.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; // This only exists for legacy reasons. It will be removed sometime in the near future. public interface YogaNodeAPI { diff --git a/java/com/facebook/csslayout/YogaOverflow.java b/java/com/facebook/csslayout/YogaOverflow.java index 0fa04bb4..d0509e24 100644 --- a/java/com/facebook/csslayout/YogaOverflow.java +++ b/java/com/facebook/csslayout/YogaOverflow.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaPositionType.java b/java/com/facebook/csslayout/YogaPositionType.java index 0215c627..fe2d4fd2 100644 --- a/java/com/facebook/csslayout/YogaPositionType.java +++ b/java/com/facebook/csslayout/YogaPositionType.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaPrintOptions.java b/java/com/facebook/csslayout/YogaPrintOptions.java index fae22f0a..dae28660 100644 --- a/java/com/facebook/csslayout/YogaPrintOptions.java +++ b/java/com/facebook/csslayout/YogaPrintOptions.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/com/facebook/csslayout/YogaWrap.java b/java/com/facebook/csslayout/YogaWrap.java index 8a371d5e..91cc3d5a 100644 --- a/java/com/facebook/csslayout/YogaWrap.java +++ b/java/com/facebook/csslayout/YogaWrap.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index 085ba5b9..2e9fd99d 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -58,7 +58,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node, float height, YGMeasureMode heightMode) { if (auto obj = YGNodeJobject(node)->lockLocal()) { - static auto measureFunc = findClassLocal("com/facebook/csslayout/YogaNode") + static auto measureFunc = findClassLocal("com/facebook/yoga/YogaNode") ->getMethod("measure"); YGTransferLayoutDirection(node, obj); @@ -81,7 +81,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node, } struct JYogaLogLevel : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;"; + static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;"; }; static global_ref *jLogger; @@ -89,7 +89,7 @@ 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/YogaLogger") + static auto logFunc = findClassLocal("com/facebook/yoga/YogaLogger") ->getMethod, jstring)>("log"); static auto logLevelFromInt = @@ -261,7 +261,7 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); jint JNI_OnLoad(JavaVM *vm, void *) { return initialize(vm, [] { - registerNatives("com/facebook/csslayout/YogaNode", + registerNatives("com/facebook/yoga/YogaNode", { YGMakeNativeMethod(jni_YGNodeNew), YGMakeNativeMethod(jni_YGNodeFree), diff --git a/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java index 743d1ccc..bdfaf0e1 100644 --- a/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGAlignContentTest.java b/java/tests/com/facebook/csslayout/YGAlignContentTest.java index c135cfdf..c0f6afa5 100644 --- a/java/tests/com/facebook/csslayout/YGAlignContentTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignContentTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGAlignItemsTest.java b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java index 6e070a34..c7fd7a2a 100644 --- a/java/tests/com/facebook/csslayout/YGAlignItemsTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignItemsTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGAlignSelfTest.java b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java index 4cd7fd94..f8dc750b 100644 --- a/java/tests/com/facebook/csslayout/YGAlignSelfTest.java +++ b/java/tests/com/facebook/csslayout/YGAlignSelfTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGBorderTest.java b/java/tests/com/facebook/csslayout/YGBorderTest.java index 2d660f2b..f264a878 100644 --- a/java/tests/com/facebook/csslayout/YGBorderTest.java +++ b/java/tests/com/facebook/csslayout/YGBorderTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java index 0e24b26c..4a731e17 100644 --- a/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGFlexTest.java b/java/tests/com/facebook/csslayout/YGFlexTest.java index 11508e2f..ca7befd2 100644 --- a/java/tests/com/facebook/csslayout/YGFlexTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGFlexWrapTest.java b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java index c05f1f55..f4772efe 100644 --- a/java/tests/com/facebook/csslayout/YGFlexWrapTest.java +++ b/java/tests/com/facebook/csslayout/YGFlexWrapTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGJustifyContentTest.java b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java index 8dc6d078..19df3a5c 100644 --- a/java/tests/com/facebook/csslayout/YGJustifyContentTest.java +++ b/java/tests/com/facebook/csslayout/YGJustifyContentTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGMarginTest.java b/java/tests/com/facebook/csslayout/YGMarginTest.java index 0f2cae7a..35859473 100644 --- a/java/tests/com/facebook/csslayout/YGMarginTest.java +++ b/java/tests/com/facebook/csslayout/YGMarginTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java index 9dc7ce30..f37a5c54 100644 --- a/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java +++ b/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGPaddingTest.java b/java/tests/com/facebook/csslayout/YGPaddingTest.java index 2ea21f69..22349186 100644 --- a/java/tests/com/facebook/csslayout/YGPaddingTest.java +++ b/java/tests/com/facebook/csslayout/YGPaddingTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YGRoundingTest.java b/java/tests/com/facebook/csslayout/YGRoundingTest.java index ae478b9e..33624b15 100644 --- a/java/tests/com/facebook/csslayout/YGRoundingTest.java +++ b/java/tests/com/facebook/csslayout/YGRoundingTest.java @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; diff --git a/java/tests/com/facebook/csslayout/YogaNodeTest.java b/java/tests/com/facebook/csslayout/YogaNodeTest.java index 3dc8339e..d7c759ea 100644 --- a/java/tests/com/facebook/csslayout/YogaNodeTest.java +++ b/java/tests/com/facebook/csslayout/YogaNodeTest.java @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -package com.facebook.csslayout; +package com.facebook.yoga; import org.junit.Test; From 72cf6806dec92d03bdcd37b6da405f5b1bca65c0 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 5 Dec 2016 04:58:55 -0800 Subject: [PATCH 100/108] Add #pragma once and extern C to YGEnums.h Summary: Makes YGEnums.h header looks like other Yoga headers Reviewed By: gkassabli Differential Revision: D4274156 fbshipit-source-id: 9fa0ae146bb9e5bd40d93fa3c56f83424ebd2bf9 --- CSSLayout/YGEnums.h | 8 ++++++++ enums.py | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CSSLayout/YGEnums.h b/CSSLayout/YGEnums.h index 2a87abf9..85d9d2f9 100644 --- a/CSSLayout/YGEnums.h +++ b/CSSLayout/YGEnums.h @@ -7,6 +7,12 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#pragma once + +#include "YGMacros.h" + +YG_EXTERN_C_BEGIN + typedef enum YGFlexDirection { YGFlexDirectionColumn, YGFlexDirectionColumnReverse, @@ -106,3 +112,5 @@ typedef enum YGAlign { YGAlignStretch, YGAlignCount, } YGAlign; + +YG_EXTERN_C_END diff --git a/enums.py b/enums.py index a94aef4e..e1626f10 100644 --- a/enums.py +++ b/enums.py @@ -116,7 +116,9 @@ root = os.path.dirname(__file__) # write out C header with open(root + '/CSSLayout/YGEnums.h', 'w') as f: f.write(LICENSE) - remaining = len(ENUMS) + f.write('#pragma once\n\n') + f.write('#include "YGMacros.h"\n\n') + f.write('YG_EXTERN_C_BEGIN\n\n') for name, values in ENUMS.items(): f.write('typedef enum YG%s {\n' % name) for value in values: @@ -126,9 +128,8 @@ with open(root + '/CSSLayout/YGEnums.h', 'w') as f: f.write(' YG%s%s,\n' % (name, value)) f.write(' YG%sCount,\n' % name) f.write('} YG%s;\n' % name) - if remaining > 1: - f.write('\n') - remaining = remaining - 1 + f.write('\n') + f.write('YG_EXTERN_C_END\n') # write out java files for name, values in ENUMS.items(): From 901f65ca05d763fd6197f218588d8f48806a31a7 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 5 Dec 2016 08:02:47 -0800 Subject: [PATCH 101/108] Fix prefix typo in YogaKit Summary: Forgot to update this in rename. Reviewed By: dshahidehpour, gkassabli Differential Revision: D4271399 fbshipit-source-id: cf354928a8839a864e9961e091d9f48840a5d4d4 --- YogaKit/UIView+Yoga.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index da22e1b8..0ad7bddc 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -19,7 +19,7 @@ + (void)initialize { - YogaSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); + YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true); } - (instancetype)init From 4710a65f7ae00c1565f4b71a66feb98690e977e3 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 5 Dec 2016 09:35:26 -0800 Subject: [PATCH 102/108] Fix an error initializing needsCrossTrailingPos Summary: https://github.com/facebook/css-layout/pull/259 Reviewed By: gkassabli Differential Revision: D4271422 fbshipit-source-id: e8d72af742d96829684958780eb56e2c375df20c --- CSSLayout/Yoga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSSLayout/Yoga.c b/CSSLayout/Yoga.c index 70afece2..58c43121 100644 --- a/CSSLayout/Yoga.c +++ b/CSSLayout/Yoga.c @@ -2240,7 +2240,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, const bool needsMainTrailingPos = mainAxis == YGFlexDirectionRowReverse || mainAxis == YGFlexDirectionColumnReverse; const bool needsCrossTrailingPos = - YGFlexDirectionRowReverse || crossAxis == YGFlexDirectionColumnReverse; + crossAxis == YGFlexDirectionRowReverse || crossAxis == YGFlexDirectionColumnReverse; // Set trailing position if necessary. if (needsMainTrailingPos || needsCrossTrailingPos) { From 613590b0d8cdc662cc9a5b384c5a3ff6d99552c2 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 5 Dec 2016 12:22:54 -0800 Subject: [PATCH 103/108] Ignore csharp test dependencies which are downloaded on the fly Summary: Running csharp tests should not result in uncommited files. Reviewed By: splhack Differential Revision: D4271411 fbshipit-source-id: abf6c69555ed657356a9426ca37864f8c2eaa78f --- csharp/.gitignore | 7 ++++++- csharp/.hgignore | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/csharp/.gitignore b/csharp/.gitignore index 4e1cd4a5..533ef745 100644 --- a/csharp/.gitignore +++ b/csharp/.gitignore @@ -30,6 +30,11 @@ bld/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* +csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/ +csharp/tests/Facebook.Yoga/YogaTest.dll +csharp/tests/Facebook.Yoga/YogaTest.dll.mdb +csharp/tests/Facebook.Yoga/libyoga.dylib +csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/ # NUNIT *.VisualState.xml @@ -262,4 +267,4 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc diff --git a/csharp/.hgignore b/csharp/.hgignore index 4e1cd4a5..4dd1c600 100644 --- a/csharp/.hgignore +++ b/csharp/.hgignore @@ -34,6 +34,11 @@ bld/ # NUNIT *.VisualState.xml TestResult.xml +csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/ +csharp/tests/Facebook.Yoga/YogaTest.dll +csharp/tests/Facebook.Yoga/YogaTest.dll.mdb +csharp/tests/Facebook.Yoga/libyoga.dylib +csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/ # Build Results of an ATL Project [Dd]ebugPS/ @@ -262,4 +267,4 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc From 40371cbf2d8ade3de39824de1078fc9988d967f4 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 6 Dec 2016 14:37:54 -0800 Subject: [PATCH 104/108] Remove init from api Summary: Both New and Reset already call init internally. No reason to expose this function Reviewed By: gkassabli Differential Revision: D4276177 fbshipit-source-id: c4404d0534f381dfacee0625b2847d38de58e038 --- CSSLayout/Yoga.c | 102 +++++++++++++++++++++++------------------------ CSSLayout/Yoga.h | 1 - 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/CSSLayout/Yoga.c b/CSSLayout/Yoga.c index 58c43121..32d7e489 100644 --- a/CSSLayout/Yoga.c +++ b/CSSLayout/Yoga.c @@ -185,57 +185,7 @@ static inline float YGComputedEdgeValue(const float edges[YGEdgeCount], return defaultValue; } -int32_t gNodeInstanceCount = 0; - -YGNodeRef YGNodeNew(void) { - const YGNodeRef node = gYGCalloc(1, sizeof(YGNode)); - YG_ASSERT(node, "Could not allocate memory for node"); - gNodeInstanceCount++; - - YGNodeInit(node); - return node; -} - -void YGNodeFree(const YGNodeRef node) { - if (node->parent) { - YGNodeListDelete(node->parent->children, node); - node->parent = NULL; - } - - const uint32_t childCount = YGNodeChildCount(node); - for (uint32_t i = 0; i < childCount; i++) { - const YGNodeRef child = YGNodeGetChild(node, i); - child->parent = NULL; - } - - YGNodeListFree(node->children); - gYGFree(node); - gNodeInstanceCount--; -} - -void YGNodeFreeRecursive(const YGNodeRef root) { - while (YGNodeChildCount(root) > 0) { - const YGNodeRef child = YGNodeGetChild(root, 0); - YGNodeRemoveChild(root, child); - YGNodeFreeRecursive(child); - } - YGNodeFree(root); -} - -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"); - - YGNodeListFree(node->children); - memset(node, 0, sizeof(YGNode)); - YGNodeInit(node); -} - -int32_t YGNodeGetInstanceCount(void) { - return gNodeInstanceCount; -} - -void YGNodeInit(const YGNodeRef node) { +static void YGNodeInit(const YGNodeRef node) { node->parent = NULL; node->children = NULL; node->hasNewLayout = true; @@ -289,6 +239,56 @@ void YGNodeInit(const YGNodeRef node) { node->layout.cachedLayout.computedHeight = -1; } +int32_t gNodeInstanceCount = 0; + +YGNodeRef YGNodeNew(void) { + const YGNodeRef node = gYGCalloc(1, sizeof(YGNode)); + YG_ASSERT(node, "Could not allocate memory for node"); + gNodeInstanceCount++; + + YGNodeInit(node); + return node; +} + +void YGNodeFree(const YGNodeRef node) { + if (node->parent) { + YGNodeListDelete(node->parent->children, node); + node->parent = NULL; + } + + const uint32_t childCount = YGNodeChildCount(node); + for (uint32_t i = 0; i < childCount; i++) { + const YGNodeRef child = YGNodeGetChild(node, i); + child->parent = NULL; + } + + YGNodeListFree(node->children); + gYGFree(node); + gNodeInstanceCount--; +} + +void YGNodeFreeRecursive(const YGNodeRef root) { + while (YGNodeChildCount(root) > 0) { + const YGNodeRef child = YGNodeGetChild(root, 0); + YGNodeRemoveChild(root, child); + YGNodeFreeRecursive(child); + } + YGNodeFree(root); +} + +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"); + + YGNodeListFree(node->children); + memset(node, 0, sizeof(YGNode)); + YGNodeInit(node); +} + +int32_t YGNodeGetInstanceCount(void) { + return gNodeInstanceCount; +} + static void YGNodeMarkDirtyInternal(const YGNodeRef node) { if (!node->isDirty) { node->isDirty = true; diff --git a/CSSLayout/Yoga.h b/CSSLayout/Yoga.h index 926a3b94..e41a4cd9 100644 --- a/CSSLayout/Yoga.h +++ b/CSSLayout/Yoga.h @@ -54,7 +54,6 @@ 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); From b11155423c7bad03be0a357510fd8a8c38aa605a Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 7 Dec 2016 05:12:11 -0800 Subject: [PATCH 105/108] Rename directories Reviewed By: gkassabli Differential Revision: D4284681 Summary: Rename csslayout directories to yoga fbshipit-source-id: f0c6855c2c6e4389b7867f48f72cbb697830fc5a --- .travis.yml | 2 +- BUCK | 10 +++++----- YOGA_DEFS | 6 +++--- YogaKit/BUCK | 8 ++++---- YogaKit/UIView+Yoga.h | 2 +- benchmark/BUCK | 2 +- benchmark/YGBenchmark.c | 2 +- csharp/BUCK | 4 ++-- csharp/Facebook.Yoga/Native.cs | 6 +++--- csharp/Yoga/YGInterop.h | 2 +- csharp/Yoga/Yoga.vcxproj | 10 +++++----- csharp/Yoga/Yoga.vcxproj.filters | 10 +++++----- csharp/tests/Facebook.Yoga/test_macos.sh | 2 +- enums.py | 4 ++-- format.sh | 3 +-- gentest/gentest-cpp.js | 2 +- gentest/gentest.rb | 2 +- java/BUCK | 6 +++--- java/com/facebook/proguard/annotations/BUCK | 2 +- .../facebook/{csslayout => yoga}/YogaAlign.java | 0 .../{csslayout => yoga}/YogaConstants.java | 0 .../{csslayout => yoga}/YogaDimension.java | 0 .../{csslayout => yoga}/YogaDirection.java | 0 .../facebook/{csslayout => yoga}/YogaEdge.java | 0 .../YogaExperimentalFeature.java | 0 .../{csslayout => yoga}/YogaFlexDirection.java | 0 .../{csslayout => yoga}/YogaJustify.java | 0 .../{csslayout => yoga}/YogaLogLevel.java | 0 .../facebook/{csslayout => yoga}/YogaLogger.java | 0 .../{csslayout => yoga}/YogaMeasureFunction.java | 0 .../{csslayout => yoga}/YogaMeasureMode.java | 0 .../{csslayout => yoga}/YogaMeasureOutput.java | 0 .../facebook/{csslayout => yoga}/YogaNode.java | 0 .../{csslayout => yoga}/YogaNodeAPI.java | 0 .../{csslayout => yoga}/YogaOverflow.java | 0 .../{csslayout => yoga}/YogaPositionType.java | 0 .../{csslayout => yoga}/YogaPrintOptions.java | 0 .../facebook/{csslayout => yoga}/YogaWrap.java | 0 java/jni/YGJNI.cpp | 2 +- .../YGAbsolutePositionTest.java | 0 .../{csslayout => yoga}/YGAlignContentTest.java | 0 .../{csslayout => yoga}/YGAlignItemsTest.java | 0 .../{csslayout => yoga}/YGAlignSelfTest.java | 0 .../{csslayout => yoga}/YGBorderTest.java | 0 .../{csslayout => yoga}/YGFlexDirectionTest.java | 0 .../facebook/{csslayout => yoga}/YGFlexTest.java | 0 .../{csslayout => yoga}/YGFlexWrapTest.java | 0 .../YGJustifyContentTest.java | 0 .../{csslayout => yoga}/YGMarginTest.java | 0 .../YGMinMaxDimensionTest.java | 0 .../{csslayout => yoga}/YGPaddingTest.java | 0 .../{csslayout => yoga}/YGRoundingTest.java | 0 .../{csslayout => yoga}/YogaNodeTest.java | 0 lib/fb/BUCK | 2 +- lib/gtest/BUCK | 2 +- lib/infer-annotations/BUCK | 2 +- lib/jsr-305/BUCK | 2 +- lib/junit/BUCK | 2 +- lib/soloader/BUCK | 2 +- tests/YGAbsolutePositionTest.cpp | 2 +- tests/YGAlignContentTest.cpp | 2 +- tests/YGAlignItemsTest.cpp | 2 +- tests/YGAlignSelfTest.cpp | 2 +- tests/YGBorderTest.cpp | 2 +- tests/YGDirtyMarkingTest.cpp | 2 +- tests/YGEdgeTest.cpp | 2 +- tests/YGFlexDirectionTest.cpp | 2 +- tests/YGFlexTest.cpp | 2 +- tests/YGFlexWrapTest.cpp | 2 +- tests/YGJustifyContentTest.cpp | 2 +- tests/YGLayoutAspectRatioTest.cpp | 2 +- tests/YGLayoutDefaultValuesTest.cpp | 2 +- tests/YGMarginTest.cpp | 2 +- tests/YGMeasureCacheTest.cpp | 2 +- tests/YGMeasureModeTest.cpp | 2 +- tests/YGMeasureTest.cpp | 2 +- tests/YGMemoryFuncTest.cpp | 2 +- tests/YGMinMaxDimensionTest.cpp | 2 +- tests/YGPaddingTest.cpp | 2 +- tests/YGRelayoutTest.cpp | 2 +- tests/YGRoundingMeasureFuncTest.cpp | 2 +- tests/YGRoundingTest.cpp | 2 +- tests/YGStyleTest.cpp | 2 +- {CSSLayout => yoga}/YGEnums.h | 0 {CSSLayout => yoga}/YGMacros.h | 0 {CSSLayout => yoga}/YGNodeList.c | 0 {CSSLayout => yoga}/YGNodeList.h | 0 {CSSLayout => yoga}/Yoga.c | 16 ++++++++-------- {CSSLayout => yoga}/Yoga.h | 2 +- 89 files changed, 82 insertions(+), 83 deletions(-) rename java/com/facebook/{csslayout => yoga}/YogaAlign.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaConstants.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaDimension.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaDirection.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaEdge.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaExperimentalFeature.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaFlexDirection.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaJustify.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaLogLevel.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaLogger.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaMeasureFunction.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaMeasureMode.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaMeasureOutput.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaNode.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaNodeAPI.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaOverflow.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaPositionType.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaPrintOptions.java (100%) rename java/com/facebook/{csslayout => yoga}/YogaWrap.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGAbsolutePositionTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGAlignContentTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGAlignItemsTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGAlignSelfTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGBorderTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGFlexDirectionTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGFlexTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGFlexWrapTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGJustifyContentTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGMarginTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGMinMaxDimensionTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGPaddingTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YGRoundingTest.java (100%) rename java/tests/com/facebook/{csslayout => yoga}/YogaNodeTest.java (100%) rename {CSSLayout => yoga}/YGEnums.h (100%) rename {CSSLayout => yoga}/YGMacros.h (100%) rename {CSSLayout => yoga}/YGNodeList.c (100%) rename {CSSLayout => yoga}/YGNodeList.h (100%) rename {CSSLayout => yoga}/Yoga.c (99%) rename {CSSLayout => yoga}/Yoga.h (98%) diff --git a/.travis.yml b/.travis.yml index c1ad41cb..618dbb0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: - export PATH=$JAVA_HOME/bin:$PATH script: - - buck test //:CSSLayout + - buck test //:yoga - buck test //java:java - buck test //YogaKit:YogaKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI - sh csharp/tests/Facebook.Yoga/test_macos.sh diff --git a/BUCK b/BUCK index e74a0a6e..7b49825c 100644 --- a/BUCK +++ b/BUCK @@ -24,14 +24,14 @@ COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC'] TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11'] cxx_library( - name = 'CSSLayout', - srcs = glob(['CSSLayout/*.c']), + name = 'yoga', + srcs = glob(['yoga/*.c']), tests=[':tests'], - exported_headers = subdir_glob([('', 'CSSLayout/*.h')]), + exported_headers = subdir_glob([('', 'yoga/*.h')]), header_namespace = '', compiler_flags = COMPILER_FLAGS, deps = [] if THIS_IS_FBOBJC else [ - csslayout_dep('lib/fb:ndklog'), + yoga_dep('lib/fb:ndklog'), ], visibility = ['PUBLIC'], ) @@ -42,7 +42,7 @@ cxx_test( srcs = glob(['tests/*.cpp']), compiler_flags = TEST_COMPILER_FLAGS, deps = [ - ':CSSLayout', + ':yoga', GTEST_TARGET, ], visibility = ['PUBLIC'], diff --git a/YOGA_DEFS b/YOGA_DEFS index 2b4a62c5..137b96fd 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -1,5 +1,5 @@ -CSSLAYOUT_ROOT = '//...' +YOGA_ROOT = '//...' INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations' JSR_305_TARGET = '//lib/jsr-305:jsr-305' JUNIT_TARGET = '//lib/junit:junit' @@ -12,12 +12,12 @@ FBJNI_TARGET = '//lib/fb:fbjni' THIS_IS_FBOBJC = False CXX_LIBRARY_WHITELIST = [ - '//:CSSLayout', + '//:yoga', '//lib/fb:fbjni', '//java:jni', ] -def csslayout_dep(dep): +def yoga_dep(dep): return '//' + dep class allow_unsafe_import: diff --git a/YogaKit/BUCK b/YogaKit/BUCK index fc97569b..4a781038 100644 --- a/YogaKit/BUCK +++ b/YogaKit/BUCK @@ -7,7 +7,7 @@ include_defs('//YOGA_DEFS') -UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ +COMPILER_FLAGS = [ '-fobjc-arc', '-Wconditional-uninitialized', '-Wdangling-else', @@ -29,7 +29,7 @@ UIKIT_CSSLAYOUT_COMPILER_FLAGS = [ apple_library( name = 'YogaKit', - compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, + compiler_flags = COMPILER_FLAGS, tests = [':YogaKitTests'], srcs = glob(['*.m']), exported_headers = glob(['*.h']), @@ -38,14 +38,14 @@ apple_library( '$SDKROOT/System/Library/Frameworks/UIKit.framework', ], deps = [ - csslayout_dep(':CSSLayout'), + yoga_dep(':yoga'), ], visibility = ['PUBLIC'], ) apple_test( name = 'YogaKitTests', - compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS, + compiler_flags = COMPILER_FLAGS, info_plist = 'Tests/Info.plist', srcs = glob(['Tests/**/*.m']), frameworks = [ diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h index 94480da6..97bb2532 100644 --- a/YogaKit/UIView+Yoga.h +++ b/YogaKit/UIView+Yoga.h @@ -8,7 +8,7 @@ */ #import -#import +#import @interface UIView (Yoga) diff --git a/benchmark/BUCK b/benchmark/BUCK index 4fafe0df..1dd388cc 100644 --- a/benchmark/BUCK +++ b/benchmark/BUCK @@ -21,7 +21,7 @@ cxx_binary( '-std=c11', ], deps = [ - csslayout_dep(':CSSLayout'), + yoga_dep(':yoga'), ], visibility = ['PUBLIC'], ) diff --git a/benchmark/YGBenchmark.c b/benchmark/YGBenchmark.c index c326616f..2e816359 100644 --- a/benchmark/YGBenchmark.c +++ b/benchmark/YGBenchmark.c @@ -9,7 +9,7 @@ #include "YGBenchmark.h" -#include +#include static YGSize _measure(YGNodeRef node, float width, diff --git a/csharp/BUCK b/csharp/BUCK index 6219ab85..8223450a 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -6,14 +6,14 @@ # of patent rights can be found in the PATENTS file in the same directory. csharp_library( - name = 'csslibnet46', + name = 'yogalibnet46', dll_name = 'Facebook.Yoga.dll', framework_ver = 'net46', srcs = glob(['**/*.cs']), ) csharp_library( - name = 'csslibnet45', + name = 'yogalibnet45', dll_name = 'Facebook.Yoga.dll', framework_ver = 'net45', srcs = glob(['**/*.cs']), diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 587c0314..7786b8cf 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -28,13 +28,13 @@ namespace Facebook.Yoga public static extern IntPtr YGNodeNew(); [DllImport(DllName)] - public static extern void YGNodeInit(IntPtr cssNode); + public static extern void YGNodeInit(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeFree(IntPtr cssNode); + public static extern void YGNodeFree(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeReset(IntPtr cssNode); + public static extern void YGNodeReset(IntPtr node); [DllImport(DllName)] public static extern int YGNodeGetInstanceCount(); diff --git a/csharp/Yoga/YGInterop.h b/csharp/Yoga/YGInterop.h index b544d3db..7494977f 100644 --- a/csharp/Yoga/YGInterop.h +++ b/csharp/Yoga/YGInterop.h @@ -9,7 +9,7 @@ #pragma once -#include +#include YG_EXTERN_C_BEGIN diff --git a/csharp/Yoga/Yoga.vcxproj b/csharp/Yoga/Yoga.vcxproj index 30d2947d..b3704474 100755 --- a/csharp/Yoga/Yoga.vcxproj +++ b/csharp/Yoga/Yoga.vcxproj @@ -150,16 +150,16 @@ - - - + + + - - + + false diff --git a/csharp/Yoga/Yoga.vcxproj.filters b/csharp/Yoga/Yoga.vcxproj.filters index 415d0824..c3afcf63 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/csharp/tests/Facebook.Yoga/test_macos.sh b/csharp/tests/Facebook.Yoga/test_macos.sh index 9a3ad14f..7df36893 100755 --- a/csharp/tests/Facebook.Yoga/test_macos.sh +++ b/csharp/tests/Facebook.Yoga/test_macos.sh @@ -28,6 +28,6 @@ if [ -d $NUNIT \ rm NUnit-2.6.4.zip fi -clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../CSSLayout/*.c ../../Yoga/YGInterop.cpp +clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../yoga/*.c ../../Yoga/YGInterop.cpp mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll diff --git a/enums.py b/enums.py index e1626f10..d2fc6dc0 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/YGEnums.h', 'w') as f: +with open(root + '/yoga/YGEnums.h', 'w') as f: f.write(LICENSE) f.write('#pragma once\n\n') f.write('#include "YGMacros.h"\n\n') @@ -133,7 +133,7 @@ with open(root + '/CSSLayout/YGEnums.h', 'w') as f: # write out java files for name, values in ENUMS.items(): - with open(root + '/java/com/facebook/csslayout/Yoga%s.java' % name, 'w') as f: + with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f: f.write(LICENSE) f.write('package com.facebook.yoga;\n\n') f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n') diff --git a/format.sh b/format.sh index 01464ab2..c8affc49 100755 --- a/format.sh +++ b/format.sh @@ -29,7 +29,6 @@ clang-format \ SpaceAfterCStyleCast: true, \ UseTab: Never, \ }" "$@" \ - -i $(dirname $0)/CSSLayout/*.{h,c,cpp} \ - $(dirname $0)/tests/CSSLayoutTestUtils/*.{h,c,cpp} \ + -i $(dirname $0)/yoga/*.{h,c,cpp} \ $(dirname $0)/benchmarks/*.{h,c,cpp} \ $(dirname $0)/java/jni/*.{h,c,cpp} diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index f4db36ed..0333dd7c 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -20,7 +20,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { emitPrologue:{value:function() { this.push([ - '#include ', + '#include ', '#include ', '', ]); diff --git a/gentest/gentest.rb b/gentest/gentest.rb index 88191ce0..4293866d 100644 --- a/gentest/gentest.rb +++ b/gentest/gentest.rb @@ -40,7 +40,7 @@ Dir['fixtures/*.html'].each do |file| f.write eval(logs[0].message.sub(/^[^"]*/, '')) f.close - f = File.open("../java/tests/com/facebook/csslayout/#{name}.java", 'w') + f = File.open("../java/tests/com/facebook/yoga/#{name}.java", 'w') f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('YogaTest', name) f.close diff --git a/java/BUCK b/java/BUCK index 3c48166d..70775d15 100644 --- a/java/BUCK +++ b/java/BUCK @@ -24,16 +24,16 @@ cxx_library( deps = [ FBJNI_TARGET, JNI_TARGET, - csslayout_dep(':CSSLayout'), + yoga_dep(':yoga'), ], visibility = ['PUBLIC'], ) java_library( name = 'java', - srcs = glob(['com/facebook/csslayout/*.java']), + srcs = glob(['com/facebook/yoga/*.java']), tests=[ - csslayout_dep('java:tests'), + yoga_dep('java:tests'), ], source = '1.7', target = '1.7', diff --git a/java/com/facebook/proguard/annotations/BUCK b/java/com/facebook/proguard/annotations/BUCK index 86f1b22f..2af11a81 100644 --- a/java/com/facebook/proguard/annotations/BUCK +++ b/java/com/facebook/proguard/annotations/BUCK @@ -13,5 +13,5 @@ java_library( source = '1.7', target = '1.7', deps = [], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/java/com/facebook/csslayout/YogaAlign.java b/java/com/facebook/yoga/YogaAlign.java similarity index 100% rename from java/com/facebook/csslayout/YogaAlign.java rename to java/com/facebook/yoga/YogaAlign.java diff --git a/java/com/facebook/csslayout/YogaConstants.java b/java/com/facebook/yoga/YogaConstants.java similarity index 100% rename from java/com/facebook/csslayout/YogaConstants.java rename to java/com/facebook/yoga/YogaConstants.java diff --git a/java/com/facebook/csslayout/YogaDimension.java b/java/com/facebook/yoga/YogaDimension.java similarity index 100% rename from java/com/facebook/csslayout/YogaDimension.java rename to java/com/facebook/yoga/YogaDimension.java diff --git a/java/com/facebook/csslayout/YogaDirection.java b/java/com/facebook/yoga/YogaDirection.java similarity index 100% rename from java/com/facebook/csslayout/YogaDirection.java rename to java/com/facebook/yoga/YogaDirection.java diff --git a/java/com/facebook/csslayout/YogaEdge.java b/java/com/facebook/yoga/YogaEdge.java similarity index 100% rename from java/com/facebook/csslayout/YogaEdge.java rename to java/com/facebook/yoga/YogaEdge.java diff --git a/java/com/facebook/csslayout/YogaExperimentalFeature.java b/java/com/facebook/yoga/YogaExperimentalFeature.java similarity index 100% rename from java/com/facebook/csslayout/YogaExperimentalFeature.java rename to java/com/facebook/yoga/YogaExperimentalFeature.java diff --git a/java/com/facebook/csslayout/YogaFlexDirection.java b/java/com/facebook/yoga/YogaFlexDirection.java similarity index 100% rename from java/com/facebook/csslayout/YogaFlexDirection.java rename to java/com/facebook/yoga/YogaFlexDirection.java diff --git a/java/com/facebook/csslayout/YogaJustify.java b/java/com/facebook/yoga/YogaJustify.java similarity index 100% rename from java/com/facebook/csslayout/YogaJustify.java rename to java/com/facebook/yoga/YogaJustify.java diff --git a/java/com/facebook/csslayout/YogaLogLevel.java b/java/com/facebook/yoga/YogaLogLevel.java similarity index 100% rename from java/com/facebook/csslayout/YogaLogLevel.java rename to java/com/facebook/yoga/YogaLogLevel.java diff --git a/java/com/facebook/csslayout/YogaLogger.java b/java/com/facebook/yoga/YogaLogger.java similarity index 100% rename from java/com/facebook/csslayout/YogaLogger.java rename to java/com/facebook/yoga/YogaLogger.java diff --git a/java/com/facebook/csslayout/YogaMeasureFunction.java b/java/com/facebook/yoga/YogaMeasureFunction.java similarity index 100% rename from java/com/facebook/csslayout/YogaMeasureFunction.java rename to java/com/facebook/yoga/YogaMeasureFunction.java diff --git a/java/com/facebook/csslayout/YogaMeasureMode.java b/java/com/facebook/yoga/YogaMeasureMode.java similarity index 100% rename from java/com/facebook/csslayout/YogaMeasureMode.java rename to java/com/facebook/yoga/YogaMeasureMode.java diff --git a/java/com/facebook/csslayout/YogaMeasureOutput.java b/java/com/facebook/yoga/YogaMeasureOutput.java similarity index 100% rename from java/com/facebook/csslayout/YogaMeasureOutput.java rename to java/com/facebook/yoga/YogaMeasureOutput.java diff --git a/java/com/facebook/csslayout/YogaNode.java b/java/com/facebook/yoga/YogaNode.java similarity index 100% rename from java/com/facebook/csslayout/YogaNode.java rename to java/com/facebook/yoga/YogaNode.java diff --git a/java/com/facebook/csslayout/YogaNodeAPI.java b/java/com/facebook/yoga/YogaNodeAPI.java similarity index 100% rename from java/com/facebook/csslayout/YogaNodeAPI.java rename to java/com/facebook/yoga/YogaNodeAPI.java diff --git a/java/com/facebook/csslayout/YogaOverflow.java b/java/com/facebook/yoga/YogaOverflow.java similarity index 100% rename from java/com/facebook/csslayout/YogaOverflow.java rename to java/com/facebook/yoga/YogaOverflow.java diff --git a/java/com/facebook/csslayout/YogaPositionType.java b/java/com/facebook/yoga/YogaPositionType.java similarity index 100% rename from java/com/facebook/csslayout/YogaPositionType.java rename to java/com/facebook/yoga/YogaPositionType.java diff --git a/java/com/facebook/csslayout/YogaPrintOptions.java b/java/com/facebook/yoga/YogaPrintOptions.java similarity index 100% rename from java/com/facebook/csslayout/YogaPrintOptions.java rename to java/com/facebook/yoga/YogaPrintOptions.java diff --git a/java/com/facebook/csslayout/YogaWrap.java b/java/com/facebook/yoga/YogaWrap.java similarity index 100% rename from java/com/facebook/csslayout/YogaWrap.java rename to java/com/facebook/yoga/YogaWrap.java diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index 2e9fd99d..bf17f087 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include #include diff --git a/java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java b/java/tests/com/facebook/yoga/YGAbsolutePositionTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGAbsolutePositionTest.java rename to java/tests/com/facebook/yoga/YGAbsolutePositionTest.java diff --git a/java/tests/com/facebook/csslayout/YGAlignContentTest.java b/java/tests/com/facebook/yoga/YGAlignContentTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGAlignContentTest.java rename to java/tests/com/facebook/yoga/YGAlignContentTest.java diff --git a/java/tests/com/facebook/csslayout/YGAlignItemsTest.java b/java/tests/com/facebook/yoga/YGAlignItemsTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGAlignItemsTest.java rename to java/tests/com/facebook/yoga/YGAlignItemsTest.java diff --git a/java/tests/com/facebook/csslayout/YGAlignSelfTest.java b/java/tests/com/facebook/yoga/YGAlignSelfTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGAlignSelfTest.java rename to java/tests/com/facebook/yoga/YGAlignSelfTest.java diff --git a/java/tests/com/facebook/csslayout/YGBorderTest.java b/java/tests/com/facebook/yoga/YGBorderTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGBorderTest.java rename to java/tests/com/facebook/yoga/YGBorderTest.java diff --git a/java/tests/com/facebook/csslayout/YGFlexDirectionTest.java b/java/tests/com/facebook/yoga/YGFlexDirectionTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGFlexDirectionTest.java rename to java/tests/com/facebook/yoga/YGFlexDirectionTest.java diff --git a/java/tests/com/facebook/csslayout/YGFlexTest.java b/java/tests/com/facebook/yoga/YGFlexTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGFlexTest.java rename to java/tests/com/facebook/yoga/YGFlexTest.java diff --git a/java/tests/com/facebook/csslayout/YGFlexWrapTest.java b/java/tests/com/facebook/yoga/YGFlexWrapTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGFlexWrapTest.java rename to java/tests/com/facebook/yoga/YGFlexWrapTest.java diff --git a/java/tests/com/facebook/csslayout/YGJustifyContentTest.java b/java/tests/com/facebook/yoga/YGJustifyContentTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGJustifyContentTest.java rename to java/tests/com/facebook/yoga/YGJustifyContentTest.java diff --git a/java/tests/com/facebook/csslayout/YGMarginTest.java b/java/tests/com/facebook/yoga/YGMarginTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGMarginTest.java rename to java/tests/com/facebook/yoga/YGMarginTest.java diff --git a/java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGMinMaxDimensionTest.java rename to java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java diff --git a/java/tests/com/facebook/csslayout/YGPaddingTest.java b/java/tests/com/facebook/yoga/YGPaddingTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGPaddingTest.java rename to java/tests/com/facebook/yoga/YGPaddingTest.java diff --git a/java/tests/com/facebook/csslayout/YGRoundingTest.java b/java/tests/com/facebook/yoga/YGRoundingTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YGRoundingTest.java rename to java/tests/com/facebook/yoga/YGRoundingTest.java diff --git a/java/tests/com/facebook/csslayout/YogaNodeTest.java b/java/tests/com/facebook/yoga/YogaNodeTest.java similarity index 100% rename from java/tests/com/facebook/csslayout/YogaNodeTest.java rename to java/tests/com/facebook/yoga/YogaNodeTest.java diff --git a/lib/fb/BUCK b/lib/fb/BUCK index dfec53fc..da59ceaa 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -13,7 +13,7 @@ prebuilt_cxx_library( exported_platform_linker_flags = [ ('android.*', ['-llog']), ], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) cxx_library( diff --git a/lib/gtest/BUCK b/lib/gtest/BUCK index c5a6d790..a4c8a00e 100644 --- a/lib/gtest/BUCK +++ b/lib/gtest/BUCK @@ -23,5 +23,5 @@ cxx_library( header_namespace = '', compiler_flags = COMPILER_FLAGS, deps = [], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/lib/infer-annotations/BUCK b/lib/infer-annotations/BUCK index c826e879..378a65d7 100644 --- a/lib/infer-annotations/BUCK +++ b/lib/infer-annotations/BUCK @@ -17,5 +17,5 @@ java_library( exported_deps = [ ':infer-annotations-jar', ], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/lib/jsr-305/BUCK b/lib/jsr-305/BUCK index ae663727..8ced012c 100644 --- a/lib/jsr-305/BUCK +++ b/lib/jsr-305/BUCK @@ -17,5 +17,5 @@ java_library( exported_deps = [ ':jsr305-jar', ], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/lib/junit/BUCK b/lib/junit/BUCK index 9b26fd30..e9bbe4b8 100644 --- a/lib/junit/BUCK +++ b/lib/junit/BUCK @@ -17,5 +17,5 @@ java_library( exported_deps = [ ':junit-jar', ], - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/lib/soloader/BUCK b/lib/soloader/BUCK index 077b4fca..977c6d58 100644 --- a/lib/soloader/BUCK +++ b/lib/soloader/BUCK @@ -10,5 +10,5 @@ include_defs('//YOGA_DEFS') android_prebuilt_aar( name = 'soloader', aar = 'soloader-0.1.0.aar', - visibility = [CSSLAYOUT_ROOT], + visibility = [YOGA_ROOT], ) diff --git a/tests/YGAbsolutePositionTest.cpp b/tests/YGAbsolutePositionTest.cpp index fb59f1c8..c5a3891b 100644 --- a/tests/YGAbsolutePositionTest.cpp +++ b/tests/YGAbsolutePositionTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html -#include +#include #include TEST(YogaTest, absolute_layout_width_height_start_top) { diff --git a/tests/YGAlignContentTest.cpp b/tests/YGAlignContentTest.cpp index 5a2c6abf..6c2aaa40 100644 --- a/tests/YGAlignContentTest.cpp +++ b/tests/YGAlignContentTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html -#include +#include #include TEST(YogaTest, align_content_flex_start) { diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index fb5857f8..e80ae1d4 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html -#include +#include #include TEST(YogaTest, align_items_stretch) { diff --git a/tests/YGAlignSelfTest.cpp b/tests/YGAlignSelfTest.cpp index d369dd64..436d78b4 100644 --- a/tests/YGAlignSelfTest.cpp +++ b/tests/YGAlignSelfTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html -#include +#include #include TEST(YogaTest, align_self_center) { diff --git a/tests/YGBorderTest.cpp b/tests/YGBorderTest.cpp index 0224276c..41673414 100644 --- a/tests/YGBorderTest.cpp +++ b/tests/YGBorderTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html -#include +#include #include TEST(YogaTest, border_no_size) { diff --git a/tests/YGDirtyMarkingTest.cpp b/tests/YGDirtyMarkingTest.cpp index 4682e534..3888966e 100644 --- a/tests/YGDirtyMarkingTest.cpp +++ b/tests/YGDirtyMarkingTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include TEST(YogaTest, dirty_propagation) { diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index 46a676f3..4122b11b 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include TEST(YogaTest, start_overrides) { diff --git a/tests/YGFlexDirectionTest.cpp b/tests/YGFlexDirectionTest.cpp index 4f279e70..b6016428 100644 --- a/tests/YGFlexDirectionTest.cpp +++ b/tests/YGFlexDirectionTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html -#include +#include #include TEST(YogaTest, flex_direction_column_no_height) { diff --git a/tests/YGFlexTest.cpp b/tests/YGFlexTest.cpp index fecc30ee..559025f7 100644 --- a/tests/YGFlexTest.cpp +++ b/tests/YGFlexTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html -#include +#include #include TEST(YogaTest, flex_basis_flex_grow_column) { diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp index c2d13b77..03d07a82 100644 --- a/tests/YGFlexWrapTest.cpp +++ b/tests/YGFlexWrapTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html -#include +#include #include TEST(YogaTest, wrap_column) { diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index af0052fa..b7afe1b6 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html -#include +#include #include TEST(YogaTest, justify_content_row_flex_start) { diff --git a/tests/YGLayoutAspectRatioTest.cpp b/tests/YGLayoutAspectRatioTest.cpp index 5c35aac0..22846c9b 100644 --- a/tests/YGLayoutAspectRatioTest.cpp +++ b/tests/YGLayoutAspectRatioTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include static YGSize _measure(YGNodeRef node, diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index 8bb086b0..fbc1e1b9 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include TEST(YogaTest, assert_default_values) { diff --git a/tests/YGMarginTest.cpp b/tests/YGMarginTest.cpp index 74f1bae0..724b2eef 100644 --- a/tests/YGMarginTest.cpp +++ b/tests/YGMarginTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html -#include +#include #include TEST(YogaTest, margin_start) { diff --git a/tests/YGMeasureCacheTest.cpp b/tests/YGMeasureCacheTest.cpp index 2a4f4482..ca932b25 100644 --- a/tests/YGMeasureCacheTest.cpp +++ b/tests/YGMeasureCacheTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include static YGSize _measureMax(YGNodeRef node, diff --git a/tests/YGMeasureModeTest.cpp b/tests/YGMeasureModeTest.cpp index 358327ff..730247fa 100644 --- a/tests/YGMeasureModeTest.cpp +++ b/tests/YGMeasureModeTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include struct _MeasureConstraint { diff --git a/tests/YGMeasureTest.cpp b/tests/YGMeasureTest.cpp index 0f12a06a..911f0c51 100644 --- a/tests/YGMeasureTest.cpp +++ b/tests/YGMeasureTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include static YGSize _measure(YGNodeRef node, diff --git a/tests/YGMemoryFuncTest.cpp b/tests/YGMemoryFuncTest.cpp index cc0681d7..bef2985c 100644 --- a/tests/YGMemoryFuncTest.cpp +++ b/tests/YGMemoryFuncTest.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; diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 2b51ae3d..2c6d3120 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html -#include +#include #include TEST(YogaTest, max_width) { diff --git a/tests/YGPaddingTest.cpp b/tests/YGPaddingTest.cpp index 359d0235..aab6726b 100644 --- a/tests/YGPaddingTest.cpp +++ b/tests/YGPaddingTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html -#include +#include #include TEST(YogaTest, padding_no_size) { diff --git a/tests/YGRelayoutTest.cpp b/tests/YGRelayoutTest.cpp index 01cf4950..de298325 100644 --- a/tests/YGRelayoutTest.cpp +++ b/tests/YGRelayoutTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) { diff --git a/tests/YGRoundingMeasureFuncTest.cpp b/tests/YGRoundingMeasureFuncTest.cpp index d6f5f6d4..6bbee0e3 100644 --- a/tests/YGRoundingMeasureFuncTest.cpp +++ b/tests/YGRoundingMeasureFuncTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include static YGSize _measureFloor(YGNodeRef node, diff --git a/tests/YGRoundingTest.cpp b/tests/YGRoundingTest.cpp index 00d6eedf..0ce9f5c0 100644 --- a/tests/YGRoundingTest.cpp +++ b/tests/YGRoundingTest.cpp @@ -9,7 +9,7 @@ // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html -#include +#include #include TEST(YogaTest, rounding_flex_basis_flex_grow_row_width_of_100) { diff --git a/tests/YGStyleTest.cpp b/tests/YGStyleTest.cpp index 863cf52b..4eb7fd60 100644 --- a/tests/YGStyleTest.cpp +++ b/tests/YGStyleTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include #include TEST(YogaTest, copy_style_same) { diff --git a/CSSLayout/YGEnums.h b/yoga/YGEnums.h similarity index 100% rename from CSSLayout/YGEnums.h rename to yoga/YGEnums.h diff --git a/CSSLayout/YGMacros.h b/yoga/YGMacros.h similarity index 100% rename from CSSLayout/YGMacros.h rename to yoga/YGMacros.h diff --git a/CSSLayout/YGNodeList.c b/yoga/YGNodeList.c similarity index 100% rename from CSSLayout/YGNodeList.c rename to yoga/YGNodeList.c diff --git a/CSSLayout/YGNodeList.h b/yoga/YGNodeList.h similarity index 100% rename from CSSLayout/YGNodeList.h rename to yoga/YGNodeList.h diff --git a/CSSLayout/Yoga.c b/yoga/Yoga.c similarity index 99% rename from CSSLayout/Yoga.c rename to yoga/Yoga.c index 32d7e489..29acb459 100644 --- a/CSSLayout/Yoga.c +++ b/yoga/Yoga.c @@ -2653,21 +2653,21 @@ inline bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature) { return experimentalFeatures[feature]; } -void YGSetMemoryFuncs(YGMalloc YGMalloc, YGCalloc YGCalloc, YGRealloc YGRealloc, YGFree YGFree) { +void YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, 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), + YG_ASSERT((ygmalloc == NULL && yccalloc == NULL && ygrealloc == NULL && ygfree == NULL) || + (ygmalloc != NULL && yccalloc != NULL && ygrealloc != NULL && ygfree != NULL), "Cannot set memory functions: functions must be all NULL or Non-NULL"); - if (YGMalloc == NULL || YGCalloc == NULL || YGRealloc == NULL || YGFree == NULL) { + if (ygmalloc == NULL || yccalloc == NULL || ygrealloc == NULL || ygfree == NULL) { gYGMalloc = &malloc; gYGCalloc = &calloc; gYGRealloc = &realloc; gYGFree = &free; } else { - gYGMalloc = YGMalloc; - gYGCalloc = YGCalloc; - gYGRealloc = YGRealloc; - gYGFree = YGFree; + gYGMalloc = ygmalloc; + gYGCalloc = yccalloc; + gYGRealloc = ygrealloc; + gYGFree = ygfree; } } diff --git a/CSSLayout/Yoga.h b/yoga/Yoga.h similarity index 98% rename from CSSLayout/Yoga.h rename to yoga/Yoga.h index e41a4cd9..c7bc600d 100644 --- a/CSSLayout/Yoga.h +++ b/yoga/Yoga.h @@ -175,6 +175,6 @@ WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, b WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature); WIN_EXPORT void -YGSetMemoryFuncs(YGMalloc cssMalloc, YGCalloc cssCalloc, YGRealloc cssRealloc, YGFree cssFree); +YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, YGRealloc ygrealloc, YGFree ygfree); YG_EXTERN_C_END From b611fac20b0b054efb7c55a0896fa2fed215aac1 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 7 Dec 2016 16:18:13 +0000 Subject: [PATCH 106/108] update naming and fix test --- BUCK | 1 + CONTRIBUTING | 7 +-- LICENSE | 2 +- PATENTS | 2 +- README.md | 164 +++++---------------------------------------------- 5 files changed, 20 insertions(+), 156 deletions(-) diff --git a/BUCK b/BUCK index 7b49825c..09e39b43 100644 --- a/BUCK +++ b/BUCK @@ -25,6 +25,7 @@ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11' cxx_library( name = 'yoga', + soname = 'libyogacore.$(ext)', srcs = glob(['yoga/*.c']), tests=[':tests'], exported_headers = subdir_glob([('', 'yoga/*.h')]), diff --git a/CONTRIBUTING b/CONTRIBUTING index eac38f3d..07c37f21 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -1,10 +1,7 @@ -# Contributing to css-layout +# Contributing to yoga We want to make contributing to this project as easy and transparent as possible. -## Our Development Process -All the development is happening on GitHub first and we have internal tools to sync down to Facebook codebase. - ## Pull Requests We actively welcome your pull requests. 1. Fork the repo and create your branch from `master`. @@ -32,5 +29,5 @@ outlined on that page and do not file a public issue. * format.sh ## License -By contributing to css-layout, you agree that your contributions will be licensed +By contributing to yoga, you agree that your contributions will be licensed under its BSD license. diff --git a/LICENSE b/LICENSE index 864c3963..2b3f0e4f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD License -For css-layout software +For yoga software Copyright (c) 2014-present, Facebook, Inc. All rights reserved. diff --git a/PATENTS b/PATENTS index 4dc338f2..78780735 100644 --- a/PATENTS +++ b/PATENTS @@ -1,6 +1,6 @@ Additional Grant of Patent Rights Version 2 -"Software" means the CSS Layout software distributed by Facebook, Inc. +"Software" means the yoga software distributed by Facebook, Inc. Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software (“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable diff --git a/README.md b/README.md index 09941370..1e066668 100644 --- a/README.md +++ b/README.md @@ -1,162 +1,28 @@ -# CSSLayout [![Build Status](https://travis-ci.org/facebook/css-layout.svg?branch=master)](https://travis-ci.org/facebook/css-layout) +# Yoga [![Build Status](https://travis-ci.org/facebook/yoga.svg?branch=master)](https://travis-ci.org/facebook/yoga) -## NOTICE -A lot is changing this week in the API regarding naming. We suggest you hold off updating to the latest version of the code until this notice is gone. Expect it to take about a week. +## Building +Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable. -## Goals -CSSLayout is a cross-platform implementation of flexbox. The goal of CSSLayout is allow native developers to have the same expressive layout system as developers developing for the modern web are used to. CSSLayout allows developers for web, android, iOS, and windows to use the same layout primitives across platforms. This saves time, increases collaboration between platform teams, and makes it easier for developers to work on multiple platforms. +## Testing +For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`. -The goal of CSSLayout is not to re-implement all of css. CSSLayout only targets flexbox, and does not have any plans on implementing support for tables, floats, or any other css concepts. CSSLayout also does not plan on supporting styling properties which do not affect layout such as color or background properties. - - -## Differences from web -CSSLayout tries to stay as close as possible to the web implementation of flexbox. There are however certain cases where CSSLayout differs from the web implementation. - -### Default values -CSSLayout has chosen to make changes to the default values of certain properties. These default values were chosen based on our usage of the library. When testing layout with tools such as JSFiddle you can apply the following css style to ensure the defaults match those of CSSLayout. Or fork the [following JSFiddle](http://jsfiddle.net/vjeux/y11txxv9/). - -```css -div, span { - box-sizing: border-box; - position: relative; - - display: flex; - flex-direction: column; - align-items: stretch; - flex-shrink: 0; - align-content: flex-start; - - border: 0 solid black; - margin: 0; - padding: 0; - min-width: 0; -} -``` - -- `box-sizing: border-box` is the most convenient way to express the relation between `width` and `borderWidth`. -- Everything is `display: flex` by default. All the behaviors of `block` and `inline-block` can be expressed in term of `flex` but not the opposite. -- All the flex elements are oriented from top to bottom, left to right and do not shrink. This is how things are laid out using the default CSS settings and what you'd expect. -- Everything is `position: relative`. This makes `position: absolute` target the direct parent and not some parent which is either `relative` or `absolute`. If you want to position an element relative to something else, you should move it in the DOM instead of relying of CSS. It also makes `top, left, right, bottom` do something when not specifying `position: absolute`. - -### Size units -CSSLayout currently only supports pixel sizes. The reason being that we have not seen the need for any other units. We would like to support percentage units sometime in the future. - -### -start and -end properties -We think supporting RTL locales is very important. Therefor CSSLayout supports non-standards -start and -end suffixed versions of margin, padding, border, and position. - - -## Usage - -### C -The full API can be found in `CSSLayout/CSSLayout.h`. - -```c -CSSNodeRef root = CSSNodeNew(); -CSSNodeStyleSetWidth(root, 100); -CSSNodeStyleSetHeight(root, 100); - -for (uint32_t i = 0; i < 10; i++) { - CSSNodeRef child = CSSNodeNew(); - CSSNodeStyleSetHeight(child, 10); - CSSNodeInsertChild(root, child, 0); -} - -CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - -// Get for resulting layout -CSSNodeLayoutGetLeft(root); -CSSNodeLayoutGetTop(root); -CSSNodeLayoutGetWidth(root); -CSSNodeLayoutGetHeight(root); -``` - -### Java -The full API can be found in `java/com/facebook/csslayout/CSSNode.java`. - -```java -CSSNode root = new CSSNode(); -root.setStyleWidth(100); -root.setStyleHeight(100); - -for (int i = 0; i < 10; i++) { - CSSNode child = new CSSNode(); - child.setStyleHeight(10); - root.addChildAt(child, 0); -} - -root.calculateLayout(new CSSLayoutContext()); - -// Get for resulting layout -root.getLayoutX(); -root.getLayoutY(); -root.getLayoutWidth(); -root.getLayoutHeight(); -``` - -### UIKit -The full API can be found in `YogaKit/UIView+Yoga.h`. - -```objective-c -UIView *root = [UIView new]; -[root yg_setUsesYoga:YES]; -[root yg_setWidth:100]; -[root yg_setHeight:100]; - -for (NSUInteger i = 0; i < 10; i++) { - UIView *child = [UIView new]; - [child yg_setUsesYoga:YES]; - [child yg_setHeight:10]; - [root addSubview:child]; -} - -// Resulting layout will be set on the UIView hierarchy frames. -[root yg_applyLayout]; -``` - -### .NET -The full API can be found in `csharp/Facebook.CSSLayout/CSSNode.cs`. - -```csharp -var root = new CSSNode(); -root.StyleWidth = 100; -root.StyleHeight = 100; - -for (var i = 0; i < 10; i++) -{ - var child = new CSSNode(); - child.StyleHeight = 10; - root.Insert(0, child); -} - -// Get for resulting layout -root.LayoutX; -root.LayoutY; -root.LayoutWidth; -root.LayoutHeight; -``` - -## Contributing -To contribute to CSSLayout you need to first install [buck](https://buckbuild.com) which is the build system used by CSSLayout. CSSLayout is implemented in C with language bindings for Java, Objective-C, and .NET. When making changes to `CSSLayout/CSSLayout.h` please ensure to update `java/jni/CSSJNI.h`, `java/com/facebook/csslayout/CSSNode.java`, `uikit/CSSLayout/UIView+CSSLayout.m`, and `csharp/Facebook.CSSLayout/CSSNode.cs` to reflect the API change. Before submitting any code please run `format.sh` to ensure the code matches the project's code style. - -Before making any larger changes to CSSLayout please open an issue with a RFC so the changes can be discussed first. Generally we are very open to changes and improvements that will benefit the community. - -### Testing -For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add at least one test to ensure we don't break anything in the future. Tests are located in `tests/CSSLayoutTest.cpp`. Run the tests by executing `buck test //:CSSLayout`. - -Instead of manually writing a test which ensures parity with web implementations of flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in CSSLayout, in `gentest/fixtures` folder, such as the following. +Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following. ```html -
+
``` -Run `gentest/gentest.rb` to generate test code and re-run `buck test //:CSSLayout` to validate the behavior. One test case will be generated for every root `div` in the input html. +Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html. You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script. -#### .NET -.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.CSSLayout/test_macos.sh`. +### .NET +.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`. -### Benchmarks -Benchmarks are located in `benchmarks/CSSBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. +## Code style +For the main C implementation of Yoga clang-format is used to ensure a consistent code style. Please run `bash format.sh` before submitting a pull request. For other languages just try to follow the current code style. + +## Benchmarks +Benchmarks are located in `benchmarks/YGBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI. From 47a8ec06a166ed77004f46b9b151fe550bd0af86 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 7 Dec 2016 17:27:25 +0000 Subject: [PATCH 107/108] Add sample project for YogaKit --- .../YogaKitSample.xcodeproj/project.pbxproj | 376 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 19846 bytes .../xcschemes/YogaKitSample.xcscheme | 91 +++++ .../xcschemes/xcschememanagement.plist | 22 + .../YogaKitSample/YogaKitSample/AppDelegate.h | 17 + .../YogaKitSample/YogaKitSample/AppDelegate.m | 28 ++ .../AppIcon.appiconset/Contents.json | 48 +++ .../YogaKitSample/YogaKitSample/Info.plist | 36 ++ .../YogaKitSample/ViewController.h | 16 + .../YogaKitSample/ViewController.m | 61 +++ YogaKit/YogaKitSample/YogaKitSample/main.m | 17 + 12 files changed, 719 insertions(+) create mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj create mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/YogaKitSample.xcscheme create mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h create mode 100644 YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m create mode 100644 YogaKit/YogaKitSample/YogaKitSample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 YogaKit/YogaKitSample/YogaKitSample/Info.plist create mode 100644 YogaKit/YogaKitSample/YogaKitSample/ViewController.h create mode 100644 YogaKit/YogaKitSample/YogaKitSample/ViewController.m create mode 100644 YogaKit/YogaKitSample/YogaKitSample/main.m diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj new file mode 100644 index 00000000..7232ec9f --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj @@ -0,0 +1,376 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 13687D481DF8748400E7C260 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D471DF8748400E7C260 /* main.m */; }; + 13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; }; + 13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; }; + 13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; }; + 13687D781DF878C600E7C260 /* YGEnums.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; }; + 13687D791DF878C600E7C260 /* YGMacros.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; }; + 13687D7A1DF878C600E7C260 /* Yoga.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; }; + 13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; }; + 13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; }; + 13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; }; + 13687D821DF87CF200E7C260 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; }; + 13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; }; + 13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 13687D771DF878A000E7C260 /* yoga */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = include/yoga; + dstSubfolderSpec = 16; + files = ( + 13687D781DF878C600E7C260 /* YGEnums.h in yoga */, + 13687D791DF878C600E7C260 /* YGMacros.h in yoga */, + 13687D7A1DF878C600E7C260 /* Yoga.h in yoga */, + ); + name = yoga; + runOnlyForDeploymentPostprocessing = 0; + }; + 13687D7B1DF878CE00E7C260 /* YogaKit */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = include/YogaKit; + dstSubfolderSpec = 16; + files = ( + 13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */, + ); + name = YogaKit; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 13687D471DF8748400E7C260 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 13687D491DF8748400E7C260 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 13687D4A1DF8748400E7C260 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 13687D4C1DF8748400E7C260 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 13687D5E1DF8778F00E7C260 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = ""; }; + 13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = ""; }; + 13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = ""; }; + 13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = ""; }; + 13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = ""; }; + 13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = ""; }; + 13687D691DF8778F00E7C260 /* UIView+Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+Yoga.h"; sourceTree = ""; }; + 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+Yoga.m"; sourceTree = ""; }; + 13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 13687D401DF8748300E7C260 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */, + 13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 13687D3A1DF8748300E7C260 = { + isa = PBXGroup; + children = ( + 13687D5D1DF8778F00E7C260 /* yoga */, + 13687D641DF8778F00E7C260 /* YogaKit */, + 13687D451DF8748400E7C260 /* YogaKitSample */, + 13687D441DF8748400E7C260 /* Products */, + 13687D831DF87D1E00E7C260 /* Frameworks */, + ); + sourceTree = ""; + }; + 13687D441DF8748400E7C260 /* Products */ = { + isa = PBXGroup; + children = ( + 13687D431DF8748400E7C260 /* YogaKitSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 13687D451DF8748400E7C260 /* YogaKitSample */ = { + isa = PBXGroup; + children = ( + 13687D491DF8748400E7C260 /* AppDelegate.h */, + 13687D4A1DF8748400E7C260 /* AppDelegate.m */, + 13687D4C1DF8748400E7C260 /* ViewController.h */, + 13687D4D1DF8748400E7C260 /* ViewController.m */, + 13687D521DF8748400E7C260 /* Assets.xcassets */, + 13687D571DF8748400E7C260 /* Info.plist */, + 13687D461DF8748400E7C260 /* Supporting Files */, + ); + path = YogaKitSample; + sourceTree = ""; + }; + 13687D461DF8748400E7C260 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 13687D471DF8748400E7C260 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 13687D5D1DF8778F00E7C260 /* yoga */ = { + isa = PBXGroup; + children = ( + 13687D5E1DF8778F00E7C260 /* YGEnums.h */, + 13687D5F1DF8778F00E7C260 /* YGMacros.h */, + 13687D601DF8778F00E7C260 /* YGNodeList.c */, + 13687D611DF8778F00E7C260 /* YGNodeList.h */, + 13687D621DF8778F00E7C260 /* Yoga.c */, + 13687D631DF8778F00E7C260 /* Yoga.h */, + ); + name = yoga; + path = ../../yoga; + sourceTree = ""; + }; + 13687D641DF8778F00E7C260 /* YogaKit */ = { + isa = PBXGroup; + children = ( + 13687D691DF8778F00E7C260 /* UIView+Yoga.h */, + 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */, + ); + name = YogaKit; + path = ..; + sourceTree = ""; + }; + 13687D831DF87D1E00E7C260 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 13687D861DF87D2400E7C260 /* Foundation.framework */, + 13687D841DF87D1E00E7C260 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 13687D421DF8748300E7C260 /* YogaKitSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */; + buildPhases = ( + 13687D771DF878A000E7C260 /* yoga */, + 13687D7B1DF878CE00E7C260 /* YogaKit */, + 13687D3F1DF8748300E7C260 /* Sources */, + 13687D401DF8748300E7C260 /* Frameworks */, + 13687D411DF8748300E7C260 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = YogaKitSample; + productName = YogaKitSample; + productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 13687D3B1DF8748300E7C260 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = facebook; + TargetAttributes = { + 13687D421DF8748300E7C260 = { + CreatedOnToolsVersion = 8.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 13687D3A1DF8748300E7C260; + productRefGroup = 13687D441DF8748400E7C260 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 13687D421DF8748300E7C260 /* YogaKitSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 13687D411DF8748300E7C260 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 13687D531DF8748400E7C260 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 13687D3F1DF8748300E7C260 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */, + 13687D4E1DF8748400E7C260 /* ViewController.m in Sources */, + 13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */, + 13687D821DF87CF200E7C260 /* Yoga.c in Sources */, + 13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */, + 13687D481DF8748400E7C260 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 13687D581DF8748400E7C260 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 13687D591DF8748400E7C260 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 13687D5B1DF8748400E7C260 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = YogaKitSample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 13687D5C1DF8748400E7C260 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = YogaKitSample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 13687D581DF8748400E7C260 /* Debug */, + 13687D591DF8748400E7C260 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 13687D5B1DF8748400E7C260 /* Debug */, + 13687D5C1DF8748400E7C260 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 13687D3B1DF8748300E7C260 /* Project object */; +} diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..b8f12e0b --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..c1f7d4ac339e1f4264645cb736068a1b0e839157 GIT binary patch literal 19846 zcmcJ02Yi!N_wc>X>TZ(mbS9)NEg5Zgf^F%BGAk{ktdh1V4Wvy;QZ{lQQ3S<>iXbSI zDK1cPD{kBi5H}9Q0S=s?h<@kElavOF@B9Dxe$|rZj&sgE_uMn@ZRvKqeE#C%LkJ@Z z(TG7T;<$C(`pLQToL-;H(=|EQ(=yxH>i0F}I=rnNE@*Dd^?SM#5MHr)w+w%eB2Xks zL`f(a4Mqj15Dh_Uq(NGwLq*7l?C4@N9yOpwGyzRSlh9<;gr=aWXd0T1W}r6YM6;0> z`H&y=pm}H^;?bq(aos+ZbD-9g<+-A_G1Jxjer zy+*x7y-gja-lsmMj#6JzC#bX3pVVJ8qA^X;G|kWnbRwNZC(|i(Cas{Aw3^n?T3SaN zXfti0OXzaCf*wPUrN`0r^u_cfdK%qEJLz`1i}ui$(<|sJ=#}&;`bzpLdNqADeGR>a zUQ6FhZ=g5PTj@LKJL$XVyXkxA-SqwRL-Z5$KKe=eCHiIh75Y{BHTre>0DYMLfc}vF zgFy^tScYSwnHWaGNSP!inUOQ;Og59lsF+-)fGK3OjE*rdM#jq6m=dOxsbDIZvCKH8 zp1GKr&dgw%nVF26>14W?Ma*Jm3A2=0#azi;#oWxSW7adbFguu?%I}d)Wur2iZs2r`V_2=h^-2i|kA6YwSVx5c@X!HG7;r z!G6Pj%YMgx&z@v|V1HzPVt;0TVSnWihdGL)xfm{)OW{(vG)~T?a~WJ7m(LC63OEC2 z8I8^)D$)!YbfGS|dS;ihuaxS3ol*Ty+H7dMYv#4YBQam%^OxRu;0?rQEDZVh(> zck_hYt{%7hAc{iKCa~@AbIdp!}Mpn*Jn- zv(NQU=yJ{Nan`i~m9BP|)7va9>pwgUR&!N_v7)-7rb=rzTYv=>HFj;K-eS@kYbq+L zYHBMhEH%J_8~{+!>IWS=FiFi)xqu?Dj7E>g-Qw`p`6jx2t`;|}DD7OIqop#eD|PW= zy+&a$>6dC0i}j}BVvWLXv@BhEAh4^&$k2<@fm87ZkO`TQ1zD$v8`=e|nk@e5^ufMY zc)gB=TVQ}~^4NxP0lN^|p`oY-<==rWLM5mam7!s%995u7RE4UEl*mW|NhC=mnWT_Z zl1Airpjz0a5vUH0M5EAXGzPwnBk8bLnIwx0A#UO!^WobfQrIj_sqp#0N;$gxHEk}x z$LkyISm^2TH%q0k;)V{-{IQOCu2~M~nF{YmjSiEGFu>JLpKDfE7~E+B z@N;uRG>as-oWAKmrMNC(niNF=A;Oe%lBVknF}WEzP<}6(NwRxU3&|0fBdea+*tdo{ zzq8XPZfZMnZ9%h82T_oGQV;?#2X&!@Ey#^JiINQ3f;_03s7Nl!n+{<5%d!-{3sj78 z%<6Lad)l1!s`AT5AmK+8lKE)Cw6P72!XamDUgTSWD$*rC?rw({M%H`Mf?XoVgF~G$JryHCcXIo!Svs7_`DGh#a zPpiMj>kO@SExHxu??5-Bb!a`h1#LhZNf9X~dSW0(V%mXjLz@EPz6I2hnOFj1ezBmG z#53FAceKu_@^p54ogn9)u89tJ4;<%Ipfx~Uqu0^pbAg(Hfqo~brPS)m;eB)pVgh|* zV0A%oa3IEYxfhP_>FRQI&8l>JTIcu#^%qnW<6)i6(ky5Yj*c+04j=$-Ka37SlQN;T z-Hq-?`PkNj`pGl;MnG(he-)3g~OUbDugu+2GBJNoUJ{A zWYl!cb9p^of-bLUYZF!o>;pujoC}+!$)P3IEa-N0wK>}Y^4l!U3$<6c;YhSC6bS9A z^?1iR=hr)We9pE2Cz_>t7&pQ(&shf|>TL-XNPFPZh%MFOTf^)J%u)}v8 zHtThWW?Wn`N$wgJ9~kY7cvUi2ENBn5AyH_=;QVh^B$=n#4v z9Y*h||Ea7NRt3zPujB}^7-r?^EjOcW@y3REVRsxv0U|f4>?zujKNHwV^Rb(7+ zuTQ>3VG6Q9H_+ZydjuRJ%^x7cHuNF-2pvHmlNwS-Mv*Zj{vi4c9R>P7N5{|?Q_f+W z5TJ$BlHp`Tvozaewkot!!}XiO?QygTP19xgC6RT<(Fr)SuvHa-m_twxqTB?a)jM3? zE$AC$`wwG6G<^q0@Cz~$4&R8$jU9qWDfFSfpWtYIK}N%&91*^Up#i4@1I7viz-uUJ z6Rd#3CmvNryT_{t+xfD@Wq*l3;zIsJe>F=BU?E{VKDVmzPT|+$b2tJ=q768jG?EEqBAEo5Y4Q#ni}G+h z{7SKmG=WBHgWq;COE|@XI~F=lfs@hbbq3ug&>%o?NVsZUZcra^&}zDbZE6$EW1oHs zgHh=OhB^CYh#-Y+Zm1d~oX;L#Utb?IiO?O?&ccMy+T=I`CG_HSGNl)1lBt5HDGUv0 zPhW+v|4;=U1ZEQ}$+TXqBGXCX`8yr(Zt-BOLHXNo0WQQtu$s&u&15EV2n_|e2p2%Z z4AKI>h4qaKK>>sVnG_U*5P4QS6y|0V5agw}HM=c(X@;7e|?8`tK9vU|akLd$2mUNs0a4~M^<3J;Ek;2f7Nw`Vq7(!aNaf<~v->*?%s*FyAl;cg%!;PK$Oq?;55bP)C<*H+wv=i&KeF7c6` zJ`V>k!r`vRFuV*LPp{y5be9KQj}YkPctx0#QjJ#jG+6hXzTSRzx!;Ho zf=zfA%HM@I<6gW4Z^hg2cDw`c#J7{hWC>YHE+NYZAw0R1EZ+qu{7xXC7S-b2cn`i8 z-v^s>8IY3>|Lq~qk>|;4f^10z)S}^ZdPN5~1=c5ervVQG4ry1L!`mh}t-@fj3$(>V zFhp4^xC8!w z{}a9sKP5=(ljQPV{4`l1EGAFH9*h+(gdoJt=kW^yfc@l(Ui>0iNeUasfWZs(zKY*O z30v`N_;vgSSw*fSS8c^_0XGkl)xg1f1VJbaLlQ2!|!NZ*zKGu(iET;9LWn= zDA*|EKB!r>S z)d?;xIBbxRIIk;s3adICUI)Yg-tmsESk;-W@4QJNlN3HnRq@2> zrSE2&zG)K7vfgB~E}gvCWV8t;x}S$fMN={8FcpVt$xgBv9I{O$y;)i`utO&LUb;Tj z*cX2U1cQG$*#?bNu#r** ze4HJEj}vay4pR9jh8j#2P=)Bw)V5$&26n5-AL1vuo$Mm0Svs~Iq-khTQPBh+9Ofct zr_1e|T_hOFqM&IEeTr`LdEd^rEdlq5(o#Bz03j9)ZDYs{-a-`#p3*>F;ANJ(1jk$m zIs$H$A{=K^&hn6ZOyGeYQr)IN(aM1^UHG-<6Mv@1}W8?|4j}%TG?Q9REE1Jf;W_1Mqnj)$=F#;4q zsy;>8r)WcHE~X|5XvR|wR3kNkJV+iQ50gi>fx)h&n!rGf2MKr-?1EsVCOW(>!J&f$ zlXHH+CXIK@7rm=yX?l2XP=htJdb*tuIEQrxrh~TwsgYK%t6Rw5KuRZUNC3K^ghZ}6 zkYRJ5nxopNcF@d}lRVxF$0c2$O$Hu=&*Kg{lET8JIJ87J)fI9WC=You=rB-TNQY29 z%1@pm&-6J9)O>1Df5Q&^Ujn>;T5tgthq(Y0p_Ye@tfDT5J$g1Uvb(>tK&_n(W2 zMORbT_EB^l*&m|l27#g*shh|P4<%3b2R4pDbecT@L(jP3^UzL&ZWqFS%V;}>N~Fs)+)8HLnY z&MsGvPdp+4M{R*$>`Chu73|--$YD4Zuaox~=t4?w{H!<}d^a0O<*7nG2bqsUEM84GElVz;u|rOWx?OTlY~<26gM(^2wpddaG6vVy2Eiv^RakN>U-)W^#k=I^%MDkd`LbbN65$I6Y}X!luP|eouW=t zzfr$aXF%0_#^ZZMNtGa~bGkjQF26634~M)L#FgnmXR)8B;)ARZ zs9fJPF>T(^+5uW00Ek~91qNCN;;ewIG)s#|JA8g2)8=*pz;iC4IIR+tds|>4q=vx_ z1)T*UWymauS$9xfX=3;rZZrfMf?S|k8iMZaG)G6^6Lb_EO^%Y!!QnbazSvI3(s6V= zEup34OY#Gc^LXsz@mgWcga64S)eBWx5o5E|Dvk{NYpnNrgz9WCqCDS}g^lT(37apN zy+C-;4#k$r9ypFp@A;D(Kvgen@qo7v8Hs* zlj9Iqp0lNNPQY%09FF*RK0{qsyGIwOV298SqVpjWOsnWzI**(n-;i&&QcZLLT?l6F zJ91KBw2%O7t{+|3(AZp4UDr5nd~-w1=$fj=x^ZKhN7Xb9G@xd3eZ|;@z5$BAL6}(A zP**v+W;}oqU zQ+b>#uuznSknD+asS`c*(IBWgpHNeo2W~^NR2?RQK@k?)0%BL+0jDl#ULbQc!03>p z9Xg014-k&xK*Q_3&Ur3RkFU|;o#hOknJS?;8CvRix-n#q=?UcbpgE=|gE^*~=qcn3 z`LoX))6?mh{Y@+Fpj*fv?%Fmd9~Cj_0w2$5I|A^EgG=#x%XrVzXA8iuKjCHmk{I zEH19GRv9eC=enSBdw!Q#7BT*9_aK;r*eQ_L4+6GY1G8-v#eV~AtrWYeYW~(`(*GT2 zP>TMBv)birb$dW<3t^}aa2s?$eEysZ2v|d_P};2*>`H$+jkV`v3~ku8^mSpr9DM_Q zqu5X%8nTXFA3kIw4b>naR~H(wneG)EL^ZGtJ-3bCPVb<1(zo+i#^VGYC-OK+C@iFp zc6H5BRD!|sE>ui%`8yP&T`gX4#GSrC$`S05V7?&GQixHCFO+ti9EdlK#!y5-@1gJQ zk999N8uSA^P9yP$=!YSqgSd`w&L zaV?KW@^}o7FXnM0k0Dy%2)82??z5T!OaM;aN1N%j;O= z?eMyME$zN;r@N)c<5=YGa25rWND=r=ZBWJa0Tig`XkFbMo-U}}clJPF@9`G7x?0^( z^bWx-nouW%v1%cap$j8EN+e$0EUg}p`2RZpA=K9(qkhgyV&X;6+Ggpfe+RmvySo}r zINXqMh7+GCVkiQOeqjv3y{qZ!>GXw9PZOu>|L3`%{#?iskr@BiNWyk;kcb4X;N)MJ z5yIw!-&|BVp=wlr3I~gmt&qU`&y)KLQrK>5L@4(E>28N%(2E!@`ahl2*8VHCh!9Gf zrAroQ7YI(Iw$0@O-^$t9;$8^3KS;2)&S`EJZdeU-J9@fWI~v47>3C;*X`rrdF*s}% zTXBA1WZ){+2#2qu)NU{tj8==;WH(z3reeFv)^9}LWV6lO0$xggk}eWS8uou?e%St( zi%=>cjep@S3?76r4)7v`lOU$ynJQ+4P&GV1C(YC`BT*hRn#WZ26@^l-7ouymqWzYRef&rBK++GM5)piSlRa2}5kpw)@c7A-2f?N9)k!C*HnZCY%# z1QO37KY(#CkUkrLyje_#NZu$OkM2j_lH*es9Se99X1%o!iihzJ2&IRa2T&I9cr1^{ z2~g@qvX;)cbl7(RC?>N(NP(NoLJB;z%1fB#1A@DZxm+X)AT{(S>e->ce--4J(a;BG zHFN!dVAe1<0GOM2Jb}j(1u&C>RK1&Z{G$Of^C7Y}Fq;R2*ULanli9}OCLW5U0B>p# zUh@*u=D;eAHXE$cSR6?7hrr#z>>d!@9_C(gmD72suL8KBWXyliKgTALXV&ZcR{1dV z#DHM-F;9wMX7bq456sf_4=djaP-Qn*`k?G*UKtR|tITTv&HlCG11(=nv5OVo>JZ}q|z=ER>hvk|u7m5wq(Vk}M z%nNIuko5_E4p>7GGFUoyAg~`TYTs5!`RtVB3|Ig40MbrN1L>go)#m$2<9bCy&)m5I$SM^oM1gA|%T8lS&q3lpsS>@=O=Lpm^`gf$(RgUZN zyIoz*@F~Hg%<5SqBn?;tkC*kb;98RajY2wcR2SS$>o<3jtIgj5cMU%2AJ4OPwj3_v zutV94*b=ssEn|nlivk`)gnk*1FX!UW#zLLkQd3-fg zW(ucF@pw9G9j&mLQ>!2W?(_yCS-1}!9@;otQt6#E8Z%ot8Vo4(JC^a z-s6KibDpj-4k(DG3Y`@~_zsy;=Q%WRBLJLk7i0(>-e8ebHSAu_p(>9UfAq+Hm8a?vA}&X5S})t-{Eqf zJ7?1&TjOelI}uu_`@rpLsW@CKWVeG&5=hngYoX38knQ{y^N$-i4m) zWg+I=BBV@`bVU%~)IkYJ=jiTs!6z(T9CxoU?mixGyWlwC9&BY@RWNrwE{N(J!661d z#6B!;ZK&Zf7Ho1a`#6tp?`8M#c$dHxiL>7|*1Br(A~yRB3sgMI<2!hK=f%1}5eB`? zzOV(sRnQsda)`oWL(pGl!B+Q6A+fKsaQ~#21uMO~mwk)Jd*H%0B%y_@mv}8QJiQTu zbC~@YCEU)w!@kSD$G*>gz<$Vn#DZ-Gp4`vly*!45(1SdFh{q4}_>tS$PvDYJ9($Di zoIS>Vfk00SwO}~WkMS5*`UH>n!S}o-e;~EmP(5mj%U9!e%@UsEnXOifHWMP!T6&a|_`eDn||2(h~!o&tARDXqJ3j|&NJX*vNxO$)} zj}(nZD^kFPAH{%j&t-Cof!3qs25~ALzslp+c>Fq8qH+-yx>zwGkQEAUC0EF42b!yBZT$OOu zqz%$q<7AYhB~agj7n+!&8J4@Kw~>U6@5{DZQD=)@GcK+&A=H(y(lk_kiDEvaen z3@eJnOdQ)#3$7N7tn#=$-a}d0InfH`AQiMXxE479YkRHRG0O+v1-+#z&li~|i<1hk zxImJ1pvd8#_d>V_*g2t209NU7w;jkITu?aBd!!)3Ed@i)Jx0=Kqjg2aK*OXCaEV}L z0a_Y_CuNnzNJ^7v0B10Uh}>cr0^iM+@RuxRq0t7Jn1p_ufj0-jCFdu?A#?cT%I^MeJ160(rybUYKT;CkU&>>_+EUITYQAAwh?Pm5fpu=oiNv%-D^#dJ7el(-tMc6#4)1tF`t z6`F=48}M297CIbtTs`#eC$A>&V0(Y365cJ5Pe?IWyMUek62xtOTFI;{ISASs|Nf^}NUno3}`wt_9`+A{L0>XCv1g+#JZ?AE&?OJX|+7m-BKy&d=k|0tx%FK(_vK9v|cJ zmpuNO$0vCFEvV{qiD7P`=r11q*ZyL7tP_@frXLfL$onI{RBZd=-DBB#?91SC{sm4-3@8=}JYiOG8hEs9 z2WvQvYvbCv4sJH*=DOg(csV~jS6%>5l&|HkhbPK6aW`}8xeeT{+$OG<+sZx8y}^AD z5fhOeVTx#t=#E$(aec%M5jRHcjMy9TP{bnQ@)K^ibqEn;g(fQH(Xk)ZF+8S+-z9_mjdPMZd=+V(* zqwAx`M=y!KG5Yc7lQFUwMNDCgE~Yrf5Mzp|iK%r z=INM2F(+ewjQKg{*O=2WzsKrgt+C~?m9f>awXq{&N5)QyZHeuOogM3r?TWoNc1`St z*hgcZj6D*2BKF(Z?_+<6{XH%sE-Ef2E-o%3t{`qmoF+~eH$HA^TwC0=aW}?28Fx7D zow(2Aeu(=i?w7bzalgf#i8~t~9UmJXA1{qhh);@7iBF3!if@R&G`=_f{`jZjpN)S$ z{>Av0<6n(G5`QB8yZDpwKgItNe@eni5+oUtEJ=<;DN#u@5}l-2Vvv|57Kv3-A{i+e zFKL#vN!leHl1_<7GFRf0tdQIwSu0s5*&w-9vPp86!stRjnXFRROxhS zvvj_6y>y3km-J5QJ<>hW`=pOapOHQ%-7kGn`m*#L>4(xI(odwvq+d$EmY$IQEW-}EzOeFkTx&v+O&0P>(e%*-JW)5+TCe; z((X&!oAzSb%W3bVy`T1B+Q(_1rX5ZDChdo`pVEFwJ0)l2QSumhoIF9EBu|m2$(3@Q z+$cB8t@09inY>(HDIX=DEN_xekx!GmDQ<4O@Au=ne^w<_ou&@{!#kJ>7S+_O+S|YW%|kVQ|Z5@pGiNP{#Qn9Mtp`e zBOxOvLz$t<$jdNfm@+IGwv5`0hKvarlQNnzyczzCc^L~b7G*5YSdpnI zCgYooUotZ?6`8e}4Vf*OZJF(v9htK;-I-mP-I>cW`OM{+D>7GQuFkwRb4})rnRjNs znE7_*H(5DZ`mE7eO<8SO?O7dJv$Nb;U0DmW7H2KZB3a9`R%ETrx-aXS?ELJDvu9*G zvRkv;vpce9XV1@Gn7ufAY4(fRZ)bm)eI)yn?9Z~l&OVX-ZT9!sKjb9j7;`4(H0QMB zwB@wtcyhXPyg93K*5<6w*^qNv&gPsgIlFW2&AC740R>XTDN+<^igZP$B3m(7QK--; ziWCNgNztshTJgBzgyOW~jN+^kDJdnRj8i5klawjSG-aN0h*G1}DUC|A(yFv8rz_i) zKIH=CBIOb#uUxLYTzQ4^I_0g(J<9u)4=Nu~KCXOH`Hb>;<%`N!lt+}GDnD0#sXVUy zR(VqSlk!*PZ^|=+QU>VpGcGXbTaMcJ^ zoobY7vZ_fnMKw+3Qq5M)QFW^3sg|iORb8%Hsk%yawdxMlZq?JOmsAH-AFDo5eX2UD z`bPD=>POYjxooZ^Hz7AUH!U|Kw>{UByCipc?uy)1xvO(;$X%PeK6hj8ZMoZX@5+56 z_v_qK@am4vhfH9%ktLe?Z|sJZ-3rPd9UWZk#`{P?YwvM zKFB+g_i5hed0*xo&-*q%IzKL7nxB}Tk}uEC%+JXml%JPhkgv|yR7czeUW;E`eJp1dV+eAx=G!l zcB(tnv(=qyk9vXnQuQkJTJuGXy8tk-PR+@|T(Y}MSQc~JAL=2gw>nm08EG>0@FX+F^$)g04&r8%zo zNpn`qX%n@X+H9>tJ4lp4R@Z{X_ew4(XzF zu{w!Prc2VL=yG%gI=!w;H(Xbz8>Jhg8>gGBo2r|ko2hHnIdxsS1v*}LjqYaMdff)y zt-4LR+jV#9?$Pbh-LHE$i?vU;y-N(95bw_o_bl>TI(EY6YRrj0jOc7HQUzAal zTa;f^P&A}SQ)Di(6UgRor7tJm57tJqPShS*OWzm&IR~MZu zI$QKtF)n6`n~UAWJ;e)(7Z+br%okr-yt??>;x)xL72jNZfAI^&-|9KNLa)^q>y3Jg z-mbq$KS@7R->F}uU#chi<@y!+Rr=NX_43ILFv!oNM$O=NlIqR~T0suQXn5JYqay{M~rggiN%FGewzVO%hYKNomS8 z4K@uiX-&l@qseR5%(Tz+l<6JQC#IvOFHB#V{xav7HD;|@ zXD&9En#;{q=2~-|d6ap&x!vqCyUiZ+T=OFHGV?X&4d#vJTg{uycbRva?=wGOe%Sn| z`9lLS#m9dEki6?3tT_2m@H+MI!lXXq2(IO zR?B0SLzd%Kwbfv?TdS<~)=AbW*6G%n)>+os)=q1;)oa~ueaiZt^)u_Y)|1wstiM`+ zv;JZI(-vb(uqE5lY#Fvewme&bO>NWKCfY8u?Xf*#d&>5@?E~9qwqv%hY$t3#+J3Q} zwwOEXJzOSPrNrS{VD(wfrArBh4WN@tb2O6QdNOIMYyF1@yNP3cXg>q8{cTOCK(MwDgIx__B<$tg@W4L1jf{`Z8mgrHn7TrtG@1HDx!IeNpyP z*)L_M%6=a + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..336f995f --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + YogaKitSample.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 13687D421DF8748300E7C260 + + primary + + + + + diff --git a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h new file mode 100644 index 00000000..fd215a3e --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end + diff --git a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m new file mode 100644 index 00000000..7b256fa4 --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m @@ -0,0 +1,28 @@ +/** + * 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. + */ + +#import "AppDelegate.h" +#import "ViewController.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.rootViewController = [ViewController new]; + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + return YES; +} + +@end diff --git a/YogaKit/YogaKitSample/YogaKitSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/YogaKit/YogaKitSample/YogaKitSample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..b8236c65 --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,48 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YogaKit/YogaKitSample/YogaKitSample/Info.plist b/YogaKit/YogaKitSample/YogaKitSample/Info.plist new file mode 100644 index 00000000..22ca2cd4 --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/YogaKit/YogaKitSample/YogaKitSample/ViewController.h b/YogaKit/YogaKitSample/YogaKitSample/ViewController.h new file mode 100644 index 00000000..3ac7561c --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/ViewController.h @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/YogaKit/YogaKitSample/YogaKitSample/ViewController.m b/YogaKit/YogaKitSample/YogaKitSample/ViewController.m new file mode 100644 index 00000000..9fcdcdc1 --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/ViewController.m @@ -0,0 +1,61 @@ +/** + * 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. + */ + +#import "ViewController.h" + +#import + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad +{ + UIView *root = self.view; + root.backgroundColor = [UIColor redColor]; + [root yg_setUsesYoga:YES]; + [root yg_setWidth:self.view.bounds.size.width]; + [root yg_setHeight:self.view.bounds.size.height]; + [root yg_setAlignItems:YGAlignCenter]; + [root yg_setJustifyContent:YGJustifyCenter]; + + UIView *child1 = [UIView new]; + child1.backgroundColor = [UIColor blueColor]; + [child1 yg_setUsesYoga:YES]; + [child1 yg_setWidth:100]; + [child1 yg_setHeight:100]; + + UIView *child2 = [UIView new]; + child2.backgroundColor = [UIColor greenColor]; + child2.frame = (CGRect) { + .size = { + .width = 200, + .height = 100, + } + }; + + UIView *child3 = [UIView new]; + child3.backgroundColor = [UIColor yellowColor]; + child3.frame = (CGRect) { + .size = { + .width = 100, + .height = 100, + } + }; + + [child2 addSubview:child3]; + [root addSubview:child1]; + [root addSubview:child2]; + [root yg_applyLayout]; +} + + +@end diff --git a/YogaKit/YogaKitSample/YogaKitSample/main.m b/YogaKit/YogaKitSample/YogaKitSample/main.m new file mode 100644 index 00000000..9e12b064 --- /dev/null +++ b/YogaKit/YogaKitSample/YogaKitSample/main.m @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} From 73662ebf83652550d32ae3a84734dc9082a83680 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 7 Dec 2016 17:41:50 +0000 Subject: [PATCH 108/108] example license --- LICENSE-examples | 9 +++++++++ .../UserInterfaceState.xcuserstate | Bin 19846 -> 20985 bytes .../YogaKitSample/YogaKitSample/AppDelegate.h | 7 +++---- .../YogaKitSample/YogaKitSample/AppDelegate.m | 7 +++---- .../YogaKitSample/ViewController.h | 7 +++---- .../YogaKitSample/ViewController.m | 7 +++---- YogaKit/YogaKitSample/YogaKitSample/main.m | 7 +++---- 7 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 LICENSE-examples diff --git a/LICENSE-examples b/LICENSE-examples new file mode 100644 index 00000000..87f537d4 --- /dev/null +++ b/LICENSE-examples @@ -0,0 +1,9 @@ +The examples provided by Facebook are for non-commercial testing and evaluation +purposes only. Facebook reserves all rights not expressly granted. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate index c1f7d4ac339e1f4264645cb736068a1b0e839157..47db969a47042b4903b4e9d2c32d6e0280b8de55 100644 GIT binary patch delta 12461 zcma)h2V7J~7w?^!doL_)dtq5%S(c@5f!$>(h6OA!*4V{DP(e`yrC5VI6JzhLU84fl zXsofs*b`%n8WS}}V>B@uV@Zs?MUywnf@0$L-qWALojG&nv^nR0X2vfDPinzT1-j2a zm=zoYp?p?Ox~rV2U@Dnm%y4D|Gm;s_jAq_t-e+bqiH1`;3zG9U*E zpahXX52AnpM1vR*3*taLFaoO!q=QV516qJqpfzX@-UeMkF6agFK_5^8O2H5?6qJE6 zzy&ZM;5{%7OaW8DEU*wP0*k>C@Bvr}R)N*bH1HwV1U7?h;8U<08~{haSKuf(1x|zS zz;!Y+JFp+DfR%6<91cgok#GW>2q(eGa0;9Xr@`6K4d=iGa0#q|weUl@0d9nw;Ky(q z+zxlaPvJheA0B`Q;b-tDJO+=$Q}7(T1b=~-;Y}C(9sU6yz=!Z}_zz-`1WAz$$&msn zkqQN)XcU8DQ5=d#2`CBKQ3}dJ*(e7!Ma@u4)Ead_T~Jrl7xhC0s1Wr>gHah8g+`-y zQ5714#-j;nB3g=;q2;I=)u39m0u0WpoAoimsv?=oY$%?z1XZ!-ldEtd2FX(QG`Mz?xYLYh&$f8k^2$vQD-s z+l+0=zQwj>+p!(lPHZ=}JKKxx&GupYvi;csYz14%4r7P2W7+rFaqM_@f{UHVPGTps z^Vs?90(K$0l3m5FX4kMEv)kD1><;!b_H*_S`vrTFJ;k18zhf`4zp$6tE9`Cd4ttlq z$Ns}H9N+@EAWq1MI1Lxdg>m6rJeR;Fa;aPzm(I1|-sD+`HU++*s~?ZVoq>o5#)P7H|u>MciU;3Adc9=2mj6xGmgH?n~|n zcbxm0JIS5m&T$vGi`;GQ4tJNk$KB^1a1Xgh++W-?p5Xxxd7cm819>qo;bpv>59Y&p zEg!+#csrlMJNQ&SjZfz@_$Ds?4L*~1@>zT~-XMUHN>z58s#X#~1L0e1Co@ zU&fd775o_9#bciEQ~0U;Onwf(f?vt6;#c!)`1SloeiOf$-^L&0zu*t^NBLv?H~hE! zcl;Ut2mU<&6aO=Rh5wbm&fnl~@qhC7I_pa+i;GV&0(Ts1L%-l$cOUkB)D0JIz0R%! z8Po6_d=h_$f5IU+5f}Do*|b@w{64Mo`xF%CiA40PUO7{gj7 zk9mj5XZkRGnSM+GQ^@qkp*ReOV=a!rIvk1hIBG3Z#0+HgOgs9wgehf)Fj3fmGwUQw z#6@^4ejif>a*OFcd}T$avVsD4xMZH53ha@#X+fXL{{0K;L_Ez@F=H4P-5xW9d5;waffK0NjrF!V$yga1^C7d&y)Pgf)iCSbdjcX| z-sKyZjm&Cn#ujY!=vg^rNNHI`QAvMo^P=K{auMIK&Bx3(N|%hS*x0LkY5)9IMHLoW-LvtlB&V2tRM7p*0p=h>dh{#pTRFI(#BEaueH}OzGkKz>ZXEW8 z(Cb*QuwO8T-Fp=ZD(si;-3pb!JNgxK)ZH&Ifn|;{4*E-clUGgsH8u8BT5kw517}cQ zG{LmIcw*!flT^*TM|~6IJEQQwN9(vtkLku@NJaWslsU;<`u+~PjCr#EKnEDmfmW`P}~00&6L zy>M@whu`^E%z8pJ4;vezr%@m_3^j_m`XTUUU5w@bKVl5m$Cbf7B~;V4V`*hs--4Xd zeg&sM2gVhz4Rr6^wqxfGt!qFx zrhcpk=;^NZRmwmQk0rdS_NI;md3b=kzfzkF`U0AcR)Bt>02G4$cpx5xi}BzUpa={E zgFrDZ!4()|f(yH~E-0+%QdBV9eL|^fp6g9+ZK#mlI~4UFP&ZQ_7@!=C@bIhvm0%bc zj!W?nJQSC$V4|3IU^Jtr?o7nxG>sLyRjPNjU@Vig{6$oO@n9kiRxklqR)a}+7$w^8 z6Kn?4z|0yj9n8SP@w?d7u+wZXmyy%}H<*J*VCwF9U_Ks&N7G;t_(r&1h#cu0jTz6M zhILCp^(*UYKrODqV{q4!t7&7vM0Sh$m6CKMYo@!7*^+mFaK5w|EMkN~bRd zhrF=e8F2Q6q0iyzxX>FOKYDh&050Mgc=pR3FM%tsu>2KV#WV3NoZCLq`Tl@cY~$}2H_!qzKmfNgb+a%a*&5Ucp+Yd7vm-P1H5z<6hJ@d&qTpMS~Hj7HFzxz zx(%LcnJ1EYiuZ^i`LyixYgth+xZG1Xd(*)#Mdd}*xg84nR^*9{-P>rjpd5;AJOJEq(QoF)%TvH7raIMFa4taMN1>@+U zfCd=Nd<vCYT7t%Dx>s|yLYzbS@3Fc#*Tn$^}^)Dyd!M8mV z8?d<=cEBIKoahX@dL~xlgzCD@8)6ss=mUGb*u6L2_;UAr*yoinhXt_MRzfqT9u9?N)LYx>ISRqw;IF6=9|^SXg@ShOF@liP2IWRU z%otX}(ePbZ1;;=a-hp@GPw+1M=}Ji8dlWnA;W)e-@1a~m@BzxDgWoA3oDOHzz!`8R z-i!C){cfv&OnW#N&ZDKH{(N^VsHmkQ^BD)tsPv=mWWa@BW;I-d4`NrNlEM(Ul$j5g z!)ls~Kc^+-GkhXXWN}ZIE8NlmZ5&)dD+^o+SHabA4L*dw#7FV*7nKFBgX<{<`2rut zMt4bozC(T8fSX|%9X~=fH+JhZfP&0^T8oHnnB7rVRgS%`s??z*xVw(vYY&0j7??<7 zL`jcQoEm-(57RJ$hu|0Z6h2);Q*sowGd&mXJW-Yleht5&F0M;RZb6*A6kxn$aVF6o3Lz5E3F0-QflS#|ij`fQtnDLm*R^ZL+E6gNBqAl~j~xQCu?2y;}2; zRgGwlScyWA28E(96pnA=-|-*#7XEW3ia!A`|r*GU7Yc$c*pN6Z;Z3AX^looc88qLbRFsC&@qPRNKdc3# z(Hkg}mg7hGG2P=%Sftw)9^saRNA{A9_TVgYRf2Z3!$E(uTav3N(4qhpHHWjRQ49P8 z@ArPc1!gXP5frEmYUh!sE&i(-wa3q2m8Wx^JkO{+PInKz|7@+VsT=A=QzPn*a#0V| z6aS6>A%J2Yumbf)dFUOKPXHt!fB+olJJ2#^vWBS5|u%|T<)JTxCI zKnu|#v=}WRKvB1al1PDyfM5dD1cVTvB^3S^x)r(>ZZ1;d?xfr7W_6N=5{TBIwXft> zv>s6e(g;(aO=$D010SPpuMX@)pLhqnZrlxLtw4LwUbGMGCqP3$C;?#vgya2rB6aJc zl0n++BKQ2roUAX=k;dzeQAmks=ttt9)94%8Inn+JeTz<_Q|NT}^13QY0XYE%0-^}e z6JV@&zb5)D`q2}T=g<%6JOR-J#1If$i!Pvx=qCc=2#6;jfm&gyJ}>Gw&o#+(Ad`SB0&)mwMnDS!S`yHTfHnlQqbyk;)|VBq zeyl$mzy`8GtdJG4VphURSs5#5sZ-x3%|K@YdJ#ZFxPX8n0tOQ>lmHrpBMEqy089Xl zuL%T9CV)b)MhBM-@f;KalJZ3HwB1y@`x_*Rm*<+*dZ(>AhWHq@r21ck(MWl@oXIBfg`5wEt-{74lXwiXiRDKQfB0dqCAx0 zUP?;-DjDsWJ(|4X-qWOmw2=yLc*mV|yuJJt#yQ@ZY_~8ruCZ2cddHjQiA;1uo%>c? zfP8RciQ0Gxnp36Ps9u@r;GKE%r8!0NzKxf5^%A`0w#VVdd-n8>w|=>2P-7+Xz0+;o z!uZ6-%L={Y?dxshdTE=!^)-eqVoN-I(!X0@wv?q;J!}~P9SG=%yAjX{7e;37c}xt7 zEKPS$Qnr}wNmboOCz~Cf1l_=I1Y1S}Zw-R~G`h5i8wwEL5@juD*faT6V*0`E6u3QGQzpC?vFZ zrThlei)ZOB-rzM{EAwUgcR3O`rltdx0;bh5Ofn~1 zsesf6)c7wff0#Y?3d06|$JwtbKZ*!w@+oT%kW3` z0%b@uBaM!755tOjhS|sOY^W0}$&vD31OCe1pzK~B88_MAJ&|#XfMJAo>y+mRFVErI zD+W2dLfR~rsxDqM(BPB%?333@_>}$2%WV_^qZ@G}N!Q!-X;3+}!Ezkrd>Di4zlVVH zYEDPAWQr{q+W9WAW%1ia^AH@2Q# z%#jnvTwb|StRB<7dZ;)p7xlkP#~HY2udd?=7~e?Os_`ur2kd4f~~mruGjK=o9jUNbs}H}0W&@PX4UhHbY9-$wV2)J_%Fj;j>5Sbt_RnX05<`1 zYq;KA9s%N?cCB5&}LTU^&fg^UbrQRUB2Vnj1sF(rS*@+GTV+ z-ICaJ95;a$7ly;9e@^@@UjB_X)TE|4XTZ+-Kb9+@X4`|)c=tL{6DHeOG(dNba+*ckIj}owjs+iq9H!<0fSYa;nZkprIo#1H8=s}(T z(eX5Q#v|)@1Z=P7z9(SktKR?7>*O8oY02H&{lxu7+b!;A?h^M4cbU7w{mNY>;1dFN z5%4Jiy9wAsz+M9Ot>&(A*SQrv zw5N^YO}v@6@JWoGfOE9{q$l(T0w{|9k$?;IJ9n$qt^hH74&Q=8Y`!VqjBic=tsOrT zaH*DmlW&PG67UNF)F$!NW@RaZ+qMTYSMqQ39r%uXC!Rvr%LLpYfSUO(0S{kvQ+zkR zr-x;CK9}!7z!d_1CE#i;-;3|f)06%i0TiWQrz{g4YoiD7#jm3s%$M+`1l%OxcLM&P zw9g&E(Uttj*U^sRNAvFz@FxMc3AjUPo22Se-s8u=hL)SgPvj@n9oKsV+{cA|8Eq6~ zv?uv#j6Xk}pRsjbYAJL*sPh&-i=W-=#jQ`%{EGZqI^<>?UFa(U{c4Dbx%?7(vZ%WA z`2~Crei6U8PU%MkJf?aRK!fb*D!vyO#4qEQ(`)lV)CTm@9Q;MVb9#G@Jt3r{*N1f% z07VreJGe6(68F3emuoE*>O+2==Wf5EXmEiC3{~yjVxx|J=9TaxeuGz-f*SrK#zC)D zI+gazAF0i+(Av_H?ArEi#BiWD9JkQ>DJBp@?DBqZ2Qxq9ckny;PxxK@r~Gby55Je+ z$L}W)5Qqrm2u$!HP(YwRfq?`H2^143rCxrSqxnO1rxe2f*+=kSc`4X`p?m&>cbxwZ zy5~=OXM8=Khph2t=e!es|3UBkMej_&OAsFL3cTkpdkKPG5(G7>DEu|=w5YzP(f!Y! zhX2D$Dft(k=kI#QWsUj=S6`YL+IDPJFtVUuR$1Qx^g*WVTmB*csB_1P{E7k$7+)rs z(J}G#H8YLLWCye5ET+%@Zk7UMwwkS_&;B2>>)8$Tng4h8357grD|$$~(y;77U(QSU5%jHm91Zcs^ksYt z|1rOvx_%dR`(A!OeI@^#KS$riFVL6qOZ;W}GX5KV8^6i_LEpyz@(J?M__X%P^QrV% z;j`K2bDs-7SA2f;x$DdM`uGZb{e1&{g}!26sju8u=^N*p;A`|X`zHBXUA}f-hi{s1 zhVL7`Eq(j=4)LAfJKJ}S?@`~MeD4a7KqW{Lv=Ouuye;S`=qxA^3>S--;zr}vl zezkrp{Z{*J@Y~^c#_zn}Q-7C_zrf$$KhR(6uk$zgTl|y#ZT>m_&HOv~ck=Jz-_5_! zzue#DKgoZJ|1|#@{%8Du@_*p}G(Z#(9MCkNWk5y1w161_vjW@!a|4zJR0q@stPI!? za5msVpiiJE&>ol`m>*aYI5e<4a9H4oz)^uUfg1z21b!U2Bk+^JPXqS{9(M(v4m=Zh zHt>hQOM#aIe+~RC@OqFuC^4v6P}`ulgE|Iv4(by$G^jkNGH7_v$e__dRY9(x=|MAt zW(Um)nisSnXi?CTprt|Uf_4O*47w_WLai`C_@=P4u($9XVIN^XVWF^8I8<0JtP~Cx zjug%jekwd7yd!)nLLycaC{l=Ak)jw;6H%rpOOzvOCTbySFX}GpA?ih=JYUpTG(=P; zst^qmjTMa(O%P2I%@ZvUEfOsetre{keI(i_+9Uc(bWHTM=o`@!F)t1htHl~|m{=>0 z6`RCXaT9Szajv+pxKKPmJWx!;)5Y_}3&o4YABdNU*N8t9uNQA{i8qP2h(8sd5?>Tw z6F(6DEny^3!b*6FP$HH{C31;U5-drPbdn60%#nY>;f0Y?W-29Fd%q zd@ngCIWM^&xgq&eaz}Dc@>udz@=Wr#G(Z|IjgeZUZ%A{b&7>`)t)*?H?WG;0J*5TG z5^0t6ed#QzYmRiDbfI*y^aJT;>0aqR>3-=!=?Upc>1pZr(sR=D(m$n-rO&1R$bbyV zL^8QdDGQc`$+R+^OfNIaQe;hKEoH4_ZDbu}on&2P-DCr0?heJ*;Uy!*$vt6vIlY~7s&nP zfpVc-Ay>)Oa*aGpo+W=rULhy)>GGNK+44E^dGZDFMe^11weofHkK`NWo8?>O+vLaO z=jDGW#0sY(Pf@HWRSZ>BD26FUC?+fBD;6o1D3&Rz6}5`ZioJ@%iX)1nisOnC3fEc1 z4~icZ7ZpD%eoURT~!{-OL+dB>%^r+lD-Dptj-d{us`09BAmq%y1CQuR~0REt!rRa;aa ztG26ls&=V%s}8GJe(!DD?#OB=r>aH1!7c zX7yh6e)U21=j!9?6Y3w;7u7$je^K97KUe<~0zyzobci{mMaaOA;UVvajG@m#<3c8c zObVG2QX6t8W7m5b|Tl#gN}ZZiU&>d^LWW0F789)yOqUO`IlK zB9_RF=5GJwy>12w6G>&&amvT;xN~$uoK~eaBFy0c+>Fa;Vr{k zg|`XM4euG=JN%vSb>Tb1_k|w_|1A7a__6S>!@mhX8GbtafmWqW)wb7m*Y?!**1n@H z(hk%XYe#C|)sE2;?O5$N?QHEF?L6%Q?Pcw4?Gx=^+UF5W1d0fV5JpHM z@`##q7>{fH+K&m#WO0bP(zs#EBKbz!;)onB|qS#>RRgLD-- zq8qQ9q?@XnrJJLhuUn{Fq^s3!(tW1;LU%-WOm{+eQum$itnR$-qVA6FzV4CksqT3s z6Nw`ENI_&kWKd*mWb4TOk?%!*5VF4O@>lf)i&@a>P)*sNH(x2B~(cjVE)!)-U(El9; zqSz=tN*NUqrH_h^ii=8&8WBaJrbo?p4kxXQStaqHqfirW~sCGJYxow$2( z58@ujH;?Za-#NZ(d~W>2__^`(;}^y+NeD@ZNr+2GNH8VjCzK=%NhnLGOsG!SkgzFX ziz{JU!i9tz3HK5nBs@xZlJHj|o9L71ml%*JOcW=o6ZMISiD`*BiOmyRCbmv&m)I?_ zM`G{9cM|(179`@t)rs2@FC<<~yq);e=wlQaB}SQ1VN@9-jCy0VG1i!1G#XQkPGd`B z7h|3=-`Lk!VC-)kVk|cfGmbEhHdYy3+{;{O9%8OCk2g;= zPc~0APdCpuFEW2%US_T_uP}dP-frG!K4$*T{Jr^{`Mmjp`KtN4`FHaz^Bwa&^D_%? z5n42sC`*hb-eR=4ES5A&6N}T5ZE0p{VQFvaZYi{sT83K6EtQtx7Hk=78E=_rnPQn{ znP*vU`N*=}veUB5vfHxPa@g{f<+$a9<)r1b<$~p^Gz~Rliy12 zn*2_3-{ivNqU7S_%H-k6qmrwVaq@e~OOv-GpH04F^|z|5A=WT!gjH`fShKCItlg{y z)&bT*))MPbYlU^V^?mCE>tyRR>rAWLI@dbiT4UW{{nGlUO<>d5qHGphnyrb=Y0I{? zvE|x&*jznry>0z%6}BoHwvDxow@tFmw#~84w=J@LU|VKeZ`)|wV%uihY1?HxY&&iH z-u8p-g6(J9W!qKTJ=;Uu6WcS}KXzzm?Yv!T*Vx1DI=kL(vS-+v*x#@_?JezH?A`4> z?RoY-_I~!E_HuireT4mp{fzxr`!)Mb`z@FKj{UyIgwQo>TS zDQPLqQ@W@0PZ^amHDyssZOW>YwJGaT4yGJU`8ws>lv61;9DWX^L*)o|gg9ax@eZTI z;;=gGjyD}|J32YKI&vL79R-eoj**V>jtP#5j>(Ssjzx|S9LpWGj+KtBjsuRb9j>1o zzc_w%TyxxX+;ZG;+;==m^-c9p4NMiLN>b&is??Cw(A4nM*i>t3o78@(BU7iRu1ejP z`dykLEi_G^W=u;@%T8;S_GVhEv<_*V)4HYgNb8k0Gi_bk=V`~&&ZeDDyO?$PyRq0u-^wRXj=_}ILrGJwCMf&mdZ_-btpGm)v{&V`} z^sDLD((k0-OMjBVX9Q-5GNc)bjL-~iMr4K|BPPR=Va>?SXqV9?qkBfrjJ%A(jG~O< zjM9vu86z@C#-ulHy>aJ_r znY}aL$sCvYVdm+~znwl#p;P4yaq6A%PO~$|+1%OA*}>V#*~OXXtZ)u@j&fExv2(0* zymOLss&j^OwsVfN+F9#d>0IOd)A`K#cNUX{vN~nuXZ6i0$QqFKN!AxxUuJ!kbv!#H zJ0?3WJ0aVYU6nmKdusOd>{;2LWq;E;`(*a%?C)~~If@)rjyfka=gpkXIbCzQ=k&~( lm@_wLe$K+2B{^T^{Frko=Qr>DAB5hY{A2IWhW~S}{~yhO$@u^P delta 11759 zcmaKS2V9d!`2XE|@4W;98HAC+NC*id1F|4dK-}WqiVIOtQHBEUk$bgnt<}_3C*rJo zwYJVyYpvbxJ?dU{*Hzp9g@DE1&);9=L-O3+_nzmu=lR}qcfP8GlNP~G!q5V4p=W8D zp4}{k4`(;5>+S{eKt31;e10zHksMghj9nj)XiM z52wND&;vh(i{TQu6z+gK;TP~rxC?#-zlOWv9=I1Cgoof!_#-?CPr=jh47>pUgb(2( z_!vHcPvJB89R9^H3}RRYGaTdgV+4#pBW5H_7^7rVOf;irVi_G{V2n&MV_~d}lc~$p zV=|eROe>}}(}row^k8~2y_g)PH`A9XUw2SurbNL)cJO!7AA(Hk#G4v1~k>z?xVyYh`V0D(hs^*mSl&+kkD& zwqe_{?bx1dFE)qm%@(pnY%x2E9nFqm$Fft|Y3y`%KD&Tj$bQDIX4kmcwd^`}C;J8a zC3}!P#D2&A&K_frvnSXq>{a#;_8R+;eZ)Ry-?IO(|6(By#6dU|E3gtr;b?5YMr^`n zoP?8c3QomN+ze;o=C}oJiCf{;xD9TLJK|0_8+XI~a3LOp$6_9j$CL16JQL5xbFh0Q zUWHfVHFzyvhd;;b@n*aQ@4!3p7x-&@0DptO!-w$^`~&_OAIB%~Nqh(2#rN=i`~d%n zAL2*&F@A!d;%E3d{)+<~_n~`*PZLZ_2&9=d0akMzzyR@aicjmH-YhnA@jiZlCtzVRrvV!;ZaBMy>6lyueF z5xSTjw_N2(mbVf2qR#JJP*yq^)f{Ec8c(60iUz-F)oYz5m$Dsd7Q zsYB|n0z1G?iX01eku;J{aaE)~#XT-RE(YI#Lo2|y;2_B$^+={?ry{-~I0Am4?ydGr zhy3zNDme<2mQw-XD-g zq%CPk+ISL`uDaknu&x9bz(sHgTqcc47HL6R5z%q*2e?LuUk5k9&2CwF`Nic0{R;9+ zJ7pE;<&PjuNK?|xGgBGs?^~6-;GXAvKr~tb?t9J#Xj}UR|4F@flQgG(Yu2^n02-Nj zYD*39Q|i^5q$Txdv!2-{{c~Fsly}H28eEuP)8S=Rht}Q>9;7l=PxKG?*P{qDvJe0# z{b2A&!^1lXs+|p4D5Q%CG31~h6o5rAfOI6CNN3W8E@s!&Fc9dVi2g{Rlw{LI%%ea3 zNPlkj{PUtXqjzmo59r6q5!sh37EX}9tRizPBKotnCfJ)M> z0!EPTMCa?;Ik#|Vep&sp+FjK!hGrbpkRBCKOL~%o|7oxfF%BAmekF{D2`~{FNH3B@ z+`UPzR}v4CU_6!dB7NvjLfeibsmI<&=~C^)8vRmX9iU%9N4n^UzTOW$0BWkF!_dKl zOG?WNiu8 z2RpnowIeAY2{jE}V79j*k@T*B-N?ZI8hXMUZ$mFKsG>?kuYUgrb-_H?-)mEFKI}(| zNHI-Gnw0IUl5x7Kz8e<9!4#{C+Tai}m?Tss1uO>zm2fB=28WX&q>K!GM{jTxe4mr* zK{p8@rCv@NoLR+5HTqA0lip*mMsNyIkaBO&>BQGlT^$)S;H=tR;U^Sym>1MDBSPtf zbKwH75%b`DGJ;Twqy$iv`qXfhm+Z^h6c>)H<`b_Y+VmMngRjhUAR@+Hqs=n74(Qjx z<*)*-fR%71Tm@IdHE=B%O~#P1WE^o5LU=NsOjt*weLbC{31|X0!!2+t+(!NN5uH&< z|860N$amytZ~RNVb2rNGGqivI{8H~OLieS2yGpB)y!@OF<(?jb39;P@t9GZ_0lp6& z@UG#0GO+@FLnhHE85NY23BQBid&P&zTToXhPPI<&K(hnUW}ZQ;2^Ss zG?Soe;)97yBo+21E2)sF7BZSDHeBsx!}s(4IHLzbCXR_`62OV>c_n>^7E!M5)V^hQ zc|lP=tttdXgUMR5jsTA&v28$66<;$Z#_YK)3}=}nN~4#BVVWFCRAzyfe!Zh}z5BQN z{VeqSCP{3@*yvn#aDqu;;=8o&VD6J!mfxNJF3m5bV}|7uKsJ)KzA0Qx9lA47MOH8_ z@8(Tw4GQra9S3c9Xqi zA4%xiGQVHBSDozk1^ow9ed^|`k*Wey66)pX!G#4?Embk>4dCi{VcIdBz0enWRoSeL(xHYShhM}wHjCwnUB$|}97 zBBfc1zGQaM zUYnWS^z60=boUhdw|1W*XUMO$6L251zd8X=lHYs@=nK0;-UR%PIm~=dekaGs@ed~8 z2hy)5`Hod3---8=uU%EKQak&6Y4)Dd%z3KzZqS{UVBN`SYSkG+D>82?T=AyDR%)fl zmoC?t8=g&p29~)=Gjda4qOaazZZmg0lAt)2xl6^8AbsnaRlUzVqb$fgVE$wtGLM+Y z%oFA*IZrN-i{uiyOscsnTSp#9 z#fVl-s}P6$;63Dz0?0LToigPOa&r|5L_tV|#7IJJk;gpL@vw}C^SoIQ=Lw9C@Z?4{ z_52<+C^j4^XpkW}xm|&jh3qZ;DTfubppbFd9X-e>4P@qB2yD zhN59;I2wUQ@{r!RFg!#&WO;~r$nnsRhXNk@uS28J7&I1*LvBP6kH(`3JPhEWkcWXh z4C0|k#6vL;B|Hq}VHmYe9INt(v`syOwQD_{w81sC2bzUGd5>R^2Yu=jw5{>t0<`e` zE{hR8WO>WSnjXthg-_sH(3RlOO0){CMr+Vo9!hx_%tILuLr7+hMA@>Sc#yh*XKiew z`diS}+QW9x96~#JC?}#5XcyfC=~jroLSLiZXis)oRnbm2G9IdUsN|u7huZ1|kBB>f z4tc}y8}uzY$ioO8M)EMK5`Bjbqwjeb%|kU$3-$!h7F~|+SMM~x@i6Ayu7HlC6E%v^ zgD*Ob&Um`()wmL!Mdv)(`fl!v=swVILYL5GbOl{Sf1qpVI=X>wqFd-Tx`Xbbdpy+h zFrJ5rJT&sq%)?|JT6t*aVG0kOJgmdRG#+N~Fmn@nfc``e(IfO2JwZ>=GxQw&g zR-x}9%6u(Jp5z2$Z78`Nulv430^YML#n&g@v)DjtW7hS_>(RL^?|U%Q*HS-6 zlJL&Wq@lmtx39Ae*=F8D-~TK_*(|m>(6KFf*pP>fNP8YOCJEa5dtZ*2Fn7*SUm=>D zVjbJrM}XC7#kOa=d=RZGn@!QW^ROuon|aZ)7#iCbO*(fjOUs)N%-^3K;G4e%4_nrn zf6U$Pqi%Hd&g!tF)^IIb!j^v!Whgt0qKx2SYaX`oqO|o{F}BzEdVhLR+-keS>Mf`3 z4lj|{*fEZs@Ikzf*oi)^C{%~qS{stIy7!JUtmxyz12-{zds9r%ykJ#q!S1UF_Zu!t7)B`(S$WFt--W*oC_^ zzgMZ{c3D&2!5n6P{29avt?t&KI^Q>E^k!0Y_+4}I(z4XfOpw@J~IdLu&}n7lbS9N z`}DK@7h6x*7yqHS|2z4yFWFZ<7`kJW)P|XN-Y>zYmeXdh@fHRc|A+G*4Cb((4`v7t zOKZW5;3YY(Ds5`{+<`?{O0NU37}K4%oQK0!;9yL*KAJNhzsJ|OnjnYfNP1Hu$?zoG zgq}lIc`X*g)l50u^U&HiS&em6KdiwqSc_wMNUMWUJRHr#F)NvD9EamEExC9&mWShb z$WuBPZ<{T%U>hxGu$8V%1*TgOp>n<5)X0T1>BSnZgX`inoQ^YaJ^Hl6Ls~<8#KVa^ zoW#S)t8snY05`;qaATn3;S?TD<>53Q&fwupdd5od%(pN1Z%6l1OqYDRC({w??u;p4 zdFujgz2B-T9C}$gP$RbQh>OC81_J7ET zVR$$mfk##wF`I{Tc=#y~=X#CkG1_FOIc!OBnH^)RiWfZ2YZ8U>5K*@V+1*Swr>Q)- zv}V=`_@n>B#3@)uPihsIdTD+Ip3cLC?=Sc#zMW$M-S_HyzDkj|@!&c({BGUW}LErFa=$jw|pA9#-(Ml838!xSEG+c({Rw z8|iweQ;Bc`I8=dY8L)z0GOtgK6mIo?-^Rn0^!xGD3^)D~@ABziW6*9)$)*DD;o;f} zypMP4-fJ1M;=mzkMr>KyXv0{pLqB)4}YQAlj%zy&`#Z{!O()jyy~^$5;)U`#+$h$ zj#itrq^15m<{dBb0kp59u6?`Y$xI7KP2uQ8^8ZpB*XPo>^r|dB!NZdzp)XL=YcusR zu09ZQ4Y-Ee`Lq(oeX45FxyD?Rp6^~R8s(PfR#H(@;OtCai|Dr+b+fp(G()L}T5v5n zG1r=FQ{|^KJUmNX#lv$vJinTgGFe;)t|Pr7%A#%~bm1=W@DjZ#+Us>*485kPPamL$ z6_k%`?fOMR&LoZZJ25E9J_#avuIsRjy}L)#}%Ic!P(xczB10_jve# zF8zPyDmT)X&eyyJZbIz>7wz`7C~Ef}?~~o62bPw#D4v__li#i;1!?WJ8NRl=-a@&y ze6~-1-&^q3me2Fa|MV8=@&Po7TX$%YKQceBerewU^fIsXckVN8k>_f|aJPnyW9{_8 zxG8-s?!b0pyRbdzV{vb`4}Bh9&TeG)u>05p?6>qa_%M5fJ<6VC&$AcV%k(|?8heAi z#ol3G;t2Z2I|FZ`8GZx*OA|#%*I7&-T(z8$KC!xJ%(UV1xPIIKZXj346;mgda^>`G zbp$ul&CTLw(+AbL+WhkSpjb$QKM06bgz3g9Rf6;{~$?3k2>8!Iy%4f*%FP1SbTi1ZM=71y=>v1UCe? z{5gN6f4YBj|1SR7{@wk1`seuP`uFu8>|g3%?mx_bg#Rf2G5+KH7y57a|Jnbx|BHa| z07Za4z!G2!pjX2Iu7J7$O#+$)G!JMQ&^n-PK>L6(0iOo!33w!w3e~~{p;?$Lvc5A zL5V@eAahXrpzc9=L9>EB4cZ@cD(H03^&t1-pr=94gI)x^3VIXtRumu#6p2I=DlsFAy&hFL8^Pi8qKh ziZ_Y3h`$$~5T6#G6<-iv5?>KN5I+(>5kD8d5WkXe5`T$MB9cfX!IEf6j3ibPCrOYP zBpH$xlD3lel8%yWNq0$4NseT=WT9lWWSwNaWRqlzWSeBSXO!#rc3Kd+e>q#dD4E; z0n#FAiFAmxOgdY-U3x%zTzXP^T6$J`UV2e_S$b7^O?pH6Qud8`*ENW3m&nQ?fI%bFvGvOR@*D zhqA}Ar?Tg=7qVBfH?p@O0U==_mXO9FxgqY5=^<-Ec7*H=*&p&v$ia~BLVgMPE#z3p ziI7tvXF}XhLzSWNp>0F6L;HpnhVr2kLMMh!4xJi0J#=sA;n1H$e+~UT^mypW&_6=2 zhu#dm9eOwPMd+*0H=%Ds{|yTa6NO2_g2U8drZ87n!?4C-O~bOnJ`1Z1`zmZ-*om;` z;Zfm+a9eo2@cQ8m!yAXU4(}MA9o{EAKfHfx4~734ek=T0_}lP*Z;@}4?~osnAC;e$pOasZUzT5$Uz6XLKbAk0KbOByunK>LP!XgER)i?R6mo?| zVOH1_ZigaOk*3H{WGWgcS}3|IvK8GFJro6sLPfD+h@wm}R54C5K`~J=Sus^HPq9d` zM6pbO$0|s4G!_MBRzH7xf_OVbtU3;AmTP=jfd1KGAv6{h~{v z2S=AiPmP`zy)b%F^wQ|%(JP`iM{kYZ9=+482I?Snm|Ct@sw31<>Ns_R+Ne%aTh(@T zj(VngkNTearTUHftp;cq4XX*#1ZzSxVH&wcr%BWpHD--X6>~i1Z*90XR;$zMweebqHbtANb!qEpn`)bBv$QR=UA5WT zZrUE&0_{NUAZ?L$nAWWwubrr!qMfdtsr_8LS^JIl2kkNKW$hL1RqZwHeeFZ-6YaBD z94n3ujtz~K$Esrc#g@2Z$HY#EofJDYc1Elxc3$kl*u}9+V^_s)i2XJ8PV5W%3XXJ~ zPM{0bh3Ud|3SEq@fi6o|pmXaM>Q?Ix>JICE(EX(QRd-BxQg=poUUx}%Rd-!?OLtfI zKp&tF(o6I*eVAUMkI+Z!WAr+GyxyQU>n(b_K1JV9-&pT%s&B3zp`WOqte>i%5$A|& z5Z5TKNnBRkCvi*Smc>=Xt&DpT_b>e)1}L73x5Q_}XT~>(ZyY}_zA}DQ{F?aBGWwD+v!09wt0ac$OHGn3QNqv?Zn_?o9kP z@lfL7#2*sh7zA!ZfFaNzHqF=QM181fAR3 zLxrKzu*$H;u*I<5@P%QQVYgwg;jrO1!#Tq(!z05J!!yHQhL=WYWQ~4Ce`BCgWDGZ| zjV5D?(P^w>OfzN}n;M%NTN&FJ+Z#I?dm8&0ON{O@#)-zs#;L~X#+k->#)Zbk#-+vz zW2JF}@eAWY<4?w4jK3L=8BZ858m}0y8E+VG8}AyQ8sC~Ylgt!hiZZE9F{W6P$&_re znH(mksg9|ksimotsgG%psmN4f8e%FljWM}R<4qr#CYz?3=9m_n)|s}Mc9^~}?J|As zHXSq_HvM4w(e#VyH`7_uAEt+mRgqb&gY@TmkXkKJqVqRumYhG{OWZq)lZr*9$Xa3%N z!hF$u*?iS}&3wcBr}?q@nfWjCE3^Ae5}PDSQYFPE>67A<5|fNcjwEMN-K6xS%%lcM zEs{DWcIL z9b=tponxJAU0_{gU20upU1!~3-E7@v-C_O4ddT{{^{Dk{>#x=e);rew)`!+7*5}rj z);BhRO=uI@q_z-SxJ_Ymt8DQ$i_LCJwYhAKZ0&6AZ5?c#Y`tuQY{j-AwsPBW+eq6a z+Z5Y0+f3Uf+dbQB+gm%ZBRgmJw+GtA_9(l?9&3-YC)!Q+WV_Aou(z>yw-?*T*k{=* z?3?Yo?7Qvz><8?p?N{vA>^JSV?f*KW9Y%-AVRj@t(%p_sM?*&wN0y_7qo<>vqrg$< zC~*vNjB>agA3GK~7CV+WmN_;!HaoUCb~<)BzIGgOoN`=qJafEoymq`z0VybjOYu($ zOo>cUr^KYhro^QrrkGOb4RVS-B_ky(rBBMpl#f#?Q+B7ENV%J8NVTTAQX8hWP3@A} zEwyK=yLW2;)Pbo*se@BXQ&*)PNIjeSN9u#rN2yO!|4Mz8`giI-PN6f{8S0cfRn8cv z&Kd7CI8DyZ&X1g1oL@N)IDc`TcmCnL;k@m<=X~OP?tJNd<9zGlTmqNKrEm%1B*G$(u*U~hU#-)kVBGY2i z3~A1^#%aycTBNm3YnRqBtxH;7TK}|yw8FHKv>|C_X+zUKOWU7zCta2vksh0FN>5IA zrDvu$PVbuDJv}eIe|kasp!D+esp&J)XQj_cpPRlQeNp<-^osPA>1)#0rGJsWEB)*A zzI!u78LEuPjOdJ*jHC=phAkr{gU|RlF~U2jjlef7S{6lZEO^_fQB0h?ibzq!TLC-&-JndbioygddR diff --git a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h index fd215a3e..dd7af882 100644 --- a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h +++ b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h @@ -1,10 +1,9 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 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. + * This source code is licensed under the license found in the + * LICENSE-examples file in the root directory of this source tree. */ #import diff --git a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m index 7b256fa4..d1840bc7 100644 --- a/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m +++ b/YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m @@ -1,10 +1,9 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 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. + * This source code is licensed under the license found in the + * LICENSE-examples file in the root directory of this source tree. */ #import "AppDelegate.h" diff --git a/YogaKit/YogaKitSample/YogaKitSample/ViewController.h b/YogaKit/YogaKitSample/YogaKitSample/ViewController.h index 3ac7561c..f5642871 100644 --- a/YogaKit/YogaKitSample/YogaKitSample/ViewController.h +++ b/YogaKit/YogaKitSample/YogaKitSample/ViewController.h @@ -1,10 +1,9 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 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. + * This source code is licensed under the license found in the + * LICENSE-examples file in the root directory of this source tree. */ #import diff --git a/YogaKit/YogaKitSample/YogaKitSample/ViewController.m b/YogaKit/YogaKitSample/YogaKitSample/ViewController.m index 9fcdcdc1..a13dae6f 100644 --- a/YogaKit/YogaKitSample/YogaKitSample/ViewController.m +++ b/YogaKit/YogaKitSample/YogaKitSample/ViewController.m @@ -1,10 +1,9 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 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. + * This source code is licensed under the license found in the + * LICENSE-examples file in the root directory of this source tree. */ #import "ViewController.h" diff --git a/YogaKit/YogaKitSample/YogaKitSample/main.m b/YogaKit/YogaKitSample/YogaKitSample/main.m index 9e12b064..bbef0040 100644 --- a/YogaKit/YogaKitSample/YogaKitSample/main.m +++ b/YogaKit/YogaKitSample/YogaKitSample/main.m @@ -1,10 +1,9 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 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. + * This source code is licensed under the license found in the + * LICENSE-examples file in the root directory of this source tree. */ #import