diff --git a/YogaKit/Source/YGLayout.h b/YogaKit/Source/YGLayout.h
index 3052b439..83dbf36b 100644
--- a/YogaKit/Source/YGLayout.h
+++ b/YogaKit/Source/YGLayout.h
@@ -32,6 +32,7 @@
@property (nonatomic, readwrite, assign) YGPositionType position;
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
@property (nonatomic, readwrite, assign) YGOverflow overflow;
+@property (nonatomic, readwrite, assign) YGDisplay display;
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m
index 23cee161..9c44cc83 100644
--- a/YogaKit/Source/YGLayout.m
+++ b/YogaKit/Source/YGLayout.m
@@ -181,6 +181,7 @@ YG_PROPERTY(YGAlign, alignItems, AlignItems)
YG_PROPERTY(YGAlign, alignSelf, AlignSelf)
YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow)
+YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs
index 3be879cf..2c0d25ac 100644
--- a/csharp/Facebook.Yoga/Native.cs
+++ b/csharp/Facebook.Yoga/Native.cs
@@ -169,6 +169,12 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaOverflow YGNodeStyleGetOverflow(YGNodeHandle node);
+ [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void YGNodeStyleSetDisplay(YGNodeHandle node, YogaDisplay display);
+
+ [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+ public static extern YogaDisplay YGNodeStyleGetDisplay(YGNodeHandle node);
+
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlex(YGNodeHandle node, float flex);
diff --git a/csharp/Facebook.Yoga/YogaDisplay.cs b/csharp/Facebook.Yoga/YogaDisplay.cs
new file mode 100644
index 00000000..0606f14b
--- /dev/null
+++ b/csharp/Facebook.Yoga/YogaDisplay.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.Yoga
+{
+ public enum YogaDisplay
+ {
+ Flex,
+ None,
+ }
+}
diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs
index 9b5bd796..59b6ae08 100644
--- a/csharp/Facebook.Yoga/YogaNode.cs
+++ b/csharp/Facebook.Yoga/YogaNode.cs
@@ -145,6 +145,19 @@ namespace Facebook.Yoga
}
}
+ public YogaDisplay Display
+ {
+ get
+ {
+ return Native.YGNodeStyleGetDisplay(_ygNode);
+ }
+
+ set
+ {
+ Native.YGNodeStyleSetDisplay(_ygNode, value);
+ }
+ }
+
public YogaAlign AlignItems
{
get
diff --git a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs
new file mode 100644
index 00000000..ccaa35c8
--- /dev/null
+++ b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs
@@ -0,0 +1,332 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
+
+using System;
+using NUnit.Framework;
+
+namespace Facebook.Yoga
+{
+ [TestFixture]
+ public class YGDisplayTest
+ {
+ [Test]
+ public void Test_display_none()
+ {
+ YogaNode root = new YogaNode();
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode();
+ root_child1.FlexGrow = 1;
+ root_child1.Display = YogaDisplay.None;
+ 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, root_child1.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_display_none_fixed_size()
+ {
+ YogaNode root = new YogaNode();
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode();
+ root_child1.Width = 20;
+ root_child1.Height = 20;
+ root_child1.Display = YogaDisplay.None;
+ 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, root_child1.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_display_none_with_margin()
+ {
+ YogaNode root = new YogaNode();
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.MarginLeft = 10;
+ root_child0.MarginTop = 10;
+ root_child0.MarginRight = 10;
+ root_child0.MarginBottom = 10;
+ root_child0.Width = 20;
+ root_child0.Height = 20;
+ root_child0.Display = YogaDisplay.None;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode();
+ root_child1.FlexGrow = 1;
+ 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(0f, root_child0.LayoutWidth);
+ Assert.AreEqual(0f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(100f, 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(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(0f, root_child0.LayoutWidth);
+ Assert.AreEqual(0f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(100f, root_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child1.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_display_none_with_child()
+ {
+ YogaNode root = new YogaNode();
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1;
+ root_child0.FlexShrink = 1;
+ root_child0.FlexBasis = 0.Percent();
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode();
+ root_child1.FlexGrow = 1;
+ root_child1.FlexShrink = 1;
+ root_child1.FlexBasis = 0.Percent();
+ root_child1.Display = YogaDisplay.None;
+ root.Insert(1, root_child1);
+
+ YogaNode root_child1_child0 = new YogaNode();
+ root_child1_child0.FlexGrow = 1;
+ root_child1_child0.FlexShrink = 1;
+ root_child1_child0.FlexBasis = 0.Percent();
+ root_child1_child0.Width = 20;
+ root_child1_child0.MinWidth = 0;
+ root_child1_child0.MinHeight = 0;
+ root_child1.Insert(0, root_child1_child0);
+
+ YogaNode root_child2 = new YogaNode();
+ root_child2.FlexGrow = 1;
+ root_child2.FlexShrink = 1;
+ root_child2.FlexBasis = 0.Percent();
+ root.Insert(2, root_child2);
+ 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(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1_child0.LayoutX);
+ Assert.AreEqual(0f, root_child1_child0.LayoutY);
+ Assert.AreEqual(0f, root_child1_child0.LayoutWidth);
+ Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
+
+ Assert.AreEqual(50f, root_child2.LayoutX);
+ Assert.AreEqual(0f, root_child2.LayoutY);
+ Assert.AreEqual(50f, root_child2.LayoutWidth);
+ Assert.AreEqual(100f, root_child2.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(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1_child0.LayoutX);
+ Assert.AreEqual(0f, root_child1_child0.LayoutY);
+ Assert.AreEqual(0f, root_child1_child0.LayoutWidth);
+ Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child2.LayoutX);
+ Assert.AreEqual(0f, root_child2.LayoutY);
+ Assert.AreEqual(50f, root_child2.LayoutWidth);
+ Assert.AreEqual(100f, root_child2.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_display_none_with_position()
+ {
+ YogaNode root = new YogaNode();
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode();
+ root_child1.FlexGrow = 1;
+ root_child1.Top = 10;
+ root_child1.Display = YogaDisplay.None;
+ 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, 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(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(0f, root_child1.LayoutWidth);
+ Assert.AreEqual(0f, root_child1.LayoutHeight);
+ }
+
+ }
+}
diff --git a/enums.py b/enums.py
index 6ac522de..47ff69ca 100644
--- a/enums.py
+++ b/enums.py
@@ -52,6 +52,10 @@ ENUMS = {
'Relative',
'Absolute',
],
+ 'Display': [
+ 'Flex',
+ 'None',
+ ],
'Wrap': [
'NoWrap',
'Wrap',
diff --git a/gentest/fixtures/YGDisplayTest.html b/gentest/fixtures/YGDisplayTest.html
new file mode 100644
index 00000000..74d11ba4
--- /dev/null
+++ b/gentest/fixtures/YGDisplayTest.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js
index 9a119557..d8a74a1c 100644
--- a/gentest/gentest-cpp.js
+++ b/gentest/gentest-cpp.js
@@ -118,6 +118,9 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGUndefined:{value:'YGUndefined'},
+ YGDisplayFlex:{value:'YGDisplayFlex'},
+ YGDisplayNone:{value:'YGDisplayNone'},
+
YGNodeCalculateLayout:{value:function(node, dir) {
this.push('YGNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');');
}},
@@ -162,6 +165,10 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
+ YGNodeStyleSetDisplay:{value:function(nodeName, value) {
+ this.push('YGNodeStyleSetDisplay(' + nodeName + ', ' + toValueCpp(value) + ');');
+ }},
+
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexBasis' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}},
diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js
index 08b08588..3650d862 100644
--- a/gentest/gentest-cs.js
+++ b/gentest/gentest-cs.js
@@ -128,6 +128,9 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
YGUndefined:{value:'YogaConstants.Undefined'},
+ YGDisplayFlex:{value:'YogaDisplay.Flex'},
+ YGDisplayNone:{value:'YogaDisplay.None'},
+
YGWrapNoWrap:{value:'YogaWrap.NoWrap'},
YGWrapWrap:{value:'YogaWrap.Wrap'},
@@ -176,6 +179,10 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
this.push(nodeName + '.StyleDirection = ' + toValueCs(value) + ';');
}},
+ YGNodeStyleSetDisplay:{value:function(nodeName, value) {
+ this.push(nodeName + '.Display = ' + toValueCs(value) + ';');
+ }},
+
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + toCsUnitValue(value) + ';');
}},
diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js
index 32b3d99b..e5b1858d 100644
--- a/gentest/gentest-java.js
+++ b/gentest/gentest-java.js
@@ -132,6 +132,9 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGUndefined:{value:'YogaConstants.UNDEFINED'},
+ YGDisplayFlex:{value:'YogaDisplay.FLEX'},
+ YGDisplayNone:{value:'YogaDisplay.NONE'},
+
YGWrapNoWrap:{value:'YogaWrap.NO_WRAP'},
YGWrapWrap:{value:'YogaWrap.WRAP'},
@@ -180,6 +183,10 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
this.push(nodeName + '.setDirection(' + toValueJava(value) + ');');
}},
+ YGNodeStyleSetDisplay:{value:function(nodeName, value) {
+ this.push(nodeName + '.setDisplay(' + toValueJavascript(value) + ');');
+ }},
+
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexBasis' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}},
diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js
index 8f56477e..67c38e83 100644
--- a/gentest/gentest-javascript.js
+++ b/gentest/gentest-javascript.js
@@ -125,6 +125,9 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGUndefined:{value:'Yoga.UNDEFINED'},
+ YGDisplayFlex:{value:'Yoga.DISPLAY_FLEX'},
+ YGDisplayNone:{value:'Yoga.DISPLAY_NONE'},
+
YGNodeCalculateLayout:{value:function(node, dir) {
this.push(node + '.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, ' + dir + ');');
}},
@@ -169,6 +172,10 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
this.push(nodeName + '.setDirection(' + toValueJavascript(value) + ');');
}},
+ YGNodeStyleSetDisplay:{value:function(nodeName, value) {
+ this.push(nodeName + '.setDisplay(' + toValueJavascript(value) + ');');
+ }},
+
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexBasis(' + toValueJavascript(value) + ');');
}},
diff --git a/gentest/gentest.js b/gentest/gentest.js
index b83f3bd4..98559988 100755
--- a/gentest/gentest.js
+++ b/gentest/gentest.js
@@ -140,6 +140,7 @@ function checkDefaultValues() {
{style:'top', value:'undefined'},
{style:'right', value:'undefined'},
{style:'bottom', value:'undefined'},
+ {style:'display', value:'flex'},
].forEach(function(item) {
assert(item.value === getDefaultStyleValue(item.style),
item.style + ' should be ' + item.value);
@@ -300,6 +301,9 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
case 'max-height':
e.YGNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style]));
break;
+ case 'display':
+ e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]))
+ break;
}
}
}
@@ -389,6 +393,13 @@ function pixelValue(e, value) {
}
}
+function displayValue(e, value){
+ switch(value){
+ case 'flex': return e.YGDisplayFlex;
+ case 'none': return e.YGDisplayNone;
+ }
+}
+
function getDefaultStyleValue(style) {
if (style == 'position') {
return 'relative';
@@ -466,6 +477,7 @@ function getYogaStyle(node) {
'height',
'min-height',
'max-height',
+ 'display',
].reduce(function(map, key) {
map[key] = node.style[key] || getComputedStyle(node, null).getPropertyValue(key);
return map;
diff --git a/java/com/facebook/yoga/YogaDisplay.java b/java/com/facebook/yoga/YogaDisplay.java
new file mode 100644
index 00000000..14e79967
--- /dev/null
+++ b/java/com/facebook/yoga/YogaDisplay.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+package com.facebook.yoga;
+
+import com.facebook.proguard.annotations.DoNotStrip;
+
+@DoNotStrip
+public enum YogaDisplay {
+ FLEX(0),
+ NONE(1);
+
+ private int mIntValue;
+
+ YogaDisplay(int intValue) {
+ mIntValue = intValue;
+ }
+
+ public int intValue() {
+ return mIntValue;
+ }
+
+ public static YogaDisplay fromInt(int value) {
+ switch (value) {
+ case 0: return FLEX;
+ case 1: return NONE;
+ default: throw new IllegalArgumentException("Unknown enum value: " + value);
+ }
+ }
+}
diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java
index 9ac26219..1bca0372 100644
--- a/java/com/facebook/yoga/YogaNode.java
+++ b/java/com/facebook/yoga/YogaNode.java
@@ -310,6 +310,18 @@ public class YogaNode implements YogaNodeAPI {
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
+ private native int jni_YGNodeStyleGetDisplay(long nativePointer);
+ @Override
+ public YogaDisplay getDisplay() {
+ return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
+ }
+
+ private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
+ @Override
+ public void setDisplay(YogaDisplay display) {
+ jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
+ }
+
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
@Override
public void setFlex(float flex) {
diff --git a/java/com/facebook/yoga/YogaNodeAPI.java b/java/com/facebook/yoga/YogaNodeAPI.java
index 2dcfa409..a2ca3200 100644
--- a/java/com/facebook/yoga/YogaNodeAPI.java
+++ b/java/com/facebook/yoga/YogaNodeAPI.java
@@ -87,6 +87,8 @@ public interface YogaNodeAPI {
YogaDirection getLayoutDirection();
YogaOverflow getOverflow();
void setOverflow(YogaOverflow overflow);
+ YogaDisplay getDisplay();
+ void setDisplay(YogaDisplay display);
void setData(Object data);
Object getData();
void reset();
diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp
index 88044a96..19a7210a 100644
--- a/java/jni/YGJNI.cpp
+++ b/java/jni/YGJNI.cpp
@@ -319,6 +319,7 @@ YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
+YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
void jni_YGNodeStyleSetFlex(alias_ref, jlong nativePointer, jfloat value) {
YGNodeStyleSetFlex(_jlong2YGNodeRef(nativePointer), static_cast(value));
@@ -378,6 +379,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap),
YGMakeNativeMethod(jni_YGNodeStyleGetOverflow),
YGMakeNativeMethod(jni_YGNodeStyleSetOverflow),
+ YGMakeNativeMethod(jni_YGNodeStyleGetDisplay),
+ YGMakeNativeMethod(jni_YGNodeStyleSetDisplay),
YGMakeNativeMethod(jni_YGNodeStyleSetFlex),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow),
diff --git a/java/tests/com/facebook/yoga/YGDisplayTest.java b/java/tests/com/facebook/yoga/YGDisplayTest.java
new file mode 100644
index 00000000..5620792b
--- /dev/null
+++ b/java/tests/com/facebook/yoga/YGDisplayTest.java
@@ -0,0 +1,325 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
+
+package com.facebook.yoga;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class YGDisplayTest {
+ @Test
+ public void test_display_none() {
+ final YogaNode root = new YogaNode();
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(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.setFlexGrow(1f);
+ root_child1.setDisplay(YogaDisplay.NONE);
+ root.addChildAt(root_child1, 1);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_display_none_fixed_size() {
+ final YogaNode root = new YogaNode();
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(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(20f);
+ root_child1.setHeight(20f);
+ root_child1.setDisplay(YogaDisplay.NONE);
+ root.addChildAt(root_child1, 1);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_display_none_with_margin() {
+ final YogaNode root = new YogaNode();
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setMargin(YogaEdge.LEFT, 10f);
+ root_child0.setMargin(YogaEdge.TOP, 10f);
+ root_child0.setMargin(YogaEdge.RIGHT, 10f);
+ root_child0.setMargin(YogaEdge.BOTTOM, 10f);
+ root_child0.setWidth(20f);
+ root_child0.setHeight(20f);
+ root_child0.setDisplay(YogaDisplay.NONE);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = new YogaNode();
+ root_child1.setFlexGrow(1f);
+ root.addChildAt(root_child1, 1);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_display_none_with_child() {
+ final YogaNode root = new YogaNode();
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setFlexGrow(1f);
+ root_child0.setFlexShrink(1f);
+ root_child0.setFlexBasisPercent(0f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = new YogaNode();
+ root_child1.setFlexGrow(1f);
+ root_child1.setFlexShrink(1f);
+ root_child1.setFlexBasisPercent(0f);
+ root_child1.setDisplay(YogaDisplay.NONE);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child1_child0 = new YogaNode();
+ root_child1_child0.setFlexGrow(1f);
+ root_child1_child0.setFlexShrink(1f);
+ root_child1_child0.setFlexBasisPercent(0f);
+ root_child1_child0.setWidth(20f);
+ root_child1_child0.setMinWidth(0f);
+ root_child1_child0.setMinHeight(0f);
+ root_child1.addChildAt(root_child1_child0, 0);
+
+ final YogaNode root_child2 = new YogaNode();
+ root_child2.setFlexGrow(1f);
+ root_child2.setFlexShrink(1f);
+ root_child2.setFlexBasisPercent(0f);
+ root.addChildAt(root_child2, 2);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(50f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_display_none_with_position() {
+ final YogaNode root = new YogaNode();
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(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.setFlexGrow(1f);
+ root_child1.setPosition(YogaEdge.TOP, 10f);
+ root_child1.setDisplay(YogaDisplay.NONE);
+ root.addChildAt(root_child1, 1);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+}
diff --git a/javascript/sources/Node.cc b/javascript/sources/Node.cc
index c673c239..65305218 100644
--- a/javascript/sources/Node.cc
+++ b/javascript/sources/Node.cc
@@ -124,6 +124,11 @@ void Node::setOverflow(int overflow)
YGNodeStyleSetOverflow(m_node, static_cast(overflow));
}
+void Node::setDisplay(int display)
+{
+ YGNodeStyleSetDisplay(m_node, static_cast(display));
+}
+
void Node::setFlex(double flex)
{
YGNodeStyleSetFlex(m_node, flex);
@@ -279,6 +284,11 @@ int Node::getOverflow(void) const
return YGNodeStyleGetOverflow(m_node);
}
+int Node::getDisplay(void) const
+{
+ return YGNodeStyleGetDisplay(m_node);
+}
+
Value Node::getFlexBasis(void) const
{
return Value::fromYGValue(YGNodeStyleGetFlexBasis(m_node));
diff --git a/javascript/sources/Node.hh b/javascript/sources/Node.hh
index c50b45d7..e861d8b3 100644
--- a/javascript/sources/Node.hh
+++ b/javascript/sources/Node.hh
@@ -67,6 +67,7 @@ class Node {
void setMarginPercent(int edge, double margin);
void setOverflow(int overflow);
+ void setDisplay(int display);
void setFlex(double flex);
void setFlexBasis(double flexBasis);
@@ -111,6 +112,7 @@ class Node {
Value getMargin(int edge) const;
int getOverflow(void) const;
+ int getDisplay(void) const;
Value getFlexBasis(void) const;
double getFlexGrow(void) const;
diff --git a/javascript/sources/YGEnums.js b/javascript/sources/YGEnums.js
index 6477789f..b48c7b7a 100644
--- a/javascript/sources/YGEnums.js
+++ b/javascript/sources/YGEnums.js
@@ -26,6 +26,10 @@ module.exports = {
DIRECTION_LTR: 1,
DIRECTION_RTL: 2,
+ DISPLAY_COUNT: 2,
+ DISPLAY_FLEX: 0,
+ DISPLAY_NONE: 1,
+
EDGE_COUNT: 9,
EDGE_LEFT: 0,
EDGE_TOP: 1,
diff --git a/javascript/sources/nbind.cc b/javascript/sources/nbind.cc
index e7b5ff5e..7e65c285 100644
--- a/javascript/sources/nbind.cc
+++ b/javascript/sources/nbind.cc
@@ -67,6 +67,7 @@ NBIND_CLASS(Node)
method(setMarginPercent);
method(setOverflow);
+ method(setDisplay);
method(setFlex);
method(setFlexBasis);
@@ -125,6 +126,9 @@ NBIND_CLASS(Node)
method(getBorder);
+ method(getOverflow);
+ method(getDisplay);
+
method(getPadding);
method(insertChild);
diff --git a/javascript/tests/Facebook.Yoga/YGDisplayTest.js b/javascript/tests/Facebook.Yoga/YGDisplayTest.js
new file mode 100644
index 00000000..faeb5fcb
--- /dev/null
+++ b/javascript/tests/Facebook.Yoga/YGDisplayTest.js
@@ -0,0 +1,329 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
+
+var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
+
+it("display_none", function () {
+ var root = Yoga.Node.create();
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setFlexGrow(1);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create();
+ root_child1.setFlexGrow(1);
+ root_child1.setDisplay(Yoga.DISPLAY_NONE);
+ root.insertChild(root_child1, 1);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("display_none_fixed_size", function () {
+ var root = Yoga.Node.create();
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setFlexGrow(1);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create();
+ root_child1.setWidth(20);
+ root_child1.setHeight(20);
+ root_child1.setDisplay(Yoga.DISPLAY_NONE);
+ root.insertChild(root_child1, 1);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("display_none_with_margin", function () {
+ var root = Yoga.Node.create();
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setMargin(Yoga.EDGE_LEFT, 10);
+ root_child0.setMargin(Yoga.EDGE_TOP, 10);
+ root_child0.setMargin(Yoga.EDGE_RIGHT, 10);
+ root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
+ root_child0.setWidth(20);
+ root_child0.setHeight(20);
+ root_child0.setDisplay(Yoga.DISPLAY_NONE);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create();
+ root_child1.setFlexGrow(1);
+ root.insertChild(root_child1, 1);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("display_none_with_child", function () {
+ var root = Yoga.Node.create();
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setFlexGrow(1);
+ root_child0.setFlexShrink(1);
+ root_child0.setFlexBasis("0%");
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create();
+ root_child1.setFlexGrow(1);
+ root_child1.setFlexShrink(1);
+ root_child1.setFlexBasis("0%");
+ root_child1.setDisplay(Yoga.DISPLAY_NONE);
+ root.insertChild(root_child1, 1);
+
+ var root_child1_child0 = Yoga.Node.create();
+ root_child1_child0.setFlexGrow(1);
+ root_child1_child0.setFlexShrink(1);
+ root_child1_child0.setFlexBasis("0%");
+ root_child1_child0.setWidth(20);
+ root_child1_child0.setMinWidth(0);
+ root_child1_child0.setMinHeight(0);
+ root_child1.insertChild(root_child1_child0, 0);
+
+ var root_child2 = Yoga.Node.create();
+ root_child2.setFlexGrow(1);
+ root_child2.setFlexShrink(1);
+ root_child2.setFlexBasis("0%");
+ root.insertChild(root_child2, 2);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
+ console.assert(0 === root_child1_child0.getComputedWidth(), "0 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
+ console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
+
+ console.assert(50 === root_child2.getComputedLeft(), "50 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
+ console.assert(0 === root_child1_child0.getComputedWidth(), "0 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
+ console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("display_none_with_position", function () {
+ var root = Yoga.Node.create();
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setFlexGrow(1);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create();
+ root_child1.setFlexGrow(1);
+ root_child1.setPosition(Yoga.EDGE_TOP, 10);
+ root_child1.setDisplay(Yoga.DISPLAY_NONE);
+ root.insertChild(root_child1, 1);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
diff --git a/tests/YGDisplayTest.cpp b/tests/YGDisplayTest.cpp
new file mode 100644
index 00000000..651dfa82
--- /dev/null
+++ b/tests/YGDisplayTest.cpp
@@ -0,0 +1,314 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
+
+#include
+#include
+
+TEST(YogaTest, display_none) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child1, 1);
+ YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
+ 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, display_none_fixed_size) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(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, 20);
+ YGNodeStyleSetHeight(root_child1, 20);
+ YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
+ 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, display_none_with_margin) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
+ YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
+ YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
+ YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
+ YGNodeStyleSetWidth(root_child0, 20);
+ YGNodeStyleSetHeight(root_child0, 20);
+ YGNodeStyleSetDisplay(root_child0, YGDisplayNone);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child1, 1);
+ 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(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, 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(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, display_none_with_child) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetFlexShrink(root_child0, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child0, 0);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child1, 1);
+ YGNodeStyleSetFlexShrink(root_child1, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child1, 0);
+ YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ const YGNodeRef root_child1_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child1_child0, 1);
+ YGNodeStyleSetFlexShrink(root_child1_child0, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child1_child0, 0);
+ YGNodeStyleSetWidth(root_child1_child0, 20);
+ YGNodeStyleSetMinWidth(root_child1_child0, 0);
+ YGNodeStyleSetMinHeight(root_child1_child0, 0);
+ YGNodeInsertChild(root_child1, root_child1_child0, 0);
+
+ const YGNodeRef root_child2 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child2, 1);
+ YGNodeStyleSetFlexShrink(root_child2, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child2, 0);
+ YGNodeInsertChild(root, root_child2, 2);
+ 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(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0));
+
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
+
+ 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(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, display_none_with_position) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child1, 1);
+ YGNodeStyleSetPosition(root_child1, YGEdgeTop, 10);
+ YGNodeStyleSetDisplay(root_child1, YGDisplayNone);
+ 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+}
diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h
index afc44513..3e65e103 100644
--- a/yoga/YGEnums.h
+++ b/yoga/YGEnums.h
@@ -36,6 +36,12 @@ typedef YG_ENUM_BEGIN(YGDirection) {
YGDirectionRTL,
} YG_ENUM_END(YGDirection);
+#define YGDisplayCount 2
+typedef YG_ENUM_BEGIN(YGDisplay) {
+ YGDisplayFlex,
+ YGDisplayNone,
+} YG_ENUM_END(YGDisplay);
+
#define YGEdgeCount 9
typedef YG_ENUM_BEGIN(YGEdge) {
YGEdgeLeft,
diff --git a/yoga/Yoga.c b/yoga/Yoga.c
index cb71ed99..4073d102 100644
--- a/yoga/Yoga.c
+++ b/yoga/Yoga.c
@@ -77,6 +77,7 @@ typedef struct YGStyle {
YGPositionType positionType;
YGWrap flexWrap;
YGOverflow overflow;
+ YGDisplay display;
float flex;
float flexGrow;
float flexShrink;
@@ -148,6 +149,7 @@ static YGNode gYGNodeDefaults = {
.direction = YGDirectionInherit,
.flexDirection = YGFlexDirectionColumn,
.overflow = YGOverflowVisible,
+ .display = YGDisplayFlex,
.dimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT,
.minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT,
.maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT,
@@ -572,6 +574,7 @@ YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignSelf, alignSelf, alignSelf);
YG_NODE_STYLE_PROPERTY_IMPL(YGPositionType, PositionType, positionType, positionType);
YG_NODE_STYLE_PROPERTY_IMPL(YGWrap, FlexWrap, flexWrap, flexWrap);
YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow);
+YG_NODE_STYLE_PROPERTY_IMPL(YGDisplay, Display, display, display);
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink);
@@ -1656,6 +1659,19 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node,
return false;
}
+static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
+ node->layout.dimensions[YGDimensionHeight] = 0;
+ node->layout.dimensions[YGDimensionWidth] = 0;
+ node->layout.position[YGEdgeTop] = 0;
+ node->layout.position[YGEdgeBottom] = 0;
+ node->layout.position[YGEdgeLeft] = 0;
+ node->layout.position[YGEdgeRight] = 0;
+ for (uint32_t i = 0; i < YGNodeGetChildCount(node); i++) {
+ const YGNodeRef child = YGNodeListGet(node->children, i);
+ YGZeroOutLayoutRecursivly(child);
+ }
+}
+
//
// This is the main routine that implements a subset of the flexbox layout
// algorithm
@@ -1925,7 +1941,12 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
-
+ if (child->style.display == YGDisplayNone) {
+ YGZeroOutLayoutRecursivly(child);
+ child->hasNewLayout = true;
+ child->isDirty = false;
+ continue;
+ }
if (performLayout) {
// Set the initial position (relative to the parent).
const YGDirection childDirection = YGNodeResolveDirection(child, direction);
@@ -2005,6 +2026,9 @@ static void YGNodelayoutImpl(const YGNodeRef 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 YGNodeRef child = YGNodeListGet(node->children, i);
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
child->lineIndex = lineCount;
if (child->style.positionType != YGPositionTypeAbsolute) {
@@ -2406,7 +2430,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
-
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
if (child->style.positionType == YGPositionTypeAbsolute &&
YGNodeIsLeadingPosDefined(child, mainAxis)) {
if (performLayout) {
@@ -2487,7 +2513,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (performLayout) {
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
-
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
if (child->style.positionType == YGPositionTypeAbsolute) {
// If the child is absolutely positioned and has a
// top/left/bottom/right
@@ -2640,7 +2668,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
float maxDescentForCurrentLine = 0;
for (ii = startIndex; ii < childCount; ii++) {
const YGNodeRef child = YGNodeListGet(node->children, ii);
-
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
if (child->style.positionType == YGPositionTypeRelative) {
if (child->lineIndex != i) {
break;
@@ -2669,7 +2699,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (performLayout) {
for (ii = startIndex; ii < endIndex; ii++) {
const YGNodeRef child = YGNodeListGet(node->children, ii);
-
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
if (child->style.positionType == YGPositionTypeRelative) {
switch (YGNodeAlignItem(node, child)) {
case YGAlignFlexStart: {
@@ -2779,7 +2811,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (needsMainTrailingPos || needsCrossTrailingPos) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeListGet(node->children, i);
-
+ if (child->style.display == YGDisplayNone) {
+ continue;
+ }
if (needsMainTrailingPos) {
YGNodeSetChildTrailingPosition(node, child, mainAxis);
}
diff --git a/yoga/Yoga.h b/yoga/Yoga.h
index ab6a2f89..bf9bd3e8 100644
--- a/yoga/Yoga.h
+++ b/yoga/Yoga.h
@@ -157,6 +157,7 @@ YG_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
+YG_NODE_STYLE_PROPERTY(YGDisplay, Display, display);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);