From a048b6e4c7e52f345ba098006e804dc75294b4d7 Mon Sep 17 00:00:00 2001 From: roxlu Date: Thu, 3 Nov 2016 20:47:23 +0100 Subject: [PATCH 01/39] Added isVisible flag and getter / setter. --- CSSLayout/CSSLayout.c | 11 +++++++++++ CSSLayout/CSSLayout.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index dadaab50..668ba35b 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -89,6 +89,7 @@ typedef struct CSSNode { CSSNodeRef parent; CSSNodeListRef children; bool isDirty; + bool isVisible; struct CSSNode *nextChild; @@ -198,6 +199,7 @@ void CSSNodeInit(const CSSNodeRef node) { node->children = NULL; node->hasNewLayout = true; node->isDirty = false; + node->isVisible = true; node->style.flex = CSSUndefined; node->style.flexGrow = CSSUndefined; @@ -287,6 +289,14 @@ bool CSSNodeIsDirty(const CSSNodeRef node) { return node->isDirty; } +void CSSNodeHide(const CSSNodeRef node) { + node->isVisible = false; +} + +void CSSNodeShow(const CSSNodeRef node) { + node->isVisible = true;; +} + inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { if (!CSSValueIsUndefined(node->style.flexGrow)) { return node->style.flexGrow; @@ -1190,6 +1200,7 @@ static void layoutNodeImpl(const CSSNodeRef node, const CSSMeasureMode widthMeasureMode, const CSSMeasureMode heightMeasureMode, const bool performLayout) { + CSS_ASSERT(CSSValueIsUndefined(availableWidth) ? widthMeasureMode == CSSMeasureModeUndefined : true, "availableWidth is indefinite so widthMeasureMode must be " diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 881d8f3b..8a08910c 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -157,6 +157,9 @@ WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node, WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node); WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); +WIN_EXPORT void CSSNodeHide(const CSSNodeRef node); +WIN_EXPORT void CSSNodeShow(const CSSNodeRef node); + WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); WIN_EXPORT bool CSSValueIsUndefined(const float value); -- 2.50.1.windows.1 From a3fc773d757014e81feb968454314427fc2b8d8f Mon Sep 17 00:00:00 2001 From: roxlu Date: Thu, 3 Nov 2016 20:50:25 +0100 Subject: [PATCH 02/39] Added CSSNodeIsVisible() --- CSSLayout/CSSLayout.c | 4 ++++ CSSLayout/CSSLayout.h | 1 + 2 files changed, 5 insertions(+) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 668ba35b..e448a409 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -297,6 +297,10 @@ void CSSNodeShow(const CSSNodeRef node) { node->isVisible = true;; } +WIN_EXPORT bool CSSNodeIsVisible(const CSSNodeRef node) { + return node->isVisible; +} + 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 8a08910c..02d451e1 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -159,6 +159,7 @@ WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); WIN_EXPORT void CSSNodeHide(const CSSNodeRef node); WIN_EXPORT void CSSNodeShow(const CSSNodeRef node); +WIN_EXPORT bool CSSNodeIsVisible(const CSSNodeRef node); WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); -- 2.50.1.windows.1 From 2ee412c7dd0a618d747c43face93d5d11e41274b Mon Sep 17 00:00:00 2001 From: roxlu Date: Fri, 11 Nov 2016 17:04:37 +0100 Subject: [PATCH 03/39] Take visiblity into account When iterating over the nodes we check if the node is hidden. When it's hidden we do skip it and go to the next child in line. --- CSSLayout/CSSLayout.c | 24 +++++++++++++++++++++++- CSSLayout/CSSLayout.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index e448a409..6cacefdd 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -294,7 +294,7 @@ void CSSNodeHide(const CSSNodeRef node) { } void CSSNodeShow(const CSSNodeRef node) { - node->isVisible = true;; + node->isVisible = true; } WIN_EXPORT bool CSSNodeIsVisible(const CSSNodeRef node) { @@ -1363,6 +1363,9 @@ 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); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (performLayout) { // Set the initial position (relative to the parent). @@ -1432,6 +1435,10 @@ static void layoutNodeImpl(const CSSNodeRef node, // 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); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } + child->lineIndex = lineCount; if (child->style.positionType != CSSPositionTypeAbsolute) { @@ -1745,6 +1752,9 @@ static void layoutNodeImpl(const CSSNodeRef node, for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (child->style.positionType == CSSPositionTypeAbsolute && isLeadingPosDefined(child, mainAxis)) { @@ -1816,6 +1826,9 @@ static void layoutNodeImpl(const CSSNodeRef node, if (performLayout) { for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (child->style.positionType == CSSPositionTypeAbsolute) { // If the child is absolutely positioned and has a @@ -1931,6 +1944,9 @@ static void layoutNodeImpl(const CSSNodeRef node, float lineHeight = 0; for (ii = startIndex; ii < childCount; ii++) { const CSSNodeRef child = CSSNodeListGet(node->children, ii); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (child->style.positionType == CSSPositionTypeRelative) { if (child->lineIndex != i) { @@ -1950,6 +1966,9 @@ static void layoutNodeImpl(const CSSNodeRef node, if (performLayout) { for (ii = startIndex; ii < endIndex; ii++) { const CSSNodeRef child = CSSNodeListGet(node->children, ii); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (child->style.positionType == CSSPositionTypeRelative) { switch (getAlignItem(node, child)) { @@ -2039,6 +2058,9 @@ static void layoutNodeImpl(const CSSNodeRef node, if (needsMainTrailingPos || needsCrossTrailingPos) { for (uint32_t i = 0; i < childCount; i++) { const CSSNodeRef child = CSSNodeListGet(node->children, i); + if (NULL != child && false == CSSNodeIsVisible(child)) { + continue; + } if (needsMainTrailingPos) { setTrailingPosition(node, child, mainAxis); diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 02d451e1..4abed17b 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -160,6 +160,7 @@ WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); WIN_EXPORT void CSSNodeHide(const CSSNodeRef node); WIN_EXPORT void CSSNodeShow(const CSSNodeRef node); WIN_EXPORT bool CSSNodeIsVisible(const CSSNodeRef node); + WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); -- 2.50.1.windows.1 From c113b755ec4fa12a3125e87dbd73d8e60899f563 Mon Sep 17 00:00:00 2001 From: roxlu Date: Thu, 1 Dec 2016 12:11:34 +0100 Subject: [PATCH 04/39] Marking nodes as dirty when visiblity changes. --- CSSLayout/CSSLayout.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 6cacefdd..26141fb1 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -291,10 +291,12 @@ bool CSSNodeIsDirty(const CSSNodeRef node) { void CSSNodeHide(const CSSNodeRef node) { node->isVisible = false; + _CSSNodeMarkDirty(node); } void CSSNodeShow(const CSSNodeRef node) { node->isVisible = true; + _CSSNodeMarkDirty(node); } WIN_EXPORT bool CSSNodeIsVisible(const CSSNodeRef node) { @@ -2075,9 +2077,9 @@ static void layoutNodeImpl(const CSSNodeRef node, } uint32_t gDepth = 0; -bool gPrintTree = false; -bool gPrintChanges = false; -bool gPrintSkips = false; +bool gPrintTree = true; +bool gPrintChanges = true; +bool gPrintSkips = true; static const char *spacer = " "; @@ -2140,6 +2142,7 @@ bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, const float lastComputedHeight, const float marginRow, const float marginColumn) { + if (lastComputedHeight < 0 || lastComputedWidth < 0) { return false; } @@ -2194,11 +2197,15 @@ bool layoutNodeInternal(const CSSNodeRef node, gDepth++; +#if 0 const bool needToVisitNode = (node->isDirty && layout->generationCount != gCurrentGenerationCount) || layout->lastParentDirection != parentDirection; - +#else + const bool needToVisitNode = true; +#endif if (needToVisitNode) { + // Invalidate the cached results. layout->nextCachedMeasurementsIndex = 0; layout->cachedLayout.widthMeasureMode = (CSSMeasureMode) -1; -- 2.50.1.windows.1 From 38ae7ea4ec31faa9582e452ad32818687a32743e Mon Sep 17 00:00:00 2001 From: roxlu Date: Thu, 1 Dec 2016 13:11:41 +0100 Subject: [PATCH 05/39] Hidden/shown nodes are updated now. See https://github.com/facebook/css-layout/issues/241 --- CSSLayout/CSSLayout.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 26141fb1..31792c2e 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -291,11 +291,13 @@ bool CSSNodeIsDirty(const CSSNodeRef node) { void CSSNodeHide(const CSSNodeRef node) { node->isVisible = false; + node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */ _CSSNodeMarkDirty(node); } void CSSNodeShow(const CSSNodeRef node) { node->isVisible = true; + node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */ _CSSNodeMarkDirty(node); } @@ -2198,12 +2200,16 @@ bool layoutNodeInternal(const CSSNodeRef node, gDepth++; #if 0 + printf("---\n"); + printf("node->isDirty: %c\n", (node->isDirty) ? 'y' : 'n'); + printf("layout->generationCount != gCurrentGenerationCount: %c\n", layout->generationCount != gCurrentGenerationCount ? 'y' : 'n'); + printf("layout->lastParentDirection != parentDirection: %c\n", layout->lastParentDirection != parentDirection ? 'y' : 'n'); +#endif + const bool needToVisitNode = (node->isDirty && layout->generationCount != gCurrentGenerationCount) || layout->lastParentDirection != parentDirection; -#else - const bool needToVisitNode = true; -#endif + if (needToVisitNode) { // Invalidate the cached results. -- 2.50.1.windows.1 From 7565eb625429c751533307b365cd10947060234e Mon Sep 17 00:00:00 2001 From: roxlu Date: Thu, 8 Dec 2016 22:47:56 +0100 Subject: [PATCH 06/39] Updating to new naming. --- yoga/Yoga.c | 4 ++-- yoga/Yoga.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 7245fc8c..344a8ebb 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -353,13 +353,13 @@ bool YGNodeIsDirty(const YGNodeRef node) { void YGNodeHide(const YGNodeRef node) { node->isVisible = false; node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */ - _YGNodeMarkDirty(node); + YGNodeMarkDirty(node); } void YGNodeShow(const YGNodeRef node) { node->isVisible = true; node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */ - _YGNodeMarkDirty(node); + YGNodeMarkDirty(node); } bool YGNodeIsVisible(const YGNodeRef node) { diff --git a/yoga/Yoga.h b/yoga/Yoga.h index afe609bf..d6d7ab69 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -80,10 +80,9 @@ WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node); WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node); -WIN_EXPORT void YGNodeHide(const CSSNodeRef node); -WIN_EXPORT void YGNodeShow(const CSSNodeRef node); -WIN_EXPORT bool YGNodeIsVisible(const CSSNodeRef node); - +WIN_EXPORT void YGNodeHide(const YGNodeRef node); +WIN_EXPORT void YGNodeShow(const YGNodeRef node); +WIN_EXPORT bool YGNodeIsVisible(const YGNodeRef node); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); -- 2.50.1.windows.1 From 8fcd544c8158d860d963a08476b425f5cafef069 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Sat, 10 Dec 2016 17:31:11 -0800 Subject: [PATCH 07/39] A bit more syncing after the name change --- .travis.yml | 2 +- BUCK | 4 ++-- YogaKit/BUCK | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 618dbb0a..608e2bab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_install: script: - buck test //:yoga - buck test //java:java - - buck test //YogaKit:YogaKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI + - buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI - sh csharp/tests/Facebook.Yoga/test_macos.sh - buck run //benchmark:benchmark - git checkout HEAD^ diff --git a/BUCK b/BUCK index 09e39b43..b9d6c907 100644 --- a/BUCK +++ b/BUCK @@ -27,7 +27,7 @@ cxx_library( name = 'yoga', soname = 'libyogacore.$(ext)', srcs = glob(['yoga/*.c']), - tests=[':tests'], + tests=[':YogaTests'], exported_headers = subdir_glob([('', 'yoga/*.h')]), header_namespace = '', compiler_flags = COMPILER_FLAGS, @@ -38,7 +38,7 @@ cxx_library( ) cxx_test( - name = 'tests', + name = 'YogaTests', contacts = ['emilsj@fb.com'], srcs = glob(['tests/*.cpp']), compiler_flags = TEST_COMPILER_FLAGS, diff --git a/YogaKit/BUCK b/YogaKit/BUCK index 4a781038..900ededb 100644 --- a/YogaKit/BUCK +++ b/YogaKit/BUCK @@ -30,7 +30,6 @@ COMPILER_FLAGS = [ apple_library( name = 'YogaKit', compiler_flags = COMPILER_FLAGS, - tests = [':YogaKitTests'], srcs = glob(['*.m']), exported_headers = glob(['*.h']), frameworks = [ -- 2.50.1.windows.1 From f36f545d75b338d24416f1584690e61d1ccd4cc7 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 9 Dec 2016 10:10:39 -0800 Subject: [PATCH 08/39] Add an anchor to the android platform regex Summary: This prevents android from matching in the middle of a platform. Reviewed By: gkassabli Differential Revision: D4306164 fbshipit-source-id: 7f62a6a017724f8f6741d3e53b5fbe0650c8c88e --- lib/fb/BUCK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fb/BUCK b/lib/fb/BUCK index da59ceaa..7300608d 100644 --- a/lib/fb/BUCK +++ b/lib/fb/BUCK @@ -11,7 +11,7 @@ prebuilt_cxx_library( name = 'ndklog', header_only = True, exported_platform_linker_flags = [ - ('android.*', ['-llog']), + ('^android.*', ['-llog']), ], visibility = [YOGA_ROOT], ) -- 2.50.1.windows.1 From 12efe604bb828c51f133022245a3bea13734f338 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 15 Dec 2016 06:31:47 -0800 Subject: [PATCH 09/39] Fix YogaKit tests on travis Summary: Fix include path Reviewed By: dshahidehpour Differential Revision: D4333185 fbshipit-source-id: 27638324e093260aa1b23134fab5140a0c703bc9 --- YogaKit/Tests/YogaKitTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 21b7f4ba..99927ade 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -9,7 +9,7 @@ #import -#import "UIView+Yoga.h" +#import @interface YogaKitTests : XCTestCase @end -- 2.50.1.windows.1 From cf753af247959592318522d76e1969022942f8c6 Mon Sep 17 00:00:00 2001 From: Jatin Pandey Date: Thu, 15 Dec 2016 06:47:55 -0800 Subject: [PATCH 10/39] Make documentation clearer Summary: Fixing a typo :) Closes https://github.com/facebook/yoga/pull/270 Reviewed By: dshahidehpour Differential Revision: D4333129 Pulled By: emilsjolander fbshipit-source-id: 28215de8fcd571fb889fe145ff303f231a50c598 --- YogaKit/UIView+Yoga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h index 97bb2532..386416b2 100644 --- a/YogaKit/UIView+Yoga.h +++ b/YogaKit/UIView+Yoga.h @@ -55,7 +55,7 @@ - (YGDirection)yg_resolvedDirection; /** - 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 the results */ - (void)yg_applyLayout; -- 2.50.1.windows.1 From e85c5ce39d1eba1b2224fedf58eb5a819f7679c6 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 15 Dec 2016 06:59:34 -0800 Subject: [PATCH 11/39] lowercase argument Summary: - Fix arguments of YogaNode.Create Reviewed By: emilsjolander Differential Revision: D4296488 fbshipit-source-id: f6eb5074b1b1462f2251d330929f7b8082ad72eb --- csharp/Facebook.Yoga/YogaNode.Create.cs | 36 +++++++++---------- .../tests/Facebook.Yoga/YogaNodeCreateTest.cs | 12 +++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs index a7df02d0..d04d0ffa 100644 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -31,12 +31,12 @@ namespace Facebook.Yoga Spacing margin = null, Spacing padding = null, Spacing border = null, - float? Width = null, - float? Height = null, - float? MaxWidth = null, - float? MaxHeight = null, - float? MinWidth = null, - float? MinHeight = null) + float? width = null, + float? height = null, + float? maxWidth = null, + float? maxHeight = null, + float? minWidth = null, + float? minHeight = null) { YogaNode node = new YogaNode(); @@ -197,34 +197,34 @@ namespace Facebook.Yoga } } - if (Width.HasValue) + if (width.HasValue) { - node.Width = Width.Value; + node.Width = width.Value; } - if (Height.HasValue) + if (height.HasValue) { - node.Height = Height.Value; + node.Height = height.Value; } - if (MinWidth.HasValue) + if (minWidth.HasValue) { - node.MinWidth = MinWidth.Value; + node.MinWidth = minWidth.Value; } - if (MinHeight.HasValue) + if (minHeight.HasValue) { - node.MinHeight = MinHeight.Value; + node.MinHeight = minHeight.Value; } - if (MaxWidth.HasValue) + if (maxWidth.HasValue) { - node.MaxWidth = MaxWidth.Value; + node.MaxWidth = maxWidth.Value; } - if (MaxHeight.HasValue) + if (maxHeight.HasValue) { - node.MaxHeight = MaxHeight.Value; + node.MaxHeight = maxHeight.Value; } return node; diff --git a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs index d7cd8d8e..0d43cdbc 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs @@ -87,12 +87,12 @@ namespace Facebook.Yoga 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); -- 2.50.1.windows.1 From 642ea07d6f1155c733b0cf0cc796e1063770ed12 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 15 Dec 2016 07:00:33 -0800 Subject: [PATCH 12/39] Update unmanaged dll name Summary: - Update unmanaged dll name from `Yoga.dll` to `yoga.dll` since Native.cs `DllName` referes lowercase `yoga` Reviewed By: emilsjolander Differential Revision: D4295954 fbshipit-source-id: 16b91c407506685b84902102cf4380cb149b5b2c --- csharp/Yoga/Yoga.vcxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/Yoga/Yoga.vcxproj b/csharp/Yoga/Yoga.vcxproj index b3704474..7303d22d 100755 --- a/csharp/Yoga/Yoga.vcxproj +++ b/csharp/Yoga/Yoga.vcxproj @@ -21,6 +21,7 @@ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5} Win32Proj + yoga Yoga 10.0.14393.0 -- 2.50.1.windows.1 From 88a4e44fd4ff77aa869846d78b1c4ca2387ccaa7 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 15 Dec 2016 08:49:51 -0800 Subject: [PATCH 13/39] Add YGNodeGetParent api Summary: Fixes https://github.com/facebook/css-layout/issues/248 Reviewed By: gkassabli Differential Revision: D4333456 fbshipit-source-id: 388afd0a01c19a6db73c175bf24c566278832cb9 --- yoga/Yoga.c | 4 ++++ yoga/Yoga.h | 1 + 2 files changed, 5 insertions(+) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 29acb459..6340d021 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -333,6 +333,10 @@ YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) { return YGNodeListGet(node->children, index); } +YGNodeRef YGNodeGetParent(const YGNodeRef node) { + return node->parent; +} + inline uint32_t YGNodeChildCount(const YGNodeRef node) { return YGNodeListCount(node->children); } diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c7bc600d..79c59a4b 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -64,6 +64,7 @@ WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node, 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 YGNodeRef YGNodeGetParent(const YGNodeRef node); WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node); WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, -- 2.50.1.windows.1 From 25b206ac531f5946c20700bfbfb1d508ff8af11a Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 15 Dec 2016 12:44:19 -0800 Subject: [PATCH 14/39] Build native library with BUCK for .NET (Mono, Xamarin) Summary: Examples: - macOS on macOS (Mono, Xamarin.Mac, Unity) - `buck build //csharp:yoganet#shared,default` -> `libyoga.dylib` - Android (Xamarin.Android, Unity) - `buck build //csharp:yoganet#shared,android-armv7` -> `libyoga.so` - iOS (Xamarin.iOS, Unity) - `buck build //:yoga#static,iphoneos-arm64` -> `libyoga.a` - `buck build //csharp:yoganet#static,iphoneos-arm64` -> `libyoganet.a` Closes https://github.com/facebook/yoga/pull/282 Reviewed By: emilsjolander Differential Revision: D4333811 Pulled By: splhack fbshipit-source-id: 54f4364d93b2419d7504392eb558296a5d06772f --- BUCK | 8 -------- YOGA_DEFS | 8 ++++++++ csharp/BUCK | 15 +++++++++++++++ csharp/tests/Facebook.Yoga/test_macos.sh | 21 ++++++++------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/BUCK b/BUCK index b9d6c907..aa7ec37e 100644 --- a/BUCK +++ b/BUCK @@ -7,14 +7,6 @@ include_defs('//YOGA_DEFS') -BASE_COMPILER_FLAGS = [ - '-fno-omit-frame-pointer', - '-fexceptions', - '-Wall', - '-Werror', - '-O3', -] - GMOCK_OVERRIDE_FLAGS = [ # gmock does not mark mocked methods as override, ignore the warnings in tests '-Wno-inconsistent-missing-override', diff --git a/YOGA_DEFS b/YOGA_DEFS index 137b96fd..288b13be 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -17,6 +17,14 @@ CXX_LIBRARY_WHITELIST = [ '//java:jni', ] +BASE_COMPILER_FLAGS = [ + '-fno-omit-frame-pointer', + '-fexceptions', + '-Wall', + '-Werror', + '-O3', +] + def yoga_dep(dep): return '//' + dep diff --git a/csharp/BUCK b/csharp/BUCK index 8223450a..7517c930 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -5,6 +5,10 @@ # 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') + +COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11'] + csharp_library( name = 'yogalibnet46', dll_name = 'Facebook.Yoga.dll', @@ -18,3 +22,14 @@ csharp_library( framework_ver = 'net45', srcs = glob(['**/*.cs']), ) + +cxx_library( + name = 'yoganet', + soname = 'libyoga.$(ext)', + srcs = glob(['Yoga/YGInterop.cpp']), + compiler_flags = COMPILER_FLAGS, + link_style = 'static', + link_whole = True, + deps = [yoga_dep(':yoga')], + visibility = ['PUBLIC'], +) diff --git a/csharp/tests/Facebook.Yoga/test_macos.sh b/csharp/tests/Facebook.Yoga/test_macos.sh index 7df36893..1d04177d 100755 --- a/csharp/tests/Facebook.Yoga/test_macos.sh +++ b/csharp/tests/Facebook.Yoga/test_macos.sh @@ -1,16 +1,6 @@ #!/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 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." +if mcs --version >/dev/null 2>&1 && mono --version >/dev/null 2>&1; then true; else + echo "ERROR: Need to install Mono (brew install mono, or http://www.mono-project.com/download/)" exit 1 fi @@ -28,6 +18,11 @@ if [ -d $NUNIT \ rm NUnit-2.6.4.zip fi -clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../yoga/*.c ../../Yoga/YGInterop.cpp +TARGET=//csharp:yoganet#default,shared +buck build $TARGET +ROOT=`buck root|tail -1` +DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'` +cp $ROOT/$DYLIB . + 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 -- 2.50.1.windows.1 From 98bbc15435ef38d1a6a8308a32bff7bdf1b297c6 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 16 Dec 2016 00:06:49 -0800 Subject: [PATCH 15/39] Support Xamarin.iOS Summary: - `__Internal` https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/#Static_Libraries > Since you can only use static libraries on iOS, there is no external shared library to link with, so the path parameter in the DllImport attribute needs to use the special name __Internal (note the double underscore characters at the start of the name) as opposed to the path name. - `__IOS__` https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_4_-_platform_divergence_abstraction_divergent_implementation/#iOS > Xamarin.iOS defines __IOS__ which you can use to detect iOS devices. Closes https://github.com/facebook/yoga/pull/277 Reviewed By: emilsjolander Differential Revision: D4338420 Pulled By: splhack fbshipit-source-id: 375efecbaf88fffbba544073c6d6b30fb1f4c8ba --- csharp/Facebook.Yoga/Native.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 7786b8cf..9b1eb03d 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -14,7 +14,7 @@ namespace Facebook.Yoga { internal static class Native { -#if UNITY_IOS && !UNITY_EDITOR +#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ private const string DllName = "__Internal"; #else private const string DllName = "yoga"; -- 2.50.1.windows.1 From 04fe81f88f67172dd277701ce71d6f3ceec2d41f Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 16 Dec 2016 00:06:50 -0800 Subject: [PATCH 16/39] YGNodeInit is no longer exported Summary: - Problem: Can't link yoga static libraries with Unity and Xamarin.iOS since YGNodeInit is undefined in the libraries. - Solution: Remove the reference in Native.cs Reviewed By: emilsjolander Differential Revision: D4338485 fbshipit-source-id: 9dc95aec8f1fd50f3f9d66e1623afe2fb1992210 --- csharp/Facebook.Yoga/Native.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 9b1eb03d..fc7df3ca 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -27,9 +27,6 @@ namespace Facebook.Yoga [DllImport(DllName)] public static extern IntPtr YGNodeNew(); - [DllImport(DllName)] - public static extern void YGNodeInit(IntPtr node); - [DllImport(DllName)] public static extern void YGNodeFree(IntPtr node); -- 2.50.1.windows.1 From 0296511f2c958b64a20cfdc32958a41136b68a18 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 16 Dec 2016 04:39:13 -0800 Subject: [PATCH 17/39] YGNodeChildCount -> YGNodeGetChildCount for consistency Summary: I kept wrongly typing this function which is a good sign that the name is inconsistent. Reviewed By: gkassabli Differential Revision: D4333480 fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad --- YogaKit/UIView+Yoga.m | 8 ++++---- csharp/Facebook.Yoga/Native.cs | 2 +- java/jni/YGJNI.cpp | 2 +- tests/YGLayoutDefaultValuesTest.cpp | 2 +- yoga/Yoga.c | 10 +++++----- yoga/Yoga.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index 0ad7bddc..241ad33e 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -53,7 +53,7 @@ - (NSUInteger)yg_numberOfChildren { - return YGNodeChildCount([self ygNode]); + return YGNodeGetChildCount([self ygNode]); } #pragma mark - Setters @@ -295,7 +295,7 @@ static void YGAttachNodesFromViewHierachy(UIView *view) { } BOOL shouldReconstructChildList = NO; - if (YGNodeChildCount(node) != subviewsToInclude.count) { + if (YGNodeGetChildCount(node) != subviewsToInclude.count) { shouldReconstructChildList = YES; } else { for (int i = 0; i < subviewsToInclude.count; i++) { @@ -324,8 +324,8 @@ static void YGRemoveAllChildren(const YGNodeRef node) return; } - while (YGNodeChildCount(node) > 0) { - YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeChildCount(node) - 1)); + while (YGNodeGetChildCount(node) > 0) { + YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1)); } } diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index fc7df3ca..57cc654f 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -55,7 +55,7 @@ namespace Facebook.Yoga public static extern IntPtr YGNodeGetChild(IntPtr node, uint index); [DllImport(DllName)] - public static extern uint YGNodeChildCount(IntPtr node); + public static extern uint YGNodeGetChildCount(IntPtr node); [DllImport(DllName)] public static extern void YGNodeCalculateLayout(IntPtr node, diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index bf17f087..09236b88 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -36,7 +36,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { obj->setFieldValue(topField, YGNodeLayoutGetTop(root)); YGTransferLayoutDirection(root, obj); - for (uint32_t i = 0; i < YGNodeChildCount(root); i++) { + for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) { YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i)); } } else { diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGLayoutDefaultValuesTest.cpp index fbc1e1b9..044059b5 100644 --- a/tests/YGLayoutDefaultValuesTest.cpp +++ b/tests/YGLayoutDefaultValuesTest.cpp @@ -13,7 +13,7 @@ TEST(YogaTest, assert_default_values) { const YGNodeRef root = YGNodeNew(); - ASSERT_EQ(0, YGNodeChildCount(root)); + ASSERT_EQ(0, YGNodeGetChildCount(root)); ASSERT_EQ(NULL, YGNodeGetChild(root, 1)); ASSERT_EQ(YGDirectionInherit, YGNodeStyleGetDirection(root)); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 6340d021..dad81116 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -256,7 +256,7 @@ void YGNodeFree(const YGNodeRef node) { node->parent = NULL; } - const uint32_t childCount = YGNodeChildCount(node); + const uint32_t childCount = YGNodeGetChildCount(node); for (uint32_t i = 0; i < childCount; i++) { const YGNodeRef child = YGNodeGetChild(node, i); child->parent = NULL; @@ -268,7 +268,7 @@ void YGNodeFree(const YGNodeRef node) { } void YGNodeFreeRecursive(const YGNodeRef root) { - while (YGNodeChildCount(root) > 0) { + while (YGNodeGetChildCount(root) > 0) { const YGNodeRef child = YGNodeGetChild(root, 0); YGNodeRemoveChild(root, child); YGNodeFreeRecursive(child); @@ -277,7 +277,7 @@ void YGNodeFreeRecursive(const YGNodeRef root) { } void YGNodeReset(const YGNodeRef node) { - YG_ASSERT(YGNodeChildCount(node) == 0, "Cannot reset a node which still has children attached"); + YG_ASSERT(YGNodeGetChildCount(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); @@ -303,7 +303,7 @@ void YGNodeSetMeasureFunc(const YGNodeRef node, YGMeasureFunc measureFunc) { if (measureFunc == NULL) { node->measure = NULL; } else { - YG_ASSERT(YGNodeChildCount(node) == 0, + YG_ASSERT(YGNodeGetChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children."); node->measure = measureFunc; } @@ -337,7 +337,7 @@ YGNodeRef YGNodeGetParent(const YGNodeRef node) { return node->parent; } -inline uint32_t YGNodeChildCount(const YGNodeRef node) { +inline uint32_t YGNodeGetChildCount(const YGNodeRef node) { return YGNodeListCount(node->children); } diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 79c59a4b..3bb96727 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -65,7 +65,7 @@ WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node, WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child); WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index); WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node); -WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node); +WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node); WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, const float availableWidth, -- 2.50.1.windows.1 From ba0bb103669e2510bb6a2daf5393c2c4495644de Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 16 Dec 2016 06:53:47 -0800 Subject: [PATCH 18/39] Build iOS fat static library for Unity and Xamarin Summary: $ buck build //csharp:yoganet-ios $ buck targets --show-output //csharp:yoganet-ios //csharp:yoganet-ios buck-out/gen/csharp/yoganet-ios/libyoga.a $ lipo -info buck-out/gen/csharp/yoganet-ios/libyoga.a Architectures in the fat file: buck-out/gen/csharp/yoganet-ios/libyoga.a are: armv7 x86_64 arm64 $ nm buck-out/gen/csharp/yoganet-ios/libyoga.a|grep -e 'T _YGNodeNew' -e 'ygNode' -e 'T _YGInteropSetLogger' 0000000000000000 T _YGNodeNew 0000000000001070 t -[UIView(Yoga) ygNode] 0000000000000000 T _YGInteropSetLogger Closes https://github.com/facebook/yoga/pull/286 Reviewed By: emilsjolander Differential Revision: D4338919 Pulled By: splhack fbshipit-source-id: 7acfdfa0dc4d152d7bfe92161efdeb9f161f70e6 --- csharp/BUCK | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/csharp/BUCK b/csharp/BUCK index 7517c930..8fc408eb 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -33,3 +33,31 @@ cxx_library( deps = [yoga_dep(':yoga')], visibility = ['PUBLIC'], ) + +with allow_unsafe_import(): + import os + +if os.path.isdir('/Applications/Xcode.app'): + yoganet_ios_srcs = [] + for arch in ['iphonesimulator-x86_64', 'iphoneos-arm64', 'iphoneos-armv7']: + name = 'yoganet-' + arch + yoganet_ios_srcs.append(':' + name) + genrule( + name = name, + srcs = [ + yoga_dep(':yoga#%s,static' % arch), + yoga_dep('YogaKit:YogaKit#%s,static' % arch), + yoga_dep('csharp:yoganet#%s,static' % arch), + ], + out = 'libyoga-%s.a' % arch, + cmd = 'libtool -static -o $OUT $SRCS', + visibility = [yoga_dep('csharp:yoganet-ios')], + ) + + genrule( + name = 'yoganet-ios', + srcs = yoganet_ios_srcs, + out = 'libyoga.a', + cmd = 'lipo $SRCS -create -output $OUT', + visibility = ['PUBLIC'], + ) -- 2.50.1.windows.1 From 74fb205083256a607d6e39bf05d7b8e6bcb60471 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 16 Dec 2016 09:03:52 -0800 Subject: [PATCH 19/39] Rename test files to match other test file names Summary: Rename test files to match other test file names Differential Revision: D4335198 fbshipit-source-id: b8f38162c3094231476059eb1f54326d8ba84848 --- tests/{YGLayoutAspectRatioTest.cpp => YGAspectRatioTest.cpp} | 0 tests/{YGLayoutDefaultValuesTest.cpp => YGDefaultValuesTest.cpp} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{YGLayoutAspectRatioTest.cpp => YGAspectRatioTest.cpp} (100%) rename tests/{YGLayoutDefaultValuesTest.cpp => YGDefaultValuesTest.cpp} (100%) diff --git a/tests/YGLayoutAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp similarity index 100% rename from tests/YGLayoutAspectRatioTest.cpp rename to tests/YGAspectRatioTest.cpp diff --git a/tests/YGLayoutDefaultValuesTest.cpp b/tests/YGDefaultValuesTest.cpp similarity index 100% rename from tests/YGLayoutDefaultValuesTest.cpp rename to tests/YGDefaultValuesTest.cpp -- 2.50.1.windows.1 From 9d35dce63eb2d7d9ca020d04f255e1083667394e Mon Sep 17 00:00:00 2001 From: yiminghe Date: Tue, 20 Dec 2016 03:20:49 -0800 Subject: [PATCH 20/39] explicit default justifyContent value Summary: make default justifyContent value explicit like alignItems https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content https://developer.mozilla.org/en-US/docs/Web/CSS/align-items https://developer.mozilla.org/en-US/docs/Web/CSS/align-content Closes https://github.com/facebook/yoga/pull/293 Differential Revision: D4351597 Pulled By: emilsjolander fbshipit-source-id: b65ff2284ede4d75f1cc5e22d4106042ab0b0d02 --- yoga/Yoga.c | 1 + 1 file changed, 1 insertion(+) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index dad81116..2e34e4f7 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -197,6 +197,7 @@ static void YGNodeInit(const YGNodeRef node) { node->style.flexBasis = YGUndefined; node->style.alignItems = YGAlignStretch; + node->style.justifyContent = YGJustifyFlexStart; node->style.alignContent = YGAlignFlexStart; node->style.direction = YGDirectionInherit; -- 2.50.1.windows.1 From 835bb1cd9c30884f28c5c68b43dd6748b56c5961 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Tue, 20 Dec 2016 11:31:55 -0800 Subject: [PATCH 21/39] Add isLeaf flag to Views. Summary: While building some views with YogaKit, I found an interesting problem. If you are apply `yg_` properties to a view which is constructed of subclassed views (that don't use Yoga.) we still treat view (and it's subviews) like they are using YogaKit. This fixes that behavior. Reviewed By: emilsjolander Differential Revision: D4348344 fbshipit-source-id: 37b8648918529f55afea1d1883a03af398aac849 --- YogaKit/Tests/YogaKitTests.m | 21 +++++++++++++++++++++ YogaKit/UIView+Yoga.h | 5 +++++ YogaKit/UIView+Yoga.m | 25 ++++++++++++++++++++----- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 99927ade..b54e308b 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -268,4 +268,25 @@ } } +- (void)testyg_isLeafFlag +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + XCTAssertTrue(view.yg_isLeaf); + + for (int i=0; i<10; i++) { + UIView *subview = [[UIView alloc] initWithFrame:CGRectZero]; + [view addSubview:subview]; + } + XCTAssertTrue(view.yg_isLeaf); + + [view yg_setUsesYoga:YES]; + [view yg_setWidth:50.0]; + XCTAssertTrue(view.yg_isLeaf); + + UIView *const subview = view.subviews[0]; + [subview yg_setUsesYoga:YES]; + [subview yg_setWidth:50.0]; + XCTAssertFalse(view.yg_isLeaf); +} + @end diff --git a/YogaKit/UIView+Yoga.h b/YogaKit/UIView+Yoga.h index 386416b2..734c13d4 100644 --- a/YogaKit/UIView+Yoga.h +++ b/YogaKit/UIView+Yoga.h @@ -69,4 +69,9 @@ */ - (NSUInteger)yg_numberOfChildren; +/** + Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout. + */ +- (BOOL)yg_isLeaf; + @end diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index 241ad33e..776304f0 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -56,6 +56,20 @@ return YGNodeGetChildCount([self ygNode]); } +- (BOOL)yg_isLeaf +{ + NSAssert([NSThread isMainThread], @"This method must be called on the main thread."); + if ([self yg_usesYoga]) { + for (UIView *subview in self.subviews) { + if ([subview yg_usesYoga] && [subview yg_includeInLayout]) { + return NO; + } + } + } + + return YES; +} + #pragma mark - Setters - (void)yg_setIncludeInLayout:(BOOL)includeInLayout @@ -276,11 +290,12 @@ static CGFloat YGSanitizeMeasurement( return result; } -static void YGAttachNodesFromViewHierachy(UIView *view) { +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) { + if (view.yg_isLeaf) { YGNodeSetMeasureFunc(node, YGMeasureView); YGRemoveAllChildren(node); } else { @@ -340,7 +355,8 @@ static CGFloat YGRoundPixelValue(CGFloat value) return round(value * scale) / scale; } -static void YGApplyLayoutToViewHierarchy(UIView *view) { +static void YGApplyLayoutToViewHierarchy(UIView *view) +{ NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); if (![view yg_includeInLayout]) { return; @@ -368,8 +384,7 @@ static void YGApplyLayoutToViewHierarchy(UIView *view) { }, }; - const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0; - if (!isLeaf) { + if (!view.yg_isLeaf) { for (NSUInteger i = 0; i < view.subviews.count; i++) { YGApplyLayoutToViewHierarchy(view.subviews[i]); } -- 2.50.1.windows.1 From 7ec3607446ba91a25801e60232fe8b33a12f7ab6 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Wed, 21 Dec 2016 10:54:31 -0800 Subject: [PATCH 22/39] Fix diffing algorithm for reattaching views. Summary: There is a bug currently where we don't traverse the entire tree to detect view hierarchy changes. Currently, if you had a hierachy like this: ``` container = UIView container.subviews = @[subview1, subview2]; subview1.subviews = @[sub11, sub12, sub13]; subview2.subviews = @[sub21, sub22, sub23]; ``` and then modified via: ``` subview2.subviews = @[newView1, newView2, newView3]; ``` our algorithm wouldn't identify that we had new views that needed their layout calculated, and would cause a crash later on. Reviewed By: emilsjolander Differential Revision: D4357662 fbshipit-source-id: 2f61f213c5f1a62948a653f3b1fa3d874c5075f7 --- YogaKit/Tests/YogaKitTests.m | 54 ++++++++++++++++++++++++++++++++++++ YogaKit/UIView+Yoga.m | 43 +++++++++++++++------------- 2 files changed, 77 insertions(+), 20 deletions(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index b54e308b..68d97dd5 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -289,4 +289,58 @@ XCTAssertFalse(view.yg_isLeaf); } +- (void)testThatWeCorrectlyAttachNestedViews +{ + UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)]; + [container yg_setUsesYoga:YES]; + [container yg_setFlexDirection:YGFlexDirectionColumn]; + + UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview1 yg_setUsesYoga:YES]; + [subview1 yg_setWidth:100]; + [subview1 yg_setFlexGrow:1]; + [subview1 yg_setFlexDirection:YGFlexDirectionColumn]; + [container addSubview:subview1]; + + UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero]; + [subview2 yg_setUsesYoga:YES]; + [subview2 yg_setWidth:150]; + [subview2 yg_setFlexGrow:1]; + [subview2 yg_setFlexDirection:YGFlexDirectionColumn]; + [container addSubview:subview2]; + + for (UIView *view in @[subview1, subview2]) { + UIView *someView = [[UIView alloc] initWithFrame:CGRectZero]; + [someView yg_setUsesYoga:YES]; + [someView yg_setFlexGrow:1]; + [view addSubview:someView]; + } + [container yg_applyLayout]; + + // Add the same amount of new views, reapply layout. + for (UIView *view in @[subview1, subview2]) { + UIView *someView = [[UIView alloc] initWithFrame:CGRectZero]; + [someView yg_setUsesYoga:YES]; + [someView yg_setFlexGrow:1]; + [view addSubview:someView]; + } + [container yg_applyLayout]; + + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size)); + for (UIView *subview in subview1.subviews) { + const CGSize subviewSize = subview.bounds.size; + XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize)); + XCTAssertFalse(isnan(subviewSize.height)); + XCTAssertFalse(isnan(subviewSize.width)); + } + + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size)); + for (UIView *subview in subview2.subviews) { + const CGSize subviewSize = subview.bounds.size; + XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size)); + XCTAssertFalse(isnan(subviewSize.height)); + XCTAssertFalse(isnan(subviewSize.width)); + } +} + @end diff --git a/YogaKit/UIView+Yoga.m b/YogaKit/UIView+Yoga.m index 776304f0..980a7683 100644 --- a/YogaKit/UIView+Yoga.m +++ b/YogaKit/UIView+Yoga.m @@ -290,9 +290,24 @@ static CGFloat YGSanitizeMeasurement( return result; } -static void YGAttachNodesFromViewHierachy(UIView *view) +static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray *subviews) { - YGNodeRef node = [view ygNode]; + if (YGNodeGetChildCount(node) != subviews.count) { + return NO; + } + + for (int i=0; i *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count]; for (UIView *subview in view.subviews) { if ([subview yg_includeInLayout]) { @@ -309,26 +323,15 @@ static void YGAttachNodesFromViewHierachy(UIView *view) } } - BOOL shouldReconstructChildList = NO; - if (YGNodeGetChildCount(node) != subviewsToInclude.count) { - shouldReconstructChildList = YES; - } else { - for (int i = 0; i < subviewsToInclude.count; i++) { - if (YGNodeGetChild(node, i) != [subviewsToInclude[i] ygNode]) { - shouldReconstructChildList = YES; - break; + if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) { + YGRemoveAllChildren(node); + for (int i=0; i Date: Wed, 21 Dec 2016 11:37:32 -0800 Subject: [PATCH 23/39] Test for minHeight with flexing Summary: This test creates a repro case for Yoga to emulate UFI layout failure Reviewed By: emilsjolander Differential Revision: D4313632 fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27 --- .../Facebook.Yoga/YGMinMaxDimensionTest.cs | 221 ++++++++++++++++++ gentest/fixtures/YGMinMaxDimensionTest.html | 22 ++ .../facebook/yoga/YGMinMaxDimensionTest.java | 217 +++++++++++++++++ tests/YGMinMaxDimensionTest.cpp | 213 +++++++++++++++++ yoga/Yoga.c | 33 ++- 5 files changed, 703 insertions(+), 3 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index 04413d41..39eca9ca 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -454,5 +454,226 @@ namespace Facebook.Yoga Assert.AreEqual(20f, root_child0_child0.LayoutHeight); } + [Test] + public void Test_flex_grow_within_constrained_min_row() + { + YogaNode root = new YogaNode(); + root.FlexDirection = YogaFlexDirection.Row; + root.MinWidth = 100f; + root.Height = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.Width = 50f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.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(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.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 = YogaDirection.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(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.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_grow_within_constrained_min_column() + { + YogaNode root = new YogaNode(); + root.MinHeight = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexGrow = 1f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.Height = 50f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(0f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(0f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutHeight); + } + + [Test] + public void Test_flex_grow_within_constrained_max_row() + { + YogaNode root = new YogaNode(); + root.Width = 200f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexDirection = YogaFlexDirection.Row; + root_child0.MaxWidth = 100f; + root_child0.Height = 100f; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.FlexShrink = 1f; + root_child0_child0.FlexBasis = 100f; + root_child0.Insert(0, root_child0_child0); + + YogaNode root_child0_child1 = new YogaNode(); + root_child0_child1.Width = 50f; + root_child0.Insert(1, root_child0_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(50f, root_child0_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(50f, root_child0_child1.LayoutX); + Assert.AreEqual(0f, root_child0_child1.LayoutY); + Assert.AreEqual(50f, root_child0_child1.LayoutWidth); + Assert.AreEqual(100f, root_child0_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(100f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutHeight); + + Assert.AreEqual(50f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(50f, root_child0_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child1.LayoutX); + Assert.AreEqual(0f, root_child0_child1.LayoutY); + Assert.AreEqual(50f, root_child0_child1.LayoutWidth); + Assert.AreEqual(100f, root_child0_child1.LayoutHeight); + } + + [Test] + public void Test_flex_grow_within_constrained_max_column() + { + YogaNode root = new YogaNode(); + root.Width = 100f; + root.MaxHeight = 100f; + + YogaNode root_child0 = new YogaNode(); + root_child0.FlexShrink = 1f; + root_child0.FlexBasis = 100f; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(); + root_child1.Height = 50f; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.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(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.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 = YogaDirection.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(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.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/gentest/fixtures/YGMinMaxDimensionTest.html b/gentest/fixtures/YGMinMaxDimensionTest.html index 6e469707..6adf67e5 100644 --- a/gentest/fixtures/YGMinMaxDimensionTest.html +++ b/gentest/fixtures/YGMinMaxDimensionTest.html @@ -41,3 +41,25 @@
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java index f37a5c54..f5f96357 100644 --- a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java +++ b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java @@ -444,4 +444,221 @@ public class YGMinMaxDimensionTest { assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_flex_grow_within_constrained_min_row() { + final YogaNode root = new YogaNode(); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setMinWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setWidth(50f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.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(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.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_grow_within_constrained_min_column() { + final YogaNode root = new YogaNode(); + root.setMinHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexGrow(1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setHeight(50f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, 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(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, 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(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_grow_within_constrained_max_row() { + final YogaNode root = new YogaNode(); + root.setWidth(200f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexDirection(YogaFlexDirection.ROW); + root_child0.setMaxWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = new YogaNode(); + root_child0_child0.setFlexShrink(1f); + root_child0_child0.setFlexBasis(100f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = new YogaNode(); + root_child0_child1.setWidth(50f); + root_child0.addChildAt(root_child0_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.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(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_grow_within_constrained_max_column() { + final YogaNode root = new YogaNode(); + root.setWidth(100f); + root.setMaxHeight(100f); + + final YogaNode root_child0 = new YogaNode(); + root_child0.setFlexShrink(1f); + root_child0.setFlexBasis(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(); + root_child1.setHeight(50f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.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(YogaDirection.RTL); + root.calculateLayout(); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.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/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp index 2c6d3120..b1463e52 100644 --- a/tests/YGMinMaxDimensionTest.cpp +++ b/tests/YGMinMaxDimensionTest.cpp @@ -430,3 +430,216 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) { YGNodeFreeRecursive(root); } + +TEST(YogaTest, flex_grow_within_constrained_min_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetMinWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + 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)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + 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)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, flex_grow_within_constrained_min_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetMinHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, flex_grow_within_constrained_max_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 200); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); + YGNodeStyleSetMaxWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child0_child0, 1); + YGNodeStyleSetFlexBasis(root_child0_child0, 100); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0_child1, 50); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, 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(50, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, flex_grow_within_constrained_max_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetMaxHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetFlexShrink(root_child0, 1); + YGNodeStyleSetFlexBasis(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + 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)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + 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)); + + YGNodeFreeRecursive(root); +} diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 2e34e4f7..e207a9b8 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1507,10 +1507,25 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS - const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; - const float availableInnerHeight = + float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; + const float minInnerWidth = node->style.minDimensions[YGDimensionWidth] - marginAxisRow - paddingAndBorderAxisRow; + const float maxInnerWidth = node->style.maxDimensions[YGDimensionWidth] - marginAxisRow - paddingAndBorderAxisRow; + float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; - const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; + const float minInnerHeight = node->style.minDimensions[YGDimensionHeight] - marginAxisColumn - paddingAndBorderAxisColumn; + const float maxInnerHeight = node->style.maxDimensions[YGDimensionHeight] - marginAxisColumn - paddingAndBorderAxisColumn; + const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight; + const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight; + + // Max dimension overrides predefined dimension value; Min dimension in turn overrides both of the above + if (!YGValueIsUndefined(availableInnerWidth)) { + availableInnerWidth = fmaxf(fminf(availableInnerWidth, maxInnerWidth), minInnerWidth); + } + if (!YGValueIsUndefined(availableInnerHeight)) { + availableInnerHeight = fmaxf(fminf(availableInnerHeight, maxInnerHeight), minInnerHeight); + } + + 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 @@ -1664,6 +1679,18 @@ static void YGNodelayoutImpl(const YGNodeRef node, // 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. + + // We resolve main dimension to fit minimum and maximum values + if (YGValueIsUndefined(availableInnerMainDim)) { + if (!YGValueIsUndefined(minInnerMainDim) && + sizeConsumedOnCurrentLine < minInnerMainDim) { + availableInnerMainDim = minInnerMainDim; + } else if (!YGValueIsUndefined(maxInnerMainDim) && + sizeConsumedOnCurrentLine > maxInnerMainDim) { + availableInnerMainDim = maxInnerMainDim; + } + } + float remainingFreeSpace = 0; if (!YGValueIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; -- 2.50.1.windows.1 From 3d10ba5f72f11e421a50653218b663dd538d7123 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 22 Dec 2016 02:57:12 -0800 Subject: [PATCH 24/39] Correctly check if child is flex by also accounting for undefined Summary: We were incorrectly returning true for children which had no flex as the flex was nan and not 0. Differential Revision: D4346712 fbshipit-source-id: 69ef0bb3fe5b4fcd3b3e2fe5aa348529be40252a --- yoga/Yoga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index e207a9b8..4762cee4 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -825,7 +825,7 @@ static YGFlexDirection YGFlexDirectionCross(const YGFlexDirection flexDirection, static inline bool YGNodeIsFlex(const YGNodeRef node) { return (node->style.positionType == YGPositionTypeRelative && - (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); + (YGNodeStyleGetFlexGrow(node) != 0 || YGNodeStyleGetFlexShrink(node) != 0)); } static inline float YGNodeDimWithMargin(const YGNodeRef node, const YGFlexDirection axis) { -- 2.50.1.windows.1 From 071f576db99775e51d384e99373a86610f712a28 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 22 Dec 2016 02:57:15 -0800 Subject: [PATCH 25/39] BREAKING - Change aspect ratio to always be width/height Summary: @public Aspect ratio being defined as width/height or height/width depending on the situation it was used in turned out to be very confusing. This diff makes aspect ratio always be defined as width/height irregardless of the usage. Differential Revision: D4339132 fbshipit-source-id: e5da32750b55ddaf6acaf1cbd7662d86f2b480c3 --- tests/YGAspectRatioTest.cpp | 4 ++-- yoga/Yoga.c | 6 +++--- yoga/Yoga.h | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/YGAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp index 22846c9b..8b28abdb 100644 --- a/tests/YGAspectRatioTest.cpp +++ b/tests/YGAspectRatioTest.cpp @@ -351,7 +351,7 @@ TEST(YogaTest, aspect_ratio_double_main) { const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetWidth(root_child0, 50); - YGNodeStyleSetAspectRatio(root_child0, 2); + YGNodeStyleSetAspectRatio(root_child0, 0.5); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -372,7 +372,7 @@ TEST(YogaTest, aspect_ratio_half_main) { const YGNodeRef root_child0 = YGNodeNew(); YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetAspectRatio(root_child0, 0.5); + YGNodeStyleSetAspectRatio(root_child0, 2); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 4762cee4..8b1c5fda 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1062,7 +1062,7 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node, if (!YGValueIsUndefined(child->style.aspectRatio)) { if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) { child->layout.computedFlexBasis = - fmaxf(childWidth * child->style.aspectRatio, + fmaxf(childWidth / child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); return; } else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) { @@ -1157,7 +1157,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childWidth = fmaxf(childHeight * child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn)); } else if (YGValueIsUndefined(childHeight)) { - childHeight = fmaxf(childWidth * child->style.aspectRatio, + childHeight = fmaxf(childWidth / child->style.aspectRatio, YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow)); } } @@ -1880,7 +1880,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (!YGValueIsUndefined(currentRelativeChild->style.aspectRatio)) { if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { childHeight = - fmaxf(childWidth * currentRelativeChild->style.aspectRatio, + fmaxf(childWidth / currentRelativeChild->style.aspectRatio, YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn)); childHeightMeasureMode = YGMeasureModeExactly; } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 3bb96727..5e10b503 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -151,6 +151,9 @@ 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. +// Aspect ratio is encoded as a floating point value width/height. e.g. A value of 2 leads to a node +// with a width twice the size of its height while a value of 0.5 gives the opposite effect. +// // - 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 -- 2.50.1.windows.1 From 1b5eb7da5e451b549bba75238a132e05c726facd Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 22 Dec 2016 02:57:16 -0800 Subject: [PATCH 26/39] BREAKING - Increase priority of AspectRatio to override flex, align stretch, and fixed sizes if specified. Summary: @public AspectRatio is a new addition and soon after introduction we noticed use cases which is did not support. Specifically we wanted to support a node being as large as possible within a container while maintaining an arbitrary aspect ratio. This was not possible due to the low priority of AspectRatio, by increasing the priority of AspectRatio this is now possible as FlexGrow will grow an item to fit its parent unless the AspectRatio makes it too big in the cross axis, the AspectRatio will now override the FlexGrow in the main axis in that case. Differential Revision: D4346720 fbshipit-source-id: 1f15613604190e3ad5ff4a467ba57db4bcfd2741 --- tests/YGAspectRatioTest.cpp | 273 +++++++++++++++++++++++++++++++++++- yoga/Yoga.c | 24 +++- 2 files changed, 292 insertions(+), 5 deletions(-) diff --git a/tests/YGAspectRatioTest.cpp b/tests/YGAspectRatioTest.cpp index 8b28abdb..b6e32de2 100644 --- a/tests/YGAspectRatioTest.cpp +++ b/tests/YGAspectRatioTest.cpp @@ -63,12 +63,15 @@ TEST(YogaTest, aspect_ratio_main_defined) { YGNodeFreeRecursive(root); } -TEST(YogaTest, aspect_ratio_both_dimensions_defined) { +TEST(YogaTest, aspect_ratio_both_dimensions_defined_row) { const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 50); YGNodeStyleSetAspectRatio(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); @@ -78,6 +81,28 @@ TEST(YogaTest, aspect_ratio_both_dimensions_defined) { ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_both_dimensions_defined_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); @@ -405,3 +430,249 @@ TEST(YogaTest, aspect_ratio_with_measure_func) { YGNodeFreeRecursive(root); } + +TEST(YogaTest, aspect_ratio_width_height_flex_grow_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 200); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_width_height_flex_grow_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_height_as_flex_basis) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetAspectRatio(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(75, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(75, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_EQ(125, YGNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(125, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_width_as_flex_basis) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNew(); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetAspectRatio(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(75, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(75, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(75, YGNodeLayoutGetTop(root_child1)); + ASSERT_EQ(125, YGNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(125, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_overrides_flex_grow_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 0.5); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_overrides_flex_grow_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeStyleSetAspectRatio(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_left_right_absolute) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 10); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_top_bottom_absolute) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_width_overrides_align_stretch_row) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, aspect_ratio_height_overrides_align_stretch_column) { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNew(); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); +} diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 8b1c5fda..21f7290e 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1878,16 +1878,22 @@ static void YGNodelayoutImpl(const YGNodeRef node, } if (!YGValueIsUndefined(currentRelativeChild->style.aspectRatio)) { - if (isMainAxisRow && childHeightMeasureMode != YGMeasureModeExactly) { + if (isMainAxisRow) { childHeight = fmaxf(childWidth / currentRelativeChild->style.aspectRatio, YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionColumn)); childHeightMeasureMode = YGMeasureModeExactly; - } else if (!isMainAxisRow && childWidthMeasureMode != YGMeasureModeExactly) { + + childHeight = fminf(childHeight, availableInnerHeight); + childWidth = childHeight * currentRelativeChild->style.aspectRatio; + } else { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, YGNodePaddingAndBorderForAxis(currentRelativeChild, YGFlexDirectionRow)); childWidthMeasureMode = YGMeasureModeExactly; + + childWidth = fminf(childWidth, availableInnerWidth); + childHeight = childWidth / currentRelativeChild->style.aspectRatio; } } @@ -2080,13 +2086,23 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGMeasureMode childHeightMeasureMode = YGMeasureModeExactly; if (isMainAxisRow) { - childHeight = crossDim; childWidth = child->layout.measuredDimensions[YGDimensionWidth] + YGNodeMarginForAxis(child, YGFlexDirectionRow); + + if (!YGValueIsUndefined(child->style.aspectRatio)) { + childHeight = childWidth / child->style.aspectRatio; + } else { + childHeight = crossDim; + } } else { - childWidth = crossDim; childHeight = child->layout.measuredDimensions[YGDimensionHeight] + YGNodeMarginForAxis(child, YGFlexDirectionColumn); + + if (!YGValueIsUndefined(child->style.aspectRatio)) { + childWidth = childHeight * child->style.aspectRatio; + } else { + childWidth = crossDim; + } } YGConstrainMaxSizeForMode(child->style.maxDimensions[YGDimensionWidth], -- 2.50.1.windows.1 From ed765fe5085cf6e5c9bfb279f0accf1075f65f4d Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 22 Dec 2016 02:57:18 -0800 Subject: [PATCH 27/39] Convert max cache count into a define Summary: This should not be an enum. A define makes a whole lot more sense Differential Revision: D4346529 fbshipit-source-id: 8641c4c5017d915d64e5884cae09ac8f01861337 --- yoga/Yoga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 21f7290e..5dd21af1 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -42,7 +42,7 @@ typedef struct 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 { YG_MAX_CACHED_RESULT_COUNT = 16 }; +#define YG_MAX_CACHED_RESULT_COUNT 16 typedef struct YGLayout { float position[4]; -- 2.50.1.windows.1 From ff1a0e1eb8db37a707d2319ea79394bad133e55f Mon Sep 17 00:00:00 2001 From: David Hart Date: Thu, 22 Dec 2016 02:57:19 -0800 Subject: [PATCH 28/39] Transform the Count enum values into private constants Summary: Hides implementation details for the C, Objective-C and Swift APIs. Closes https://github.com/facebook/yoga/pull/292 Differential Revision: D4351523 Pulled By: emilsjolander fbshipit-source-id: 18a1149d169f0d52bd078714295000b5d07434dd --- enums.py | 6 +++--- yoga/YGEnums.h | 26 +++++++++++++------------- yoga/Yoga.c | 7 ------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/enums.py b/enums.py index d2fc6dc0..756c7c43 100644 --- a/enums.py +++ b/enums.py @@ -111,22 +111,22 @@ def to_java_upper(symbol): return out -root = os.path.dirname(__file__) +root = os.path.dirname(os.path.abspath(__file__)) -# write out C header +# write out C headers 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') f.write('YG_EXTERN_C_BEGIN\n\n') for name, values in ENUMS.items(): + f.write('#define YG%sCount %s\n' % (name, len(values))) f.write('typedef enum YG%s {\n' % name) for value in values: if isinstance(value, tuple): f.write(' YG%s%s = %d,\n' % (name, value[0], value[1])) else: f.write(' YG%s%s,\n' % (name, value)) - f.write(' YG%sCount,\n' % name) f.write('} YG%s;\n' % name) f.write('\n') f.write('YG_EXTERN_C_END\n') diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 85d9d2f9..a64c1673 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -13,28 +13,29 @@ YG_EXTERN_C_BEGIN +#define YGFlexDirectionCount 4 typedef enum YGFlexDirection { YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow, YGFlexDirectionRowReverse, - YGFlexDirectionCount, } YGFlexDirection; +#define YGMeasureModeCount 3 typedef enum YGMeasureMode { YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost, - YGMeasureModeCount, } YGMeasureMode; +#define YGPrintOptionsCount 3 typedef enum YGPrintOptions { YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4, - YGPrintOptionsCount, } YGPrintOptions; +#define YGEdgeCount 9 typedef enum YGEdge { YGEdgeLeft, YGEdgeTop, @@ -45,72 +46,71 @@ typedef enum YGEdge { YGEdgeHorizontal, YGEdgeVertical, YGEdgeAll, - YGEdgeCount, } YGEdge; +#define YGPositionTypeCount 2 typedef enum YGPositionType { YGPositionTypeRelative, YGPositionTypeAbsolute, - YGPositionTypeCount, } YGPositionType; +#define YGDimensionCount 2 typedef enum YGDimension { YGDimensionWidth, YGDimensionHeight, - YGDimensionCount, } YGDimension; +#define YGJustifyCount 5 typedef enum YGJustify { YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween, YGJustifySpaceAround, - YGJustifyCount, } YGJustify; +#define YGDirectionCount 3 typedef enum YGDirection { YGDirectionInherit, YGDirectionLTR, YGDirectionRTL, - YGDirectionCount, } YGDirection; +#define YGLogLevelCount 5 typedef enum YGLogLevel { YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose, - YGLogLevelCount, } YGLogLevel; +#define YGWrapCount 2 typedef enum YGWrap { YGWrapNoWrap, YGWrapWrap, - YGWrapCount, } YGWrap; +#define YGOverflowCount 3 typedef enum YGOverflow { YGOverflowVisible, YGOverflowHidden, YGOverflowScroll, - YGOverflowCount, } YGOverflow; +#define YGExperimentalFeatureCount 2 typedef enum YGExperimentalFeature { YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis, - YGExperimentalFeatureCount, } YGExperimentalFeature; +#define YGAlignCount 5 typedef enum YGAlign { YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, - YGAlignCount, } YGAlign; YG_EXTERN_C_END diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 5dd21af1..a73f8ad5 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -133,8 +133,6 @@ static int YGAndroidLog(YGLogLevel level, const char *format, va_list args) { case YGLogLevelVerbose: androidLevel = ANDROID_LOG_VERBOSE; break; - case YGLogLevelCount: - break; } const int result = __android_log_vprint(androidLevel, "YG-layout", format, args); return result; @@ -951,8 +949,6 @@ static void YGConstrainMaxSizeForMode(const float maxSize, YGMeasureMode *mode, *size = maxSize; } break; - case YGMeasureModeCount: - break; } } @@ -1968,7 +1964,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, leadingMainDim = betweenMainDim / 2; break; case YGJustifyFlexStart: - case YGJustifyCount: break; } @@ -2171,7 +2166,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, break; case YGAlignAuto: case YGAlignFlexStart: - case YGAlignCount: break; } @@ -2231,7 +2225,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, break; } case YGAlignAuto: - case YGAlignCount: break; } } -- 2.50.1.windows.1 From 0df58d8aa2ccd458aef52b50b7453c14e486a73e Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 22 Dec 2016 02:57:21 -0800 Subject: [PATCH 29/39] Declaratively initialize default values of nodes Summary: Improve performance of allocations and reseting by writing fewer bits. Also just looks nicer imho. Reviewed By: passy Differential Revision: D4356994 fbshipit-source-id: ebbe52163e0c86230bfa4131b657941afe16fbf1 --- tests/YGMemoryFuncTest.cpp | 2 +- yoga/Yoga.c | 122 +++++++++++++++++++------------------ 2 files changed, 64 insertions(+), 60 deletions(-) diff --git a/tests/YGMemoryFuncTest.cpp b/tests/YGMemoryFuncTest.cpp index bef2985c..b6481373 100644 --- a/tests/YGMemoryFuncTest.cpp +++ b/tests/YGMemoryFuncTest.cpp @@ -56,7 +56,7 @@ TEST(YogaTest, memory_func_test_funcs) { } YGNodeFreeRecursive(root); ASSERT_NE(testMallocCount, 0); - ASSERT_NE(testCallocCount, 0); + ASSERT_EQ(testCallocCount, 0); ASSERT_NE(testReallocCount, 0); ASSERT_NE(testFreeCount, 0); YGSetMemoryFuncs(NULL, NULL, NULL, NULL); diff --git a/yoga/Yoga.c b/yoga/Yoga.c index a73f8ad5..9723d894 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -106,6 +106,66 @@ typedef struct YGNode { void *context; } YGNode; +#define YG_DEFAULT_EDGE_VALUES { \ + [YGEdgeLeft] = YGUndefined, \ + [YGEdgeTop] = YGUndefined, \ + [YGEdgeRight] = YGUndefined, \ + [YGEdgeBottom] = YGUndefined, \ + [YGEdgeStart] = YGUndefined, \ + [YGEdgeEnd] = YGUndefined, \ + [YGEdgeHorizontal] = YGUndefined, \ + [YGEdgeVertical] = YGUndefined, \ + [YGEdgeAll] = YGUndefined, \ +} + +#define YG_DEFAULT_DIMENSION_VALUES { \ + [YGDimensionWidth] = YGUndefined, \ + [YGDimensionHeight] = YGUndefined, \ +} + +YGNode gYGNodeDefaults = { + .parent = NULL, + .children = NULL, + .hasNewLayout = true, + .isDirty = false, + + .style = { + .flex = YGUndefined, + .flexGrow = YGUndefined, + .flexShrink = YGUndefined, + .flexBasis = YGUndefined, + .justifyContent = YGJustifyFlexStart, + .alignItems = YGAlignStretch, + .alignContent = YGAlignFlexStart, + .direction = YGDirectionInherit, + .flexDirection = YGFlexDirectionColumn, + .overflow = YGOverflowVisible, + .dimensions = YG_DEFAULT_DIMENSION_VALUES, + .minDimensions = YG_DEFAULT_DIMENSION_VALUES, + .maxDimensions = YG_DEFAULT_DIMENSION_VALUES, + .position = YG_DEFAULT_EDGE_VALUES, + .margin = YG_DEFAULT_EDGE_VALUES, + .padding = YG_DEFAULT_EDGE_VALUES, + .border = YG_DEFAULT_EDGE_VALUES, + .aspectRatio = YGUndefined, + }, + + .layout = { + .dimensions = YG_DEFAULT_DIMENSION_VALUES, + .lastParentDirection = (YGDirection) -1, + .nextCachedMeasurementsIndex = 0, + .computedFlexBasis = YGUndefined, + .measuredDimensions = YG_DEFAULT_DIMENSION_VALUES, + + .cachedLayout = { + .widthMeasureMode = (YGMeasureMode) -1, + .heightMeasureMode = (YGMeasureMode) -1, + .computedWidth = -1, + .computedHeight = -1, + }, + }, +}; + static void YGNodeMarkDirtyInternal(const YGNodeRef node); YGMalloc gYGMalloc = &malloc; @@ -183,69 +243,14 @@ static inline float YGComputedEdgeValue(const float edges[YGEdgeCount], return defaultValue; } -static void YGNodeInit(const YGNodeRef node) { - node->parent = NULL; - node->children = NULL; - node->hasNewLayout = true; - node->isDirty = false; - - node->style.flex = YGUndefined; - node->style.flexGrow = YGUndefined; - node->style.flexShrink = YGUndefined; - node->style.flexBasis = YGUndefined; - - node->style.alignItems = YGAlignStretch; - node->style.justifyContent = YGJustifyFlexStart; - node->style.alignContent = YGAlignFlexStart; - - node->style.direction = YGDirectionInherit; - node->style.flexDirection = YGFlexDirectionColumn; - - node->style.overflow = YGOverflowVisible; - - // Some of the fields default to undefined and not 0 - node->style.dimensions[YGDimensionWidth] = YGUndefined; - node->style.dimensions[YGDimensionHeight] = YGUndefined; - - node->style.minDimensions[YGDimensionWidth] = YGUndefined; - node->style.minDimensions[YGDimensionHeight] = YGUndefined; - - node->style.maxDimensions[YGDimensionWidth] = YGUndefined; - node->style.maxDimensions[YGDimensionHeight] = YGUndefined; - - 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 = YGUndefined; - - node->layout.dimensions[YGDimensionWidth] = YGUndefined; - node->layout.dimensions[YGDimensionHeight] = YGUndefined; - - // Such that the comparison is always going to be false - node->layout.lastParentDirection = (YGDirection) -1; - node->layout.nextCachedMeasurementsIndex = 0; - node->layout.computedFlexBasis = YGUndefined; - - 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; -} - int32_t gNodeInstanceCount = 0; YGNodeRef YGNodeNew(void) { - const YGNodeRef node = gYGCalloc(1, sizeof(YGNode)); + const YGNodeRef node = gYGMalloc(sizeof(YGNode)); YG_ASSERT(node, "Could not allocate memory for node"); gNodeInstanceCount++; - YGNodeInit(node); + memcpy(node, &gYGNodeDefaults, sizeof(YGNode)); return node; } @@ -280,8 +285,7 @@ void YGNodeReset(const YGNodeRef node) { YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent"); YGNodeListFree(node->children); - memset(node, 0, sizeof(YGNode)); - YGNodeInit(node); + memcpy(node, &gYGNodeDefaults, sizeof(YGNode)); } int32_t YGNodeGetInstanceCount(void) { -- 2.50.1.windows.1 From e43c9f66ffda81dcab82f87b6f92bf0f8ea84d8e Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 22 Dec 2016 08:36:31 -0800 Subject: [PATCH 30/39] Add script to build Unity package Summary: Added Bash script and bat file to build a package of Yoga in order to import Yoga for Unity easily. Closes https://github.com/facebook/yoga/pull/288 Reviewed By: emilsjolander Differential Revision: D4344198 Pulled By: splhack fbshipit-source-id: 49ae27dbc513b4a2d161840ca5c5f4c9df2ab227 --- csharp/Unity/.gitignore | 3 +++ csharp/Unity/pack.sh | 53 +++++++++++++++++++++++++++++++++++++++++ csharp/Unity/win.bat | 2 ++ 3 files changed, 58 insertions(+) create mode 100644 csharp/Unity/.gitignore create mode 100755 csharp/Unity/pack.sh create mode 100755 csharp/Unity/win.bat diff --git a/csharp/Unity/.gitignore b/csharp/Unity/.gitignore new file mode 100644 index 00000000..a26b100a --- /dev/null +++ b/csharp/Unity/.gitignore @@ -0,0 +1,3 @@ +Yoga +yoga.dll +yoga.unitypackage diff --git a/csharp/Unity/pack.sh b/csharp/Unity/pack.sh new file mode 100755 index 00000000..402a9632 --- /dev/null +++ b/csharp/Unity/pack.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# 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. + +cd "$( dirname "$0" )" + +if [ \! -f yoga.dll ]; then + echo "Launch win.bat on Windows and copy yoga.dll to here" + exit 1 +fi + +function build { + buck build $1 + echo "$root/`buck targets --show-output $1|tail -1|awk '{print $2}'`" +} + +function copy { + mkdir -p $3 + cp $1 $3/$2 +} + +rm -rf Yoga yoga.unitypackage + +root=`buck root|tail -f` +mac=$(build '//csharp:yoganet#default,shared') +armv7=$(build '//csharp:yoganet#android-armv7,shared') +ios=$(build '//csharp:yoganet-ios') +win=yoga.dll + +Unity -quit -batchMode -createProject Yoga + +copy $win ${win##*/} Yoga/Assets/Facebook.Yoga/Plugins/x86_64 +copy $mac yoga Yoga/Assets/Facebook.Yoga/Plugins/x86_64/yoga.bundle/Contents/MacOS +armv7path=Assets/Plugins/Android/libs/armeabi-v7a +copy $armv7 ${armv7##*/} Yoga/$armv7path +iospath=Assets/Plugins/iOS +copy $ios ${ios##*/} Yoga/$iospath +libs="$armv7path/${armv7##*/} $iospath/${ios##*/}" + +scripts=Yoga/Assets/Facebook.Yoga/Scripts/Facebook.Yoga +mkdir -p $scripts +(cd ../Facebook.Yoga; tar cf - *.cs)|tar -C $scripts -xf - + +tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests +mkdir -p $tests +(cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf - + +Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs `pwd`/yoga.unitypackage + diff --git a/csharp/Unity/win.bat b/csharp/Unity/win.bat new file mode 100755 index 00000000..3f838cd4 --- /dev/null +++ b/csharp/Unity/win.bat @@ -0,0 +1,2 @@ +"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ..\Yoga\Yoga.vcxproj /p:configuration=Release /property:Platform=x64 +xcopy "..\Yoga\x64\Release\yoga.dll" %~dp0 /s /d /y -- 2.50.1.windows.1 From df0f76bba5814f5cacc37f82ce7555c9b710a9cb Mon Sep 17 00:00:00 2001 From: Hannes Verlinde Date: Fri, 23 Dec 2016 02:05:43 -0800 Subject: [PATCH 31/39] Run unit tests on Sandcastle Summary: - Change the CI config so it runs the tests for Editor on Sandcastle - Don't run tests for effects-framework and yoga libraries when building for Mac (triggers code signing issues that I don't want to deal with right now) - Add target for unit tests (aka EditorTests) - Make the existing unit tests build and pass. These include both Objective-C and Swift (we should probably get rid of some of these though). I will convert these to Swift 3 before landing (after the migration is complete). - Exclude the EditorUITests target for now. It only contains a single dummy test and it causes a code signing failure on Sandcastle. I did not manage to work around that yet but there is a separate task for it. Reviewed By: Perspx Differential Revision: D4352670 fbshipit-source-id: 0295004a72953bd8e7ae83895b2e5712bab7bd32 --- BUCK | 1 + 1 file changed, 1 insertion(+) diff --git a/BUCK b/BUCK index aa7ec37e..49107901 100644 --- a/BUCK +++ b/BUCK @@ -20,6 +20,7 @@ cxx_library( soname = 'libyogacore.$(ext)', srcs = glob(['yoga/*.c']), tests=[':YogaTests'], + fbobjc_macosx_tests_override = [], exported_headers = subdir_glob([('', 'yoga/*.h')]), header_namespace = '', compiler_flags = COMPILER_FLAGS, -- 2.50.1.windows.1 From 4717594e93b1314e41c0a81121bf2f180483e25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Fr=C4=85cz?= Date: Fri, 23 Dec 2016 08:29:31 -0800 Subject: [PATCH 32/39] Switched to using SafeHandle for native code interrupt Summary: This PR fixes issue #295 - Created a new internal YGNodeHandle class extending SafeHandle. - YogaNode now stores a reference to YGNodeHandle. - Removed finalizer from YogaNode. - Pulling in System.Runtime.Handles 4.3.0. Closes https://github.com/facebook/yoga/pull/297 Reviewed By: emilsjolander Differential Revision: D4365462 Pulled By: splhack fbshipit-source-id: 73293b105962cbedb71f4e3d8d1244251db1ea79 --- csharp/Facebook.Yoga/Native.cs | 166 ++++++++++++++++-------------- csharp/Facebook.Yoga/YogaNode.cs | 9 +- csharp/Facebook.Yoga/project.json | 3 +- 3 files changed, 95 insertions(+), 83 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 57cc654f..a11dfd91 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -20,18 +20,40 @@ namespace Facebook.Yoga private const string DllName = "yoga"; #endif + internal class YGNodeHandle : SafeHandle + { + private YGNodeHandle() : base(IntPtr.Zero, true) + { + } + + public override bool IsInvalid + { + get + { + return this.handle == IntPtr.Zero; + } + } + + protected override bool ReleaseHandle() + { + Native.YGNodeFree(this.handle); + GC.KeepAlive(this); + return true; + } + } + [DllImport(DllName)] public static extern void YGInteropSetLogger( [MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func); [DllImport(DllName)] - public static extern IntPtr YGNodeNew(); + public static extern YGNodeHandle YGNodeNew(); [DllImport(DllName)] public static extern void YGNodeFree(IntPtr node); [DllImport(DllName)] - public static extern void YGNodeReset(IntPtr node); + public static extern void YGNodeReset(YGNodeHandle node); [DllImport(DllName)] public static extern int YGNodeGetInstanceCount(); @@ -46,237 +68,231 @@ namespace Facebook.Yoga YogaExperimentalFeature feature); [DllImport(DllName)] - public static extern void YGNodeInsertChild(IntPtr node, IntPtr child, uint index); + public static extern void YGNodeInsertChild(YGNodeHandle node, YGNodeHandle child, uint index); [DllImport(DllName)] - public static extern void YGNodeRemoveChild(IntPtr node, IntPtr child); + public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child); [DllImport(DllName)] - public static extern IntPtr YGNodeGetChild(IntPtr node, uint index); - - [DllImport(DllName)] - public static extern uint YGNodeGetChildCount(IntPtr node); - - [DllImport(DllName)] - public static extern void YGNodeCalculateLayout(IntPtr node, + public static extern void YGNodeCalculateLayout(YGNodeHandle node, float availableWidth, float availableHeight, YogaDirection parentDirection); [DllImport(DllName)] - public static extern void YGNodeMarkDirty(IntPtr node); + public static extern void YGNodeMarkDirty(YGNodeHandle node); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool YGNodeIsDirty(IntPtr node); + public static extern bool YGNodeIsDirty(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodePrint(IntPtr node, YogaPrintOptions options); + public static extern void YGNodePrint(YGNodeHandle node, YogaPrintOptions options); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool YGValueIsUndefined(float value); [DllImport(DllName)] - public static extern void YGNodeCopyStyle(IntPtr dstNode, IntPtr srcNode); + public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode); #region YG_NODE_PROPERTY [DllImport(DllName)] - public static extern void YGNodeSetContext(IntPtr node, IntPtr context); + public static extern void YGNodeSetContext(YGNodeHandle node, IntPtr context); [DllImport(DllName)] - public static extern IntPtr YGNodeGetContext(IntPtr node); + public static extern IntPtr YGNodeGetContext(YGNodeHandle node); [DllImport(DllName)] public static extern void YGNodeSetMeasureFunc( - IntPtr node, + YGNodeHandle node, [MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.FunctionPtr)] - public static extern YogaMeasureFunc YGNodeGetMeasureFunc(IntPtr node); + public static extern YogaMeasureFunc YGNodeGetMeasureFunc(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); + public static extern void YGNodeSetHasNewLayout(YGNodeHandle node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout); [DllImport(DllName)] [return: MarshalAs(UnmanagedType.I1)] - public static extern bool YGNodeGetHasNewLayout(IntPtr node); + public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node); #endregion #region YG_NODE_STYLE_PROPERTY [DllImport(DllName)] - public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction); + public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction); [DllImport(DllName)] - public static extern YogaDirection YGNodeStyleGetDirection(IntPtr node); + public static extern YogaDirection YGNodeStyleGetDirection(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection); + public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection); [DllImport(DllName)] - public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(IntPtr node); + public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent); + public static extern void YGNodeStyleSetJustifyContent(YGNodeHandle node, YogaJustify justifyContent); [DllImport(DllName)] - public static extern YogaJustify YGNodeStyleGetJustifyContent(IntPtr node); + public static extern YogaJustify YGNodeStyleGetJustifyContent(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent); + public static extern void YGNodeStyleSetAlignContent(YGNodeHandle node, YogaAlign alignContent); [DllImport(DllName)] - public static extern YogaAlign YGNodeStyleGetAlignContent(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignContent(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems); + public static extern void YGNodeStyleSetAlignItems(YGNodeHandle node, YogaAlign alignItems); [DllImport(DllName)] - public static extern YogaAlign YGNodeStyleGetAlignItems(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignItems(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf); + public static extern void YGNodeStyleSetAlignSelf(YGNodeHandle node, YogaAlign alignSelf); [DllImport(DllName)] - public static extern YogaAlign YGNodeStyleGetAlignSelf(IntPtr node); + public static extern YogaAlign YGNodeStyleGetAlignSelf(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType); + public static extern void YGNodeStyleSetPositionType(YGNodeHandle node, YogaPositionType positionType); [DllImport(DllName)] - public static extern YogaPositionType YGNodeStyleGetPositionType(IntPtr node); + public static extern YogaPositionType YGNodeStyleGetPositionType(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap); + public static extern void YGNodeStyleSetFlexWrap(YGNodeHandle node, YogaWrap flexWrap); [DllImport(DllName)] - public static extern YogaWrap YGNodeStyleGetFlexWrap(IntPtr node); + public static extern YogaWrap YGNodeStyleGetFlexWrap(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap); + public static extern void YGNodeStyleSetOverflow(YGNodeHandle node, YogaOverflow flexWrap); [DllImport(DllName)] - public static extern YogaOverflow YGNodeStyleGetOverflow(IntPtr node); + public static extern YogaOverflow YGNodeStyleGetOverflow(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlex(IntPtr node, float flex); + public static extern void YGNodeStyleSetFlex(YGNodeHandle node, float flex); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexGrow(IntPtr node, float flexGrow); + public static extern void YGNodeStyleSetFlexGrow(YGNodeHandle node, float flexGrow); [DllImport(DllName)] - public static extern float YGNodeStyleGetFlexGrow(IntPtr node); + public static extern float YGNodeStyleGetFlexGrow(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexShrink(IntPtr node, float flexShrink); + public static extern void YGNodeStyleSetFlexShrink(YGNodeHandle node, float flexShrink); [DllImport(DllName)] - public static extern float YGNodeStyleGetFlexShrink(IntPtr node); + public static extern float YGNodeStyleGetFlexShrink(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis); + public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis); [DllImport(DllName)] - public static extern float YGNodeStyleGetFlexBasis(IntPtr node); + public static extern float YGNodeStyleGetFlexBasis(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetWidth(IntPtr node, float width); + public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); [DllImport(DllName)] - public static extern float YGNodeStyleGetWidth(IntPtr node); + public static extern float YGNodeStyleGetWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetHeight(IntPtr node, float height); + public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); [DllImport(DllName)] - public static extern float YGNodeStyleGetHeight(IntPtr node); + public static extern float YGNodeStyleGetHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth); + public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); [DllImport(DllName)] - public static extern float YGNodeStyleGetMinWidth(IntPtr node); + public static extern float YGNodeStyleGetMinWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight); + public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); [DllImport(DllName)] - public static extern float YGNodeStyleGetMinHeight(IntPtr node); + public static extern float YGNodeStyleGetMinHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth); + public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); [DllImport(DllName)] - public static extern float YGNodeStyleGetMaxWidth(IntPtr node); + public static extern float YGNodeStyleGetMaxWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight); + public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); [DllImport(DllName)] - public static extern float YGNodeStyleGetMaxHeight(IntPtr node); + public static extern float YGNodeStyleGetMaxHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio); + public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio); [DllImport(DllName)] - public static extern float YGNodeStyleGetAspectRatio(IntPtr node); + public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node); #endregion #region YG_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName)] - public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position); + public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position); [DllImport(DllName)] - public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin); + public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); [DllImport(DllName)] - public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding); + public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); [DllImport(DllName)] - public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); [DllImport(DllName)] - public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border); + public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border); [DllImport(DllName)] - public static extern float YGNodeStyleGetBorder(IntPtr node, YogaEdge edge); + public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge); #endregion #region YG_NODE_LAYOUT_PROPERTY [DllImport(DllName)] - public static extern float YGNodeLayoutGetLeft(IntPtr node); + public static extern float YGNodeLayoutGetLeft(YGNodeHandle node); [DllImport(DllName)] - public static extern float YGNodeLayoutGetTop(IntPtr node); + public static extern float YGNodeLayoutGetTop(YGNodeHandle node); [DllImport(DllName)] - public static extern float YGNodeLayoutGetRight(IntPtr node); + public static extern float YGNodeLayoutGetRight(YGNodeHandle node); [DllImport(DllName)] - public static extern float YGNodeLayoutGetBottom(IntPtr node); + public static extern float YGNodeLayoutGetBottom(YGNodeHandle node); [DllImport(DllName)] - public static extern float YGNodeLayoutGetWidth(IntPtr node); + public static extern float YGNodeLayoutGetWidth(YGNodeHandle node); [DllImport(DllName)] - public static extern float YGNodeLayoutGetHeight(IntPtr node); + public static extern float YGNodeLayoutGetHeight(YGNodeHandle node); [DllImport(DllName)] - public static extern YogaDirection YGNodeLayoutGetDirection(IntPtr node); + public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node); #endregion } diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 9211b28e..ab2989e8 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -17,7 +17,7 @@ namespace Facebook.Yoga { public partial class YogaNode : IEnumerable { - private IntPtr _ygNode; + private Native.YGNodeHandle _ygNode; private WeakReference _parent; private List _children; private MeasureFunction _measureFunction; @@ -29,17 +29,12 @@ namespace Facebook.Yoga YogaLogger.Initialize(); _ygNode = Native.YGNodeNew(); - if (_ygNode == IntPtr.Zero) + if (_ygNode.IsInvalid) { throw new InvalidOperationException("Failed to allocate native memory"); } } - ~YogaNode() - { - Native.YGNodeFree(_ygNode); - } - public void Reset() { _measureFunction = null; diff --git a/csharp/Facebook.Yoga/project.json b/csharp/Facebook.Yoga/project.json index a0454a86..a188a056 100644 --- a/csharp/Facebook.Yoga/project.json +++ b/csharp/Facebook.Yoga/project.json @@ -3,7 +3,8 @@ "version": "3.0.0-*", "dependencies": { - "NETStandard.Library": "1.6.0" + "NETStandard.Library": "1.6.0", + "System.Runtime.Handles": "4.3.0" }, "frameworks": { -- 2.50.1.windows.1 From a302b76d59d796c7868ace7919549e80482fd958 Mon Sep 17 00:00:00 2001 From: David Hart Date: Fri, 23 Dec 2016 08:44:24 -0800 Subject: [PATCH 33/39] Added gitignore rule for Xcode xcuserdata Summary: Closes https://github.com/facebook/yoga/pull/294 Reviewed By: dshahidehpour Differential Revision: D4365534 Pulled By: emilsjolander fbshipit-source-id: ff899d3526156ce9bbe8cba07418ca77b2f38ac8 --- .gitignore | 41 ++++++++ .hgignore | 41 ++++++++ .../UserInterfaceState.xcuserstate | Bin 20985 -> 0 bytes .../xcschemes/YogaKitSample.xcscheme | 91 ------------------ .../xcschemes/xcschememanagement.plist | 22 ----- 5 files changed, 82 insertions(+), 113 deletions(-) delete mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/xcuserdata/emilsj.xcuserdatad/UserInterfaceState.xcuserstate delete mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/YogaKitSample.xcscheme delete mode 100644 YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/.gitignore b/.gitignore index 5b346768..fca97a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,44 @@ # Visual studio code .vscode + +# Xcode +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xcuserstate + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build diff --git a/.hgignore b/.hgignore index 5b346768..fca97a4b 100644 --- a/.hgignore +++ b/.hgignore @@ -8,3 +8,44 @@ # Visual studio code .vscode + +# Xcode +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xcuserstate + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build 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 deleted file mode 100644 index 47db969a47042b4903b4e9d2c32d6e0280b8de55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20985 zcmch930zcF7x=wzlbrzuhMfV1Rc2*27G+n-H9$mAX@EgTM+RpG70tXa)3h|TEYr*c z+{)6lY|r-kDs53)P0RMZ%&fHSf8M+qU<|+d{@?fi*RO{6?!D)pd+yoKy|1OyZgaUc zn&Su~3eku`EaJEyxpNJQ`BtaP=ICfpI9g^~Tivdy3X8LKmJMFlDcp|ENQ75x+ZRDa zqhTljMIkAQMp-Bu<)BJ(|ilcE1mf>`)z!^9bXW?v|gLCn4 ztipO+giCM*9*xK1ad;BG98bZGcsjP=7TkdyxD(IAPJ9(!iV5cN)p$9+9LzLfbt|=n>ZSUqyQsa?KI&fTe(E6g0QCsaH1!PiGIf|bLLH;tp-xjDQXf%YQD0NvQ0J(hs6VJbX+%fTQM8nfrekOs9ZSd2 zS#&m?L+8@N={#CT8)*|=MwinSbR}IySJUI@8oHjILbuXww3TkBXVP(AUx{>8EQkgU+lgVO+GkJ`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|NUTiD27dwjQ6)!C2i&u^OcI26n7fJ$3!b@UG z(n~ZY`6b4Zf|BBrl9KY0i6u29btO|u8cU{?%qY2{WO>P5CC5wtC>>TBUK(4PP^u^$ zUaBdrC>>Qgv9zYNuC%_ixzt^{pmb5`l2TH-taL@`s?yb^YfEn|-B8+7+E==xba&}@ zrN5Q_QHILsvbr)$S! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 336f995f..00000000 --- a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/xcuserdata/emilsj.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - YogaKitSample.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - 13687D421DF8748300E7C260 - - primary - - - - - -- 2.50.1.windows.1 From f1ab289022cf38a9e8502f65e7760e71e9723403 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 23 Dec 2016 09:48:55 -0800 Subject: [PATCH 34/39] Run unit tests before building Unity package Summary: - Enable destructor unit tests in Unity Editor - Exit pack.sh immediately if a command exits with a non-zero status - Run unit tests before building Unity package Reviewed By: emilsjolander Differential Revision: D4365773 fbshipit-source-id: 20d0a51f4cef791154c17d329ac36598dc333a60 --- csharp/Unity/pack.sh | 13 ++++++++++++- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 2 -- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/csharp/Unity/pack.sh b/csharp/Unity/pack.sh index 402a9632..cc79ef0b 100755 --- a/csharp/Unity/pack.sh +++ b/csharp/Unity/pack.sh @@ -6,6 +6,8 @@ # 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. +set -e + cd "$( dirname "$0" )" if [ \! -f yoga.dll ]; then @@ -49,5 +51,14 @@ tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests mkdir -p $tests (cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf - -Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs `pwd`/yoga.unitypackage +function onerror { + local xml=Yoga/EditorTestResults.xml + if [ -f $xml ]; then cat $xml|grep 'success="False"'; fi +} +trap onerror EXIT +Unity -quit -batchMode -projectPath `pwd`/Yoga -runEditorTests +pkg="`pwd`/yoga.unitypackage" +Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs $pkg + +echo "Success: $pkg" diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index 5cf1002b..7efd2a67 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -228,7 +228,6 @@ namespace Facebook.Yoga Assert.AreEqual(100, node0.MaxHeight); } -#if !UNITY_EDITOR private void ForceGC() { GC.Collect(GC.MaxGeneration); @@ -356,6 +355,5 @@ namespace Facebook.Yoga return MeasureOutput.Make(120, 130); }); } -#endif } } -- 2.50.1.windows.1 From 92137273a2024c8e71686d25fc4cdde13bbbc8da Mon Sep 17 00:00:00 2001 From: desmondyao Date: Fri, 23 Dec 2016 10:15:50 -0800 Subject: [PATCH 35/39] Not re-calculate value in Step1. Summary: Not re-calculate `paddingAndBorderAxisMain`/`paddingAndBorderAxisCross`/`paddingAndBorderAxisRow`/`paddingAndBorderAxisColumn` in Step1 of `YGNodelayoutImpl`. They can be figure out by values calculated before. Closes https://github.com/facebook/yoga/pull/298 Reviewed By: dshahidehpour Differential Revision: D4365533 Pulled By: emilsjolander fbshipit-source-id: 6caf60bc6ef3addd49915b39b48f01a8b4926e9c --- yoga/Yoga.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 9723d894..32bc01e4 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -1500,9 +1500,9 @@ static void YGNodelayoutImpl(const YGNodeRef node, const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; - const float paddingAndBorderAxisRow = YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow); - const float paddingAndBorderAxisColumn = - YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn); + const float paddingAndBorderAxisRow = isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross; + const float paddingAndBorderAxisColumn = isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain; + const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow); const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn); @@ -1516,7 +1516,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float maxInnerHeight = node->style.maxDimensions[YGDimensionHeight] - marginAxisColumn - paddingAndBorderAxisColumn; const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight; const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight; - + // Max dimension overrides predefined dimension value; Min dimension in turn overrides both of the above if (!YGValueIsUndefined(availableInnerWidth)) { availableInnerWidth = fmaxf(fminf(availableInnerWidth, maxInnerWidth), minInnerWidth); @@ -1524,7 +1524,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, if (!YGValueIsUndefined(availableInnerHeight)) { availableInnerHeight = fmaxf(fminf(availableInnerHeight, maxInnerHeight), minInnerHeight); } - + float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight; const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; @@ -1679,7 +1679,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // 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. - + // We resolve main dimension to fit minimum and maximum values if (YGValueIsUndefined(availableInnerMainDim)) { if (!YGValueIsUndefined(minInnerMainDim) && @@ -1690,7 +1690,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerMainDim = maxInnerMainDim; } } - + float remainingFreeSpace = 0; if (!YGValueIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; -- 2.50.1.windows.1 From abad796c44e4ef3c4dc9499df8ac9f6d1e838498 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 23 Dec 2016 11:20:27 -0800 Subject: [PATCH 36/39] Fix BUCK Summary: Remove internal arg Reviewed By: emilsjolander Differential Revision: D4365827 fbshipit-source-id: 705855732146e03da65f21cbaa746277719b72f4 --- BUCK | 1 - 1 file changed, 1 deletion(-) diff --git a/BUCK b/BUCK index 49107901..aa7ec37e 100644 --- a/BUCK +++ b/BUCK @@ -20,7 +20,6 @@ cxx_library( soname = 'libyogacore.$(ext)', srcs = glob(['yoga/*.c']), tests=[':YogaTests'], - fbobjc_macosx_tests_override = [], exported_headers = subdir_glob([('', 'yoga/*.h')]), header_namespace = '', compiler_flags = COMPILER_FLAGS, -- 2.50.1.windows.1 From 12017e49bdd7e0d44761d032b38b5bf2f0e90c8d Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 23 Dec 2016 12:02:21 -0800 Subject: [PATCH 37/39] Update .git/hgignore Summary: Fix paths Reviewed By: emilsjolander Differential Revision: D4365853 fbshipit-source-id: 1eb5b1046f4bb7a18b8f29d2876c0d560c3fad49 --- csharp/.gitignore | 9 ++++----- csharp/.hgignore | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/csharp/.gitignore b/csharp/.gitignore index 533ef745..bdb6ff4e 100644 --- a/csharp/.gitignore +++ b/csharp/.gitignore @@ -30,15 +30,14 @@ 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 TestResult.xml +tests/Facebook.Yoga/NUnit-[0-9\.]*/ +tests/Facebook.Yoga/YogaTest.dll +tests/Facebook.Yoga/YogaTest.dll.mdb +tests/Facebook.Yoga/libyoga.dylib # Build Results of an ATL Project [Dd]ebugPS/ diff --git a/csharp/.hgignore b/csharp/.hgignore index 4dd1c600..bdb6ff4e 100644 --- a/csharp/.hgignore +++ b/csharp/.hgignore @@ -34,11 +34,10 @@ 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/ +tests/Facebook.Yoga/NUnit-[0-9\.]*/ +tests/Facebook.Yoga/YogaTest.dll +tests/Facebook.Yoga/YogaTest.dll.mdb +tests/Facebook.Yoga/libyoga.dylib # Build Results of an ATL Project [Dd]ebugPS/ -- 2.50.1.windows.1 From 9f59a1383659846309facd782a7696558de78664 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 23 Dec 2016 12:02:40 -0800 Subject: [PATCH 38/39] Remove unused P/Invoke interface Summary: - Remove YGNodeGetContext and YGNodeSetContext from Native.cs - https://github.com/facebook/yoga/pull/297#discussion_r93789907 Reviewed By: emilsjolander Differential Revision: D4365845 fbshipit-source-id: 89b41ec773baa1b4901f637f5e83427c9fba4aed --- csharp/Facebook.Yoga/Native.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index a11dfd91..a07ab94e 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -98,12 +98,6 @@ namespace Facebook.Yoga #region YG_NODE_PROPERTY - [DllImport(DllName)] - public static extern void YGNodeSetContext(YGNodeHandle node, IntPtr context); - - [DllImport(DllName)] - public static extern IntPtr YGNodeGetContext(YGNodeHandle node); - [DllImport(DllName)] public static extern void YGNodeSetMeasureFunc( YGNodeHandle node, -- 2.50.1.windows.1 From 24c6ce5aa7c740e9eac56265b86731e57af5a31f Mon Sep 17 00:00:00 2001 From: roxlu Date: Fri, 23 Dec 2016 23:40:51 +0100 Subject: [PATCH 39/39] Oops typo, character at the top of Yoga.h --- yoga/Yoga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yoga/Yoga.h b/yoga/Yoga.h index d6d7ab69..91b3c769 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -1,4 +1,4 @@ -n/** +/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * -- 2.50.1.windows.1