From 6a6efe07649cdea4995a78ab4d12520ab6286fe6 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Wed, 9 Nov 2016 09:10:54 -0800 Subject: [PATCH] change default value of position styles Summary: Default value for positions should be undefined not 0px. Fixing this leads to more correct tests. Reviewed By: gkassabli Differential Revision: D4153329 fbshipit-source-id: d0f194f9c47eac93d3815ec7e55568a1016bc7fe --- .../CSSLayoutAbsolutePositionTest.cs | 4 +++- .../fixtures/CSSLayoutAbsolutePositionTest.html | 2 +- gentest/gentest.js | 17 +++++++++++++---- .../CSSLayoutAbsolutePositionTest.java | 4 +++- tests/CSSLayoutAbsolutePositionTest.cpp | 4 +++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs index c9ae2bb6..b5ee81a3 100644 --- a/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.CSSLayout/CSSLayoutAbsolutePositionTest.cs @@ -27,7 +27,7 @@
-
+
@@ -219,6 +219,8 @@ namespace Facebook.CSSLayout CSSNode root_child0 = new CSSNode(); root_child0.PositionType = CSSPositionType.Absolute; + root_child0.SetPosition(CSSEdge.Start, 0); + root_child0.SetPosition(CSSEdge.Top, 0); root.Insert(0, root_child0); CSSNode root_child0_child0 = new CSSNode(); diff --git a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html index bb6e5673..37ebffe8 100644 --- a/gentest/fixtures/CSSLayoutAbsolutePositionTest.html +++ b/gentest/fixtures/CSSLayoutAbsolutePositionTest.html @@ -15,7 +15,7 @@
-
+
diff --git a/gentest/gentest.js b/gentest/gentest.js index a680a9d0..07fef381 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -159,10 +159,10 @@ function checkDefaultValues() { {style:'overflow', value:'visible'}, {style:'flex-grow', value:'0'}, {style:'flex-shrink', value:'0'}, - {style:'left', value:'0px'}, - {style:'top', value:'0px'}, - {style:'right', value:'0px'}, - {style:'bottom', value:'0px'}, + {style:'left', value:'undefined'}, + {style:'top', value:'undefined'}, + {style:'right', value:'undefined'}, + {style:'bottom', value:'undefined'}, ].forEach(function(item) { assert(item.value === getDefaultStyleValue(item.style), item.style + ' should be ' + item.value); @@ -415,6 +415,15 @@ function getDefaultStyleValue(style) { if (style == 'position') { return 'relative'; } + switch (style) { + case 'left': + case 'top': + case 'right': + case 'bottom': + case 'start': + case 'end': + return 'undefined'; + } var node = document.getElementById('default'); return getComputedStyle(node, null).getPropertyValue(style); } diff --git a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java index c64be24e..f3703e70 100644 --- a/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java +++ b/java/tests/com/facebook/csslayout/CSSLayoutAbsolutePositionTest.java @@ -27,7 +27,7 @@
-
+
@@ -213,6 +213,8 @@ public class CSSLayoutAbsolutePositionTest { final CSSNode root_child0 = new CSSNode(); root_child0.setPositionType(CSSPositionType.ABSOLUTE); + root_child0.setPosition(Spacing.START, 0); + root_child0.setPosition(Spacing.TOP, 0); root.addChildAt(root_child0, 0); final CSSNode root_child0_child0 = new CSSNode(); diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index d817b6ff..92fd8f0f 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -27,7 +27,7 @@
-
+
@@ -204,6 +204,8 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); + CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 0); + CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0); CSSNodeInsertChild(root, root_child0, 0); const CSSNodeRef root_child0_child0 = CSSNodeNew();