Normalized C and Java definition of isDimDefined.

The JavaScript implementation of isDimDefined contains a check to ensure
that the dimension value is positive; the C and Java versions did not
have this check. As a result, a negative style value for 'width' (such
as that used by the "should layout node with negative width" test) would
have different layout under the C/Java implementation to the JavaScript
implementation.

This was hidden because the C/Java transpilers filtered out any negative
instantiation values from the test suite. In effect, the negative value
tests weren't running on the C/Java implementation.

This patch removes the negative value filter from the transpiler, and
makes the isDimDefined definition consistent between the three
implementations.
This commit is contained in:
Russell Keith-Magee
2015-03-22 14:36:16 +08:00
parent f5850b56e5
commit 8f6a96adbc
5 changed files with 29 additions and 25 deletions

View File

@@ -116,7 +116,8 @@ public class LayoutEngine {
}
private static boolean isDimDefined(CSSNode node, CSSFlexDirection axis) {
return !CSSConstants.isUndefined(getStyleDimension(node, getDim(axis)));
float value = getStyleDimension(node, getDim(axis));
return !CSSConstants.isUndefined(value) && value > 0.0;
}
private static boolean isPosDefined(CSSNode node, PositionIndex position) {

View File

@@ -2603,6 +2603,7 @@ public class LayoutEngineTest {
TestCSSNode root_node = new TestCSSNode();
{
TestCSSNode node_0 = root_node;
node_0.style.width = -31;
addChildren(node_0, 1);
{
TestCSSNode node_1;
@@ -3341,6 +3342,7 @@ public class LayoutEngineTest {
TestCSSNode node_1;
node_1 = node_0.getChildAt(0);
node_1.style.alignSelf = CSSAlign.FLEX_START;
node_1.style.flex = -2.5f;
node_1 = node_0.getChildAt(1);
node_1.style.alignSelf = CSSAlign.FLEX_START;
node_1.style.flex = 0;