From 06c708053f9dd7f63f001ff32ede0dd0f8bf3a54 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 4 Sep 2015 13:50:28 +0100 Subject: [PATCH 01/11] Change Java to use array indexes instead of methods Method invocations are not entirely free on Android. Change the generated Java code to use the same array-based approach used in JS and C to compute dimensions, positions, etc instead of relying too heavily on method invovations. As a bonus, the Java transpiler becomes a lot simpler because the code is more analogous to the C counterpart. In my local benchmarks this change gives us a major performance boost on Android (between 15% and 30%) depending on the device and the runtime (Dalvik|Art). --- src/JavaTranspiler.js | 66 +- src/Layout.js | 8 +- .../src/com/facebook/csslayout/CSSLayout.java | 47 +- .../src/com/facebook/csslayout/CSSNode.java | 43 +- .../src/com/facebook/csslayout/CSSStyle.java | 16 +- .../com/facebook/csslayout/LayoutEngine.java | 639 +-- .../facebook/csslayout/LayoutEngineTest.java | 4853 +++++++++-------- src/transpile.js | 1 + 8 files changed, 2752 insertions(+), 2921 deletions(-) diff --git a/src/JavaTranspiler.js b/src/JavaTranspiler.js index 455b826d..1c888bc5 100644 --- a/src/JavaTranspiler.js +++ b/src/JavaTranspiler.js @@ -10,54 +10,42 @@ function __transpileToJavaCommon(code) { return code .replace(/CSS_UNDEFINED/g, 'CSSConstants.UNDEFINED') + .replace(/CSS_JUSTIFY_/g, 'CSSJustify.') + .replace(/CSS_ALIGN_/g, 'CSSAlign.') .replace(/css_flex_direction_t/g, 'CSSFlexDirection') .replace(/css_direction_t/g, 'CSSDirection') - .replace(/CSS_DIRECTION_/g, 'CSSDirection.') - .replace(/CSS_FLEX_DIRECTION_/g, 'CSSFlexDirection.') .replace(/css_align_t/g, 'CSSAlign') - .replace(/CSS_ALIGN_/g, 'CSSAlign.') - .replace(/CSS_WRAP/g, 'CSSWrap.WRAP') - .replace(/CSS_POSITION_/g, 'CSSPositionType.') .replace(/css_justify_t/g, 'CSSJustify') - .replace(/CSS_JUSTIFY_/g, 'CSSJustify.') .replace(/css_dim_t/g, 'MeasureOutput') .replace(/bool/g, 'boolean') - .replace(/^(\s+)([^\s]+)\s+\+=/gm, '$1$2 = $2 +') // Expand += - .replace(/leading\[([^\]]+)\]/g, 'getLeading($1)') - .replace(/trailing\[([^\]]+)\]/g, 'getTrailing($1)') - .replace(/pos\[([^\]]+)\]/g, 'getPos($1)') - .replace(/dim\[([^\]]+)\]/g, 'getDim($1)') - .replace(/isUndefined/g, 'CSSConstants.isUndefined') + .replace(/style\[dim/g, 'style.dimensions[dim') + .replace(/(style|layout)\.width/g, '$1.dimensions[DIMENSION_WIDTH]') + .replace(/(style|layout)\.height/g, '$1.dimensions[DIMENSION_HEIGHT]') + .replace(/layout\[dim/g, 'layout.dimensions[dim') + .replace(/layout\[pos/g, 'layout.position[pos') + .replace(/layout\[leading/g, 'layout.position[leading') + .replace(/layout\[trailing/g, 'layout.position[trailing') + .replace(/\/\*\(c\)!([^*]+)\*\//g, '') + .replace(/var\/\*\(java\)!([^*]+)\*\//g, '$1') .replace(/\/\*\(java\)!([^*]+)\*\//g, '$1') - - // Since Java doesn't store its attributes in arrays, we need to use setters/getters to access - // the appropriate layout/style fields - .replace( - /(\w+)\.layout\[((?:getLeading|getPos)\([^\)]+\))\]\s+=\s+([^;]+);/gm, - 'setLayoutPosition($1, $2, $3);') - .replace( - /(\w+)\.layout\[((?:getTrailing|getPos)\([^\)]+\))\]\s+=\s+([^;]+);/gm, - 'setLayoutPosition($1, $2, $3);') - .replace( - /(\w+)\.layout\.direction\s+=\s+([^;]+);/gm, - 'setLayoutDirection($1, $2);') - .replace(/(\w+)\.layout\[((?:getLeading|getPos)\([^\]]+\))\]/g, 'getLayoutPosition($1, $2)') - .replace(/(\w+)\.layout\[((?:getTrailing|getPos)\([^\]]+\))\]/g, 'getLayoutPosition($1, $2)') - .replace( - /(\w+)\.layout\[(getDim\([^\)]+\))\]\s+=\s+([^;]+);/gm, - 'setLayoutDimension($1, $2, $3);') - .replace(/(\w+)\.layout\[(getDim\([^\]]+\))\]/g, 'getLayoutDimension($1, $2)') - .replace(/(\w+)\.style\[((?:getLeading|getPos)\([^\]]+\))\]/g, 'getStylePosition($1, $2)') - .replace(/(\w+)\.style\[(getDim\([^\]]+\))\]/g, 'getStyleDimension($1, $2)'); } function __transpileSingleTestToJava(code) { return __transpileToJavaCommon(code) + .replace(/CSS_DIRECTION_/g, 'CSSDirection.') + .replace(/CSS_FLEX_DIRECTION_/g, 'CSSFlexDirection.') + .replace(/CSS_WRAP/g, 'CSSWrap.WRAP') + .replace(/CSS_POSITION_/g, 'CSSPositionType.') .replace(/new_test_css_node/g, 'new TestCSSNode') - .replace( // style.dimensions[CSS_WIDTH] => style.width + .replace( // style.position[CSS_TOP] => style.position[CSSLayout.POSITION_TOP] + /(style|layout)\.position\[CSS_(LEFT|TOP|RIGHT|BOTTOM)\]/g, + function (str, match1, match2) { + return match1 + '.position[POSITION_' + match2 + ']'; + }) + .replace( // style.dimensions[CSS_WIDTH] => style.dimensions[CSSLayout.DIMENSION_WIDTH] /(style|layout)\.dimensions\[CSS_(WIDTH|HEIGHT)\]/g, function (str, match1, match2) { - return match1 + '.' + match2.toLowerCase(); + return match1 + '.dimensions[DIMENSION_' + match2 + ']'; }) .replace( // style.maxDimensions[CSS_WIDTH] => style.maxWidth /(style|layout)\.maxDimensions\[CSS_(WIDTH|HEIGHT)\]/g, @@ -69,16 +57,6 @@ function __transpileSingleTestToJava(code) { function (str, match1, match2) { return match1 + '.min' + match2.substr(0, 1).toUpperCase() + match2.substr(1).toLowerCase(); }) - .replace( // layout.position[CSS_TOP] => layout.y - /layout\.position\[CSS_(TOP|LEFT)\]/g, - function (str, match1) { - return 'layout.' + (match1 === 'TOP' ? 'top' : 'left'); - }) - .replace( // style.position[CSS_TOP] => style.positionTop - /style\.(position)\[CSS_(TOP|BOTTOM|LEFT|RIGHT)\]/g, - function (str, match1, match2) { - return 'style.' + match1 + match2[0] + match2.substring(1).toLowerCase(); - }) .replace( // style.margin[CSS_TOP] = 12.3 => style.margin[Spacing.TOP].set(12.3) /style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT|START|END)\]\s+=\s+(-?[\.\d]+)/g, function (str, match1, match2, match3) { diff --git a/src/Layout.js b/src/Layout.js index a70e205e..bb9eeb9b 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -391,9 +391,9 @@ var computeLayout = (function() { function layoutNode(node, parentMaxWidth, /*css_direction_t*/parentDirection) { var/*css_direction_t*/ direction = resolveDirection(node, parentDirection); - var/*css_flex_direction_t*/ mainAxis = resolveAxis(getFlexDirection(node), direction); - var/*css_flex_direction_t*/ crossAxis = getCrossFlexDirection(mainAxis, direction); - var/*css_flex_direction_t*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction); + var/*(c)!css_flex_direction_t*//*(java)!int*/ mainAxis = resolveAxis(getFlexDirection(node), direction); + var/*(c)!css_flex_direction_t*//*(java)!int*/ crossAxis = getCrossFlexDirection(mainAxis, direction); + var/*(c)!css_flex_direction_t*//*(java)!int*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction); // Handle width and height style attributes setDimensionFromStyle(node, mainAxis); @@ -457,7 +457,7 @@ var computeLayout = (function() { var/*int*/ i; var/*int*/ ii; var/*css_node_t**/ child; - var/*css_flex_direction_t*/ axis; + var/*(c)!css_flex_direction_t*//*(java)!int*/ axis; // Pre-fill some dimensions straight from the parent for (i = 0; i < node.children.length; ++i) { diff --git a/src/java/src/com/facebook/csslayout/CSSLayout.java b/src/java/src/com/facebook/csslayout/CSSLayout.java index 6b457183..e5fafb17 100644 --- a/src/java/src/com/facebook/csslayout/CSSLayout.java +++ b/src/java/src/com/facebook/csslayout/CSSLayout.java @@ -8,49 +8,50 @@ */ package com.facebook.csslayout; +import java.util.Arrays; + /** * Where the output of {@link LayoutEngine#layoutNode(CSSNode, float)} will go in the CSSNode. */ public class CSSLayout { + static final int POSITION_LEFT = 0; + static final int POSITION_TOP = 1; + static final int POSITION_RIGHT = 2; + static final int POSITION_BOTTOM = 3; - public float top; - public float left; - public float right; - public float bottom; - public float width = CSSConstants.UNDEFINED; - public float height = CSSConstants.UNDEFINED; - public CSSDirection direction = CSSDirection.LTR; + static final int DIMENSION_WIDTH = 0; + static final int DIMENSION_HEIGHT = 1; + + float[] position = new float[4]; + float[] dimensions = new float[2]; + CSSDirection direction = CSSDirection.LTR; /** * This should always get called before calling {@link LayoutEngine#layoutNode(CSSNode, float)} */ public void resetResult() { - left = 0; - top = 0; - right = 0; - bottom = 0; - width = CSSConstants.UNDEFINED; - height = CSSConstants.UNDEFINED; + Arrays.fill(position, 0); + Arrays.fill(dimensions, CSSConstants.UNDEFINED); direction = CSSDirection.LTR; } public void copy(CSSLayout layout) { - left = layout.left; - top = layout.top; - right = layout.right; - bottom = layout.bottom; - width = layout.width; - height = layout.height; + position[POSITION_LEFT] = layout.position[POSITION_LEFT]; + position[POSITION_TOP] = layout.position[POSITION_TOP]; + position[POSITION_RIGHT] = layout.position[POSITION_RIGHT]; + position[POSITION_BOTTOM] = layout.position[POSITION_BOTTOM]; + dimensions[DIMENSION_WIDTH] = layout.dimensions[DIMENSION_WIDTH]; + dimensions[DIMENSION_HEIGHT] = layout.dimensions[DIMENSION_HEIGHT]; direction = layout.direction; } @Override public String toString() { return "layout: {" + - "left: " + left + ", " + - "top: " + top + ", " + - "width: " + width + ", " + - "height: " + height + ", " + + "left: " + position[POSITION_LEFT] + ", " + + "top: " + position[POSITION_TOP] + ", " + + "width: " + dimensions[DIMENSION_WIDTH] + ", " + + "height: " + dimensions[DIMENSION_HEIGHT] + ", " + "direction: " + direction + "}"; } diff --git a/src/java/src/com/facebook/csslayout/CSSNode.java b/src/java/src/com/facebook/csslayout/CSSNode.java index 064ec193..91d7ed83 100644 --- a/src/java/src/com/facebook/csslayout/CSSNode.java +++ b/src/java/src/com/facebook/csslayout/CSSNode.java @@ -14,6 +14,13 @@ import java.util.ArrayList; import com.facebook.infer.annotation.Assertions; +import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT; +import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH; +import static com.facebook.csslayout.CSSLayout.POSITION_BOTTOM; +import static com.facebook.csslayout.CSSLayout.POSITION_LEFT; +import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT; +import static com.facebook.csslayout.CSSLayout.POSITION_TOP; + /** * A CSS Node. It has a style object you can manipulate at {@link #style}. After calling * {@link #calculateLayout()}, {@link #layout} will be filled with the results of the layout. @@ -293,61 +300,61 @@ public class CSSNode { } public void setPositionTop(float positionTop) { - if (!valuesEqual(style.positionTop, positionTop)) { - style.positionTop = positionTop; + if (!valuesEqual(style.position[POSITION_TOP], positionTop)) { + style.position[POSITION_TOP] = positionTop; dirty(); } } public void setPositionBottom(float positionBottom) { - if (!valuesEqual(style.positionBottom, positionBottom)) { - style.positionBottom = positionBottom; + if (!valuesEqual(style.position[POSITION_BOTTOM], positionBottom)) { + style.position[POSITION_BOTTOM] = positionBottom; dirty(); } } public void setPositionLeft(float positionLeft) { - if (!valuesEqual(style.positionLeft, positionLeft)) { - style.positionLeft = positionLeft; + if (!valuesEqual(style.position[POSITION_LEFT], positionLeft)) { + style.position[POSITION_LEFT] = positionLeft; dirty(); } } public void setPositionRight(float positionRight) { - if (!valuesEqual(style.positionRight, positionRight)) { - style.positionRight = positionRight; + if (!valuesEqual(style.position[POSITION_RIGHT], positionRight)) { + style.position[POSITION_RIGHT] = positionRight; dirty(); } } public void setStyleWidth(float width) { - if (!valuesEqual(style.width, width)) { - style.width = width; + if (!valuesEqual(style.dimensions[DIMENSION_WIDTH], width)) { + style.dimensions[DIMENSION_WIDTH] = width; dirty(); } } public void setStyleHeight(float height) { - if (!valuesEqual(style.height, height)) { - style.height = height; + if (!valuesEqual(style.dimensions[DIMENSION_HEIGHT], height)) { + style.dimensions[DIMENSION_HEIGHT] = height; dirty(); } } public float getLayoutX() { - return layout.left; + return layout.position[POSITION_LEFT]; } public float getLayoutY() { - return layout.top; + return layout.position[POSITION_TOP]; } public float getLayoutWidth() { - return layout.width; + return layout.dimensions[DIMENSION_WIDTH]; } public float getLayoutHeight() { - return layout.height; + return layout.dimensions[DIMENSION_HEIGHT]; } public CSSDirection getLayoutDirection() { @@ -365,14 +372,14 @@ public class CSSNode { * Get this node's width, as defined in the style. */ public float getStyleWidth() { - return style.width; + return style.dimensions[DIMENSION_WIDTH]; } /** * Get this node's height, as defined in the style. */ public float getStyleHeight() { - return style.height; + return style.dimensions[DIMENSION_HEIGHT]; } /** diff --git a/src/java/src/com/facebook/csslayout/CSSStyle.java b/src/java/src/com/facebook/csslayout/CSSStyle.java index 15b10a5b..4b361fb8 100644 --- a/src/java/src/com/facebook/csslayout/CSSStyle.java +++ b/src/java/src/com/facebook/csslayout/CSSStyle.java @@ -27,13 +27,17 @@ public class CSSStyle { public Spacing padding = new Spacing(); public Spacing border = new Spacing(); - public float positionTop = CSSConstants.UNDEFINED; - public float positionBottom = CSSConstants.UNDEFINED; - public float positionLeft = CSSConstants.UNDEFINED; - public float positionRight = CSSConstants.UNDEFINED; + public float[] position = { + CSSConstants.UNDEFINED, + CSSConstants.UNDEFINED, + CSSConstants.UNDEFINED, + CSSConstants.UNDEFINED, + }; - public float width = CSSConstants.UNDEFINED; - public float height = CSSConstants.UNDEFINED; + public float[] dimensions = { + CSSConstants.UNDEFINED, + CSSConstants.UNDEFINED, + }; public float minWidth = CSSConstants.UNDEFINED; public float minHeight = CSSConstants.UNDEFINED; diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index f0da1921..2b8a5ed8 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -8,329 +8,160 @@ */ package com.facebook.csslayout; +import static com.facebook.csslayout.CSSConstants.isUndefined; +import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT; +import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH; +import static com.facebook.csslayout.CSSLayout.POSITION_BOTTOM; +import static com.facebook.csslayout.CSSLayout.POSITION_LEFT; +import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT; +import static com.facebook.csslayout.CSSLayout.POSITION_TOP; + /** * Calculates layouts based on CSS style. See {@link #layoutNode(CSSNode, float)}. */ public class LayoutEngine { - private static enum PositionIndex { - TOP, - LEFT, - BOTTOM, - RIGHT, - START, - END, + private static final int CSS_FLEX_DIRECTION_COLUMN = + CSSFlexDirection.COLUMN.ordinal(); + private static final int CSS_FLEX_DIRECTION_COLUMN_REVERSE = + CSSFlexDirection.COLUMN_REVERSE.ordinal(); + private static final int CSS_FLEX_DIRECTION_ROW = + CSSFlexDirection.ROW.ordinal(); + private static final int CSS_FLEX_DIRECTION_ROW_REVERSE = + CSSFlexDirection.ROW_REVERSE.ordinal(); + + private static final int CSS_POSITION_RELATIVE = CSSPositionType.RELATIVE.ordinal(); + private static final int CSS_POSITION_ABSOLUTE = CSSPositionType.ABSOLUTE.ordinal(); + + private static final int[] leading = { + POSITION_TOP, + POSITION_BOTTOM, + POSITION_LEFT, + POSITION_RIGHT, + }; + + private static final int[] trailing = { + POSITION_BOTTOM, + POSITION_TOP, + POSITION_RIGHT, + POSITION_LEFT, + }; + + private static final int[] pos = { + POSITION_TOP, + POSITION_BOTTOM, + POSITION_LEFT, + POSITION_RIGHT, + }; + + private static final int[] dim = { + DIMENSION_HEIGHT, + DIMENSION_HEIGHT, + DIMENSION_WIDTH, + DIMENSION_WIDTH, + }; + + private static boolean isDimDefined(CSSNode node, int axis) { + float value = node.style.dimensions[dim[axis]]; + return !isUndefined(value) && value > 0.0; } - private static enum DimensionIndex { - WIDTH, - HEIGHT, + private static boolean isPosDefined(CSSNode node, int position) { + return !isUndefined(node.style.position[position]); } - private static void setLayoutPosition(CSSNode node, PositionIndex position, float value) { - switch (position) { - case TOP: - node.layout.top = value; - break; - case LEFT: - node.layout.left = value; - break; - case RIGHT: - node.layout.right = value; - break; - case BOTTOM: - node.layout.bottom = value; - break; - default: - throw new RuntimeException("Didn't get TOP, LEFT, RIGHT, or BOTTOM!"); - } + private static float getPosition(CSSNode node, int position) { + float result = node.style.position[position]; + return isUndefined(result) ? 0 : result; } - private static float getLayoutPosition(CSSNode node, PositionIndex position) { - switch (position) { - case TOP: - return node.layout.top; - case LEFT: - return node.layout.left; - case RIGHT: - return node.layout.right; - case BOTTOM: - return node.layout.bottom; - default: - throw new RuntimeException("Didn't get TOP, LEFT, RIGHT, or BOTTOM!"); - } - } - - private static void setLayoutDimension(CSSNode node, DimensionIndex dimension, float value) { - switch (dimension) { - case WIDTH: - node.layout.width = value; - break; - case HEIGHT: - node.layout.height = value; - break; - default: - throw new RuntimeException("Someone added a third dimension..."); - } - } - - private static float getLayoutDimension(CSSNode node, DimensionIndex dimension) { - switch (dimension) { - case WIDTH: - return node.layout.width; - case HEIGHT: - return node.layout.height; - default: - throw new RuntimeException("Someone added a third dimension..."); - } - } - - private static void setLayoutDirection(CSSNode node, CSSDirection direction) { - node.layout.direction = direction; - } - - private static float getStylePosition(CSSNode node, PositionIndex position) { - switch (position) { - case TOP: - return node.style.positionTop; - case BOTTOM: - return node.style.positionBottom; - case LEFT: - return node.style.positionLeft; - case RIGHT: - return node.style.positionRight; - default: - throw new RuntimeException("Someone added a new cardinal direction..."); - } - } - - private static float getStyleDimension(CSSNode node, DimensionIndex dimension) { - switch (dimension) { - case WIDTH: - return node.style.width; - case HEIGHT: - return node.style.height; - default: - throw new RuntimeException("Someone added a third dimension..."); - } - } - - private static PositionIndex getLeading(CSSFlexDirection axis) { - switch (axis) { - case COLUMN: - return PositionIndex.TOP; - case COLUMN_REVERSE: - return PositionIndex.BOTTOM; - case ROW: - return PositionIndex.LEFT; - case ROW_REVERSE: - return PositionIndex.RIGHT; - default: - throw new RuntimeException("Didn't get TOP, LEFT, RIGHT, or BOTTOM!"); - } - } - - private static PositionIndex getTrailing(CSSFlexDirection axis) { - switch (axis) { - case COLUMN: - return PositionIndex.BOTTOM; - case COLUMN_REVERSE: - return PositionIndex.TOP; - case ROW: - return PositionIndex.RIGHT; - case ROW_REVERSE: - return PositionIndex.LEFT; - default: - throw new RuntimeException("Didn't get COLUMN, COLUMN_REVERSE, ROW, or ROW_REVERSE!"); - } - } - - private static PositionIndex getPos(CSSFlexDirection axis) { - switch (axis) { - case COLUMN: - return PositionIndex.TOP; - case COLUMN_REVERSE: - return PositionIndex.BOTTOM; - case ROW: - return PositionIndex.LEFT; - case ROW_REVERSE: - return PositionIndex.RIGHT; - default: - throw new RuntimeException("Didn't get COLUMN, COLUMN_REVERSE, ROW, or ROW_REVERSE!"); - } - } - - private static DimensionIndex getDim(CSSFlexDirection axis) { - switch (axis) { - case COLUMN: - case COLUMN_REVERSE: - return DimensionIndex.HEIGHT; - case ROW: - case ROW_REVERSE: - return DimensionIndex.WIDTH; - default: - throw new RuntimeException("Didn't get COLUMN, COLUMN_REVERSE, ROW, or ROW_REVERSE!"); - } - } - - private static boolean isDimDefined(CSSNode node, CSSFlexDirection axis) { - float value = getStyleDimension(node, getDim(axis)); - return !CSSConstants.isUndefined(value) && value > 0.0; - } - - private static boolean isPosDefined(CSSNode node, PositionIndex position) { - return !CSSConstants.isUndefined(getStylePosition(node, position)); - } - - private static float getPosition(CSSNode node, PositionIndex position) { - float result = getStylePosition(node, position); - return CSSConstants.isUndefined(result) ? 0 : result; - } - - private static float getMargin(CSSNode node, PositionIndex position) { - switch (position) { - case TOP: - return node.style.margin.get(Spacing.TOP); - case BOTTOM: - return node.style.margin.get(Spacing.BOTTOM); - case LEFT: - return node.style.margin.get(Spacing.LEFT); - case RIGHT: - return node.style.margin.get(Spacing.RIGHT); - case START: - return node.style.margin.get(Spacing.START); - case END: - return node.style.margin.get(Spacing.END); - default: - throw new RuntimeException("Someone added a new cardinal direction..."); - } - } - - private static float getLeadingMargin(CSSNode node, CSSFlexDirection axis) { + private static float getLeadingMargin(CSSNode node, int axis) { if (isRowDirection(axis)) { float leadingMargin = node.style.margin.getRaw(Spacing.START); - if (!CSSConstants.isUndefined(leadingMargin)) { + if (!isUndefined(leadingMargin)) { return leadingMargin; } } - return getMargin(node, getLeading(axis)); + return node.style.margin.get(leading[axis]); } - private static float getTrailingMargin(CSSNode node, CSSFlexDirection axis) { + private static float getTrailingMargin(CSSNode node, int axis) { if (isRowDirection(axis)) { float trailingMargin = node.style.margin.getRaw(Spacing.END); - if (!CSSConstants.isUndefined(trailingMargin)) { + if (!isUndefined(trailingMargin)) { return trailingMargin; } } - return getMargin(node, getTrailing(axis)); + return node.style.margin.get(trailing[axis]); } - private static float getPadding(CSSNode node, PositionIndex position) { - switch (position) { - case TOP: - return node.style.padding.get(Spacing.TOP); - case BOTTOM: - return node.style.padding.get(Spacing.BOTTOM); - case LEFT: - return node.style.padding.get(Spacing.LEFT); - case RIGHT: - return node.style.padding.get(Spacing.RIGHT); - case START: - return node.style.padding.get(Spacing.START); - case END: - return node.style.padding.get(Spacing.END); - default: - throw new RuntimeException("Someone added a new cardinal direction..."); - } - } - - private static float getLeadingPadding(CSSNode node, CSSFlexDirection axis) { + private static float getLeadingPadding(CSSNode node, int axis) { if (isRowDirection(axis)) { float leadingPadding = node.style.padding.getRaw(Spacing.START); - if (!CSSConstants.isUndefined(leadingPadding)) { + if (!isUndefined(leadingPadding)) { return leadingPadding; } } - return getPadding(node, getLeading(axis)); + return node.style.padding.get(leading[axis]); } - private static float getTrailingPadding(CSSNode node, CSSFlexDirection axis) { + private static float getTrailingPadding(CSSNode node, int axis) { if (isRowDirection(axis)) { float trailingPadding = node.style.padding.getRaw(Spacing.END); - if (!CSSConstants.isUndefined(trailingPadding)) { + if (!isUndefined(trailingPadding)) { return trailingPadding; } } - return getPadding(node, getTrailing(axis)); + return node.style.padding.get(trailing[axis]); } - private static float getBorder(CSSNode node, PositionIndex position) { - switch (position) { - case TOP: - return node.style.border.get(Spacing.TOP); - case BOTTOM: - return node.style.border.get(Spacing.BOTTOM); - case LEFT: - return node.style.border.get(Spacing.LEFT); - case RIGHT: - return node.style.border.get(Spacing.RIGHT); - case START: - return node.style.border.get(Spacing.START); - case END: - return node.style.border.get(Spacing.END); - default: - throw new RuntimeException("Someone added a new cardinal direction..."); - } - } - - private static float getLeadingBorder(CSSNode node, CSSFlexDirection axis) { + private static float getLeadingBorder(CSSNode node, int axis) { if (isRowDirection(axis)) { float leadingBorder = node.style.border.getRaw(Spacing.START); - if (!CSSConstants.isUndefined(leadingBorder)) { + if (!isUndefined(leadingBorder)) { return leadingBorder; } } - return getBorder(node, getLeading(axis)); + return node.style.border.get(leading[axis]); } - private static float getTrailingBorder(CSSNode node, CSSFlexDirection axis) { + private static float getTrailingBorder(CSSNode node, int axis) { if (isRowDirection(axis)) { float trailingBorder = node.style.border.getRaw(Spacing.END); - if (!CSSConstants.isUndefined(trailingBorder)) { + if (!isUndefined(trailingBorder)) { return trailingBorder; } } - return getBorder(node, getTrailing(axis)); + return node.style.border.get(trailing[axis]); } - private static float getLeadingPaddingAndBorder(CSSNode node, CSSFlexDirection axis) { + private static float getLeadingPaddingAndBorder(CSSNode node, int axis) { return getLeadingPadding(node, axis) + getLeadingBorder(node, axis); } - private static float getTrailingPaddingAndBorder(CSSNode node, CSSFlexDirection axis) { + private static float getTrailingPaddingAndBorder(CSSNode node, int axis) { return getTrailingPadding(node, axis) + getTrailingBorder(node, axis); } - private static float getBorderAxis(CSSNode node, CSSFlexDirection axis) { + private static float getBorderAxis(CSSNode node, int axis) { return getLeadingBorder(node, axis) + getTrailingBorder(node, axis); } - private static float getMarginAxis(CSSNode node, CSSFlexDirection axis) { + private static float getMarginAxis(CSSNode node, int axis) { return getLeadingMargin(node, axis) + getTrailingMargin(node, axis); } - private static float getPaddingAndBorderAxis(CSSNode node, CSSFlexDirection axis) { + private static float getPaddingAndBorderAxis(CSSNode node, int axis) { return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis); } - private static float boundAxis(CSSNode node, CSSFlexDirection axis, float value) { + private static float boundAxis(CSSNode node, int axis, float value) { float min = CSSConstants.UNDEFINED; float max = CSSConstants.UNDEFINED; @@ -344,19 +175,19 @@ public class LayoutEngine { float boundValue = value; - if (!CSSConstants.isUndefined(max) && max >= 0.0 && boundValue > max) { + if (!isUndefined(max) && max >= 0.0 && boundValue > max) { boundValue = max; } - if (!CSSConstants.isUndefined(min) && min >= 0.0 && boundValue < min) { + if (!isUndefined(min) && min >= 0.0 && boundValue < min) { boundValue = min; } return boundValue; } - private static void setDimensionFromStyle(CSSNode node, CSSFlexDirection axis) { + private static void setDimensionFromStyle(CSSNode node, int axis) { // The parent already computed us a width or height. We just skip it - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(axis)))) { + if (!isUndefined(node.layout.dimensions[dim[axis]])) { return; } // We only run if there's a width or height defined @@ -366,53 +197,49 @@ public class LayoutEngine { // The dimensions can never be smaller than the padding and border float maxLayoutDimension = Math.max( - boundAxis(node, axis, getStyleDimension(node, getDim(axis))), + boundAxis(node, axis, node.style.dimensions[dim[axis]]), getPaddingAndBorderAxis(node, axis)); - setLayoutDimension(node, getDim(axis), maxLayoutDimension); + node.layout.dimensions[dim[axis]] = maxLayoutDimension; } private static void setTrailingPosition( CSSNode node, CSSNode child, - CSSFlexDirection axis) { - setLayoutPosition( - child, - getTrailing(axis), - getLayoutDimension(node, getDim(axis)) - - getLayoutDimension(child, getDim(axis)) - - getLayoutPosition(child, getPos(axis))); + int axis) { + child.layout.position[trailing[axis]] = node.layout.dimensions[dim[axis]] - + child.layout.dimensions[dim[axis]] - child.layout.position[pos[axis]]; } - private static float getRelativePosition(CSSNode node, CSSFlexDirection axis) { - float lead = getStylePosition(node, getLeading(axis)); - if (!CSSConstants.isUndefined(lead)) { + private static float getRelativePosition(CSSNode node, int axis) { + float lead = node.style.position[leading[axis]]; + if (!isUndefined(lead)) { return lead; } - return -getPosition(node, getTrailing(axis)); + return -getPosition(node, trailing[axis]); } private static float getFlex(CSSNode node) { return node.style.flex; } - private static boolean isRowDirection(CSSFlexDirection flexDirection) { - return flexDirection == CSSFlexDirection.ROW || - flexDirection == CSSFlexDirection.ROW_REVERSE; + private static boolean isRowDirection(int flexDirection) { + return flexDirection == CSS_FLEX_DIRECTION_ROW || + flexDirection == CSS_FLEX_DIRECTION_ROW_REVERSE; } - private static boolean isColumnDirection(CSSFlexDirection flexDirection) { - return flexDirection == CSSFlexDirection.COLUMN || - flexDirection == CSSFlexDirection.COLUMN_REVERSE; + private static boolean isColumnDirection(int flexDirection) { + return flexDirection == CSS_FLEX_DIRECTION_COLUMN || + flexDirection == CSS_FLEX_DIRECTION_COLUMN_REVERSE; } - private static CSSFlexDirection resolveAxis( - CSSFlexDirection axis, + private static int resolveAxis( + int axis, CSSDirection direction) { if (direction == CSSDirection.RTL) { - if (axis == CSSFlexDirection.ROW) { - return CSSFlexDirection.ROW_REVERSE; - } else if (axis == CSSFlexDirection.ROW_REVERSE) { - return CSSFlexDirection.ROW; + if (axis == CSS_FLEX_DIRECTION_ROW) { + return CSS_FLEX_DIRECTION_ROW_REVERSE; + } else if (axis == CSS_FLEX_DIRECTION_ROW_REVERSE) { + return CSS_FLEX_DIRECTION_ROW; } } @@ -428,22 +255,22 @@ public class LayoutEngine { return direction; } - private static CSSFlexDirection getFlexDirection(CSSNode node) { - return node.style.flexDirection; + private static int getFlexDirection(CSSNode node) { + return node.style.flexDirection.ordinal(); } - private static CSSFlexDirection getCrossFlexDirection( - CSSFlexDirection flexDirection, + private static int getCrossFlexDirection( + int flexDirection, CSSDirection direction) { if (isColumnDirection(flexDirection)) { - return resolveAxis(CSSFlexDirection.ROW, direction); + return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction); } else { - return CSSFlexDirection.COLUMN; + return CSS_FLEX_DIRECTION_COLUMN; } } - private static CSSPositionType getPositionType(CSSNode node) { - return node.style.positionType; + private static int getPositionType(CSSNode node) { + return node.style.positionType.ordinal(); } private static CSSAlign getAlignItem(CSSNode node, CSSNode child) { @@ -466,23 +293,27 @@ public class LayoutEngine { } private static boolean isFlex(CSSNode node) { - return getPositionType(node) == CSSPositionType.RELATIVE && getFlex(node) > 0; + return getPositionType(node) == CSS_POSITION_RELATIVE && node.style.flex > 0; } private static boolean isMeasureDefined(CSSNode node) { return node.isMeasureDefined(); } - private static float getDimWithMargin(CSSNode node, CSSFlexDirection axis) { - return getLayoutDimension(node, getDim(axis)) + + private static float getDimWithMargin(CSSNode node, int axis) { + return node.layout.dimensions[dim[axis]] + getLeadingMargin(node, axis) + getTrailingMargin(node, axis); } private static boolean needsRelayout(CSSNode node, float parentMaxWidth) { return node.isDirty() || - !FloatUtil.floatsEqual(node.lastLayout.requestedHeight, node.layout.height) || - !FloatUtil.floatsEqual(node.lastLayout.requestedWidth, node.layout.width) || + !FloatUtil.floatsEqual( + node.lastLayout.requestedHeight, + node.layout.dimensions[DIMENSION_HEIGHT]) || + !FloatUtil.floatsEqual( + node.lastLayout.requestedWidth, + node.layout.dimensions[DIMENSION_WIDTH]) || !FloatUtil.floatsEqual(node.lastLayout.parentMaxWidth, parentMaxWidth); } @@ -492,8 +323,8 @@ public class LayoutEngine { float parentMaxWidth, CSSDirection parentDirection) { if (needsRelayout(node, parentMaxWidth)) { - node.lastLayout.requestedWidth = node.layout.width; - node.lastLayout.requestedHeight = node.layout.height; + node.lastLayout.requestedWidth = node.layout.dimensions[DIMENSION_WIDTH]; + node.lastLayout.requestedHeight = node.layout.dimensions[DIMENSION_HEIGHT]; node.lastLayout.parentMaxWidth = parentMaxWidth; layoutNodeImpl(layoutContext, node, parentMaxWidth, parentDirection); @@ -517,34 +348,34 @@ public class LayoutEngine { /** START_GENERATED **/ CSSDirection direction = resolveDirection(node, parentDirection); - CSSFlexDirection mainAxis = resolveAxis(getFlexDirection(node), direction); - CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); - CSSFlexDirection resolvedRowAxis = resolveAxis(CSSFlexDirection.ROW, direction); + int mainAxis = resolveAxis(getFlexDirection(node), direction); + int crossAxis = getCrossFlexDirection(mainAxis, direction); + int resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction); // Handle width and height style attributes setDimensionFromStyle(node, mainAxis); setDimensionFromStyle(node, crossAxis); // Set the resolved resolution in the node's layout - setLayoutDirection(node, direction); + node.layout.direction = direction; // The position is set by the parent, but we need to complete it with a // delta composed of the margin and left/top/right/bottom - setLayoutPosition(node, getLeading(mainAxis), getLayoutPosition(node, getLeading(mainAxis)) + getLeadingMargin(node, mainAxis) + - getRelativePosition(node, mainAxis)); - setLayoutPosition(node, getTrailing(mainAxis), getLayoutPosition(node, getTrailing(mainAxis)) + getTrailingMargin(node, mainAxis) + - getRelativePosition(node, mainAxis)); - setLayoutPosition(node, getLeading(crossAxis), getLayoutPosition(node, getLeading(crossAxis)) + getLeadingMargin(node, crossAxis) + - getRelativePosition(node, crossAxis)); - setLayoutPosition(node, getTrailing(crossAxis), getLayoutPosition(node, getTrailing(crossAxis)) + getTrailingMargin(node, crossAxis) + - getRelativePosition(node, crossAxis)); + node.layout.position[leading[mainAxis]] += getLeadingMargin(node, mainAxis) + + getRelativePosition(node, mainAxis); + node.layout.position[trailing[mainAxis]] += getTrailingMargin(node, mainAxis) + + getRelativePosition(node, mainAxis); + node.layout.position[leading[crossAxis]] += getLeadingMargin(node, crossAxis) + + getRelativePosition(node, crossAxis); + node.layout.position[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) + + getRelativePosition(node, crossAxis); if (isMeasureDefined(node)) { float width = CSSConstants.UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { - width = node.style.width; - } else if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(resolvedRowAxis)))) { - width = getLayoutDimension(node, getDim(resolvedRowAxis)); + width = node.style.dimensions[DIMENSION_WIDTH]; + } else if (!isUndefined(node.layout.dimensions[dim[resolvedRowAxis]])) { + width = node.layout.dimensions[dim[resolvedRowAxis]]; } else { width = parentMaxWidth - getMarginAxis(node, resolvedRowAxis); @@ -555,23 +386,24 @@ public class LayoutEngine { // for it computed yet. It can either be from the style attribute or because // the element is flexible. boolean isRowUndefined = !isDimDefined(node, resolvedRowAxis) && - CSSConstants.isUndefined(getLayoutDimension(node, getDim(resolvedRowAxis))); - boolean isColumnUndefined = !isDimDefined(node, CSSFlexDirection.COLUMN) && - CSSConstants.isUndefined(getLayoutDimension(node, getDim(CSSFlexDirection.COLUMN))); + isUndefined(node.layout.dimensions[dim[resolvedRowAxis]]); + boolean isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) && + isUndefined(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]); // Let's not measure the text if we already know both dimensions if (isRowUndefined || isColumnUndefined) { MeasureOutput measureDim = node.measure( - layoutContext.measureOutput, + + layoutContext.measureOutput, width ); if (isRowUndefined) { - node.layout.width = measureDim.width + + node.layout.dimensions[DIMENSION_WIDTH] = measureDim.width + getPaddingAndBorderAxis(node, resolvedRowAxis); } if (isColumnUndefined) { - node.layout.height = measureDim.height + - getPaddingAndBorderAxis(node, CSSFlexDirection.COLUMN); + node.layout.dimensions[DIMENSION_HEIGHT] = measureDim.height + + getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN); } } if (node.getChildCount() == 0) { @@ -582,7 +414,7 @@ public class LayoutEngine { int i; int ii; CSSNode child; - CSSFlexDirection axis; + int axis; // Pre-fill some dimensions straight from the parent for (i = 0; i < node.getChildCount(); ++i) { @@ -590,42 +422,42 @@ public class LayoutEngine { // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) == CSSAlign.STRETCH && - getPositionType(child) == CSSPositionType.RELATIVE && - !CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis))) && + getPositionType(child) == CSS_POSITION_RELATIVE && + !isUndefined(node.layout.dimensions[dim[crossAxis]]) && !isDimDefined(child, crossAxis)) { - setLayoutDimension(child, getDim(crossAxis), Math.max( - boundAxis(child, crossAxis, getLayoutDimension(node, getDim(crossAxis)) - + child.layout.dimensions[dim[crossAxis]] = Math.max( + boundAxis(child, crossAxis, node.layout.dimensions[dim[crossAxis]] - getPaddingAndBorderAxis(node, crossAxis) - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) - )); - } else if (getPositionType(child) == CSSPositionType.ABSOLUTE) { + ); + } else if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSSFlexDirection.ROW : CSSFlexDirection.COLUMN; - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(axis))) && + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout.dimensions[dim[axis]]) && !isDimDefined(child, axis) && - isPosDefined(child, getLeading(axis)) && - isPosDefined(child, getTrailing(axis))) { - setLayoutDimension(child, getDim(axis), Math.max( - boundAxis(child, axis, getLayoutDimension(node, getDim(axis)) - + isPosDefined(child, leading[axis]) && + isPosDefined(child, trailing[axis])) { + child.layout.dimensions[dim[axis]] = Math.max( + boundAxis(child, axis, node.layout.dimensions[dim[axis]] - getPaddingAndBorderAxis(node, axis) - getMarginAxis(child, axis) - - getPosition(child, getLeading(axis)) - - getPosition(child, getTrailing(axis))), + getPosition(child, leading[axis]) - + getPosition(child, trailing[axis])), // You never want to go smaller than padding getPaddingAndBorderAxis(child, axis) - )); + ); } } } } float definedMainDim = CSSConstants.UNDEFINED; - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis)))) { - definedMainDim = getLayoutDimension(node, getDim(mainAxis)) - + if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { + definedMainDim = node.layout.dimensions[dim[mainAxis]] - getPaddingAndBorderAxis(node, mainAxis); } @@ -660,9 +492,9 @@ public class LayoutEngine { // It only makes sense to consider a child flexible if we have a computed // dimension for the node. - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis))) && isFlex(child)) { + if (!isUndefined(node.layout.dimensions[dim[mainAxis]]) && isFlex(child)) { flexibleChildrenCount++; - totalFlexible = totalFlexible + getFlex(child); + totalFlexible += getFlex(child); // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents @@ -679,7 +511,7 @@ public class LayoutEngine { getPaddingAndBorderAxis(node, resolvedRowAxis); if (isDimDefined(node, resolvedRowAxis)) { - maxWidth = getLayoutDimension(node, getDim(resolvedRowAxis)) - + maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - getPaddingAndBorderAxis(node, resolvedRowAxis); } } @@ -691,7 +523,7 @@ public class LayoutEngine { // Absolute positioned elements do not take part of the layout, so we // don't use them to compute mainContentDim - if (getPositionType(child) == CSSPositionType.RELATIVE) { + if (getPositionType(child) == CSS_POSITION_RELATIVE) { nonFlexibleChildrenCount++; // At this point we know the final size and margin of the element. nextContentDim = getDimWithMargin(child, mainAxis); @@ -700,7 +532,7 @@ public class LayoutEngine { // The element we are about to add would make us go to the next line if (isFlexWrap(node) && - !CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis))) && + !isUndefined(node.layout.dimensions[dim[mainAxis]]) && mainContentDim + nextContentDim > definedMainDim && // If there's only one element, then it's bigger than the content // and needs its own line @@ -710,7 +542,7 @@ public class LayoutEngine { break; } alreadyComputedNextLayout = 0; - mainContentDim = mainContentDim + nextContentDim; + mainContentDim += nextContentDim; endLine = i + 1; } @@ -724,7 +556,7 @@ public class LayoutEngine { // The remaining available space that needs to be allocated float remainingMainDim = 0; - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis)))) { + if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { remainingMainDim = definedMainDim - mainContentDim; } else { remainingMainDim = Math.max(mainContentDim, 0) - mainContentDim; @@ -768,13 +600,13 @@ public class LayoutEngine { if (isFlex(child)) { // At this point we know the final size of the element in the main // dimension - setLayoutDimension(child, getDim(mainAxis), boundAxis(child, mainAxis, + child.layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis, flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis) - )); + ); maxWidth = CSSConstants.UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { - maxWidth = getLayoutDimension(node, getDim(resolvedRowAxis)) - + maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - getPaddingAndBorderAxis(node, resolvedRowAxis); } else if (!isRowDirection(mainAxis)) { maxWidth = parentMaxWidth - @@ -825,21 +657,21 @@ public class LayoutEngine { child = node.getChildAt(i); child.lineIndex = linesCount; - if (getPositionType(child) == CSSPositionType.ABSOLUTE && - isPosDefined(child, getLeading(mainAxis))) { + if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + isPosDefined(child, leading[mainAxis])) { // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said // (and margin/border). - setLayoutPosition(child, getPos(mainAxis), getPosition(child, getLeading(mainAxis)) + + child.layout.position[pos[mainAxis]] = getPosition(child, leading[mainAxis]) + getLeadingBorder(node, mainAxis) + - getLeadingMargin(child, mainAxis)); + getLeadingMargin(child, mainAxis); } else { // If the child is position absolute (without top/left) or relative, // we put it at the current accumulated offset. - setLayoutPosition(child, getPos(mainAxis), getLayoutPosition(child, getPos(mainAxis)) + mainDim); + child.layout.position[pos[mainAxis]] += mainDim; // Define the trailing position accordingly. - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis)))) { + if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { setTrailingPosition(node, child, mainAxis); } } @@ -847,18 +679,18 @@ public class LayoutEngine { // Now that we placed the element, we need to update the variables // We only need to do that for relative elements. Absolute elements // do not take part in that phase. - if (getPositionType(child) == CSSPositionType.RELATIVE) { + if (getPositionType(child) == CSS_POSITION_RELATIVE) { // The main dimension is the sum of all the elements dimension plus // the spacing. - mainDim = mainDim + betweenMainDim + getDimWithMargin(child, mainAxis); + mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); // The cross dimension is the max of the elements dimension since there // can only be one element in that cross dimension. crossDim = Math.max(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); } } - float containerCrossAxis = getLayoutDimension(node, getDim(crossAxis)); - if (CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) { + float containerCrossAxis = node.layout.dimensions[dim[crossAxis]]; + if (isUndefined(node.layout.dimensions[dim[crossAxis]])) { containerCrossAxis = Math.max( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values @@ -872,33 +704,33 @@ public class LayoutEngine { for (i = startLine; i < endLine; ++i) { child = node.getChildAt(i); - if (getPositionType(child) == CSSPositionType.ABSOLUTE && - isPosDefined(child, getLeading(crossAxis))) { + if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + isPosDefined(child, leading[crossAxis])) { // In case the child is absolutely positionned and has a // top/left/bottom/right being set, we override all the previously // computed positions to set it correctly. - setLayoutPosition(child, getPos(crossAxis), getPosition(child, getLeading(crossAxis)) + + child.layout.position[pos[crossAxis]] = getPosition(child, leading[crossAxis]) + getLeadingBorder(node, crossAxis) + - getLeadingMargin(child, crossAxis)); + getLeadingMargin(child, crossAxis); } else { float leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis); // For a relative children, we're either using alignItems (parent) or // alignSelf (child) in order to determine the position in the cross axis - if (getPositionType(child) == CSSPositionType.RELATIVE) { + if (getPositionType(child) == CSS_POSITION_RELATIVE) { CSSAlign alignItem = getAlignItem(node, child); if (alignItem == CSSAlign.STRETCH) { // You can only stretch if the dimension has not already been set // previously. if (!isDimDefined(child, crossAxis)) { - setLayoutDimension(child, getDim(crossAxis), Math.max( + child.layout.dimensions[dim[crossAxis]] = Math.max( boundAxis(child, crossAxis, containerCrossAxis - getPaddingAndBorderAxis(node, crossAxis) - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) - )); + ); } } else if (alignItem != CSSAlign.FLEX_START) { // The remaining space between the parent dimensions+padding and child @@ -908,26 +740,26 @@ public class LayoutEngine { getDimWithMargin(child, crossAxis); if (alignItem == CSSAlign.CENTER) { - leadingCrossDim = leadingCrossDim + remainingCrossDim / 2; + leadingCrossDim += remainingCrossDim / 2; } else { // CSSAlign.FLEX_END - leadingCrossDim = leadingCrossDim + remainingCrossDim; + leadingCrossDim += remainingCrossDim; } } } // And we apply the position - setLayoutPosition(child, getPos(crossAxis), getLayoutPosition(child, getPos(crossAxis)) + linesCrossDim + leadingCrossDim); + child.layout.position[pos[crossAxis]] += linesCrossDim + leadingCrossDim; // Define the trailing position accordingly. - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) { + if (!isUndefined(node.layout.dimensions[dim[crossAxis]])) { setTrailingPosition(node, child, crossAxis); } } } - linesCrossDim = linesCrossDim + crossDim; + linesCrossDim += crossDim; linesMainDim = Math.max(linesMainDim, mainDim); - linesCount = linesCount + 1; + linesCount += 1; startLine = endLine; } @@ -945,8 +777,8 @@ public class LayoutEngine { // section 9.4 // if (linesCount > 1 && - !CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) { - float nodeCrossAxisInnerSize = getLayoutDimension(node, getDim(crossAxis)) - + !isUndefined(node.layout.dimensions[dim[crossAxis]])) { + float nodeCrossAxisInnerSize = node.layout.dimensions[dim[crossAxis]] - getPaddingAndBorderAxis(node, crossAxis); float remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim; @@ -955,9 +787,9 @@ public class LayoutEngine { CSSAlign alignContent = getAlignContent(node); if (alignContent == CSSAlign.FLEX_END) { - currentLead = currentLead + remainingAlignContentDim; + currentLead += remainingAlignContentDim; } else if (alignContent == CSSAlign.CENTER) { - currentLead = currentLead + remainingAlignContentDim / 2; + currentLead += remainingAlignContentDim / 2; } else if (alignContent == CSSAlign.STRETCH) { if (nodeCrossAxisInnerSize > linesCrossDim) { crossDimLead = (remainingAlignContentDim / linesCount); @@ -972,44 +804,44 @@ public class LayoutEngine { float lineHeight = 0; for (ii = startIndex; ii < node.getChildCount(); ++ii) { child = node.getChildAt(ii); - if (getPositionType(child) != CSSPositionType.RELATIVE) { + if (getPositionType(child) != CSS_POSITION_RELATIVE) { continue; } if (child.lineIndex != i) { break; } - if (!CSSConstants.isUndefined(getLayoutDimension(child, getDim(crossAxis)))) { + if (!isUndefined(child.layout.dimensions[dim[crossAxis]])) { lineHeight = Math.max( lineHeight, - getLayoutDimension(child, getDim(crossAxis)) + getMarginAxis(child, crossAxis) + child.layout.dimensions[dim[crossAxis]] + getMarginAxis(child, crossAxis) ); } } endIndex = ii; - lineHeight = lineHeight + crossDimLead; + lineHeight += crossDimLead; for (ii = startIndex; ii < endIndex; ++ii) { child = node.getChildAt(ii); - if (getPositionType(child) != CSSPositionType.RELATIVE) { + if (getPositionType(child) != CSS_POSITION_RELATIVE) { continue; } CSSAlign alignContentAlignItem = getAlignItem(node, child); if (alignContentAlignItem == CSSAlign.FLEX_START) { - setLayoutPosition(child, getPos(crossAxis), currentLead + getLeadingMargin(child, crossAxis)); + child.layout.position[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis); } else if (alignContentAlignItem == CSSAlign.FLEX_END) { - setLayoutPosition(child, getPos(crossAxis), currentLead + lineHeight - getTrailingMargin(child, crossAxis) - getLayoutDimension(child, getDim(crossAxis))); + child.layout.position[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child.layout.dimensions[dim[crossAxis]]; } else if (alignContentAlignItem == CSSAlign.CENTER) { - float childHeight = getLayoutDimension(child, getDim(crossAxis)); - setLayoutPosition(child, getPos(crossAxis), currentLead + (lineHeight - childHeight) / 2); + float childHeight = child.layout.dimensions[dim[crossAxis]]; + child.layout.position[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2; } else if (alignContentAlignItem == CSSAlign.STRETCH) { - setLayoutPosition(child, getPos(crossAxis), currentLead + getLeadingMargin(child, crossAxis)); + child.layout.position[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis); // TODO(prenaux): Correctly set the height of items with undefined // (auto) crossAxis dimension. } } - currentLead = currentLead + lineHeight; + currentLead += lineHeight; } } @@ -1018,26 +850,26 @@ public class LayoutEngine { // If the user didn't specify a width or height, and it has not been set // by the container, then we set it via the children. - if (CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis)))) { - setLayoutDimension(node, getDim(mainAxis), Math.max( + if (isUndefined(node.layout.dimensions[dim[mainAxis]])) { + node.layout.dimensions[dim[mainAxis]] = Math.max( // We're missing the last padding at this point to get the final // dimension boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)), // We can never assign a width smaller than the padding and borders getPaddingAndBorderAxis(node, mainAxis) - )); + ); needsMainTrailingPos = true; } - if (CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) { - setLayoutDimension(node, getDim(crossAxis), Math.max( + if (isUndefined(node.layout.dimensions[dim[crossAxis]])) { + node.layout.dimensions[dim[crossAxis]] = Math.max( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)), getPaddingAndBorderAxis(node, crossAxis) - )); + ); needsCrossTrailingPos = true; } @@ -1060,34 +892,35 @@ public class LayoutEngine { // Calculate dimensions for absolutely positioned elements for (i = 0; i < node.getChildCount(); ++i) { child = node.getChildAt(i); - if (getPositionType(child) == CSSPositionType.ABSOLUTE) { + if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSSFlexDirection.ROW : CSSFlexDirection.COLUMN; - if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(axis))) && + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout.dimensions[dim[axis]]) && !isDimDefined(child, axis) && - isPosDefined(child, getLeading(axis)) && - isPosDefined(child, getTrailing(axis))) { - setLayoutDimension(child, getDim(axis), Math.max( - boundAxis(child, axis, getLayoutDimension(node, getDim(axis)) - + isPosDefined(child, leading[axis]) && + isPosDefined(child, trailing[axis])) { + child.layout.dimensions[dim[axis]] = Math.max( + boundAxis(child, axis, node.layout.dimensions[dim[axis]] - getBorderAxis(node, axis) - getMarginAxis(child, axis) - - getPosition(child, getLeading(axis)) - - getPosition(child, getTrailing(axis)) + getPosition(child, leading[axis]) - + getPosition(child, trailing[axis]) ), // You never want to go smaller than padding getPaddingAndBorderAxis(child, axis) - )); + ); } } for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSSFlexDirection.ROW : CSSFlexDirection.COLUMN; - if (isPosDefined(child, getTrailing(axis)) && - !isPosDefined(child, getLeading(axis))) { - setLayoutPosition(child, getLeading(axis), getLayoutDimension(node, getDim(axis)) - - getLayoutDimension(child, getDim(axis)) - - getPosition(child, getTrailing(axis))); + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (isPosDefined(child, trailing[axis]) && + !isPosDefined(child, leading[axis])) { + child.layout.position[leading[axis]] = + node.layout.dimensions[dim[axis]] - + child.layout.dimensions[dim[axis]] - + getPosition(child, trailing[axis]); } } } diff --git a/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java b/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java index 2e4373b2..0610728f 100644 --- a/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java +++ b/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java @@ -11,6 +11,13 @@ package com.facebook.csslayout; import org.junit.Assert; import org.junit.Test; +import static com.facebook.csslayout.CSSLayout.POSITION_LEFT; +import static com.facebook.csslayout.CSSLayout.POSITION_TOP; +import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT; +import static com.facebook.csslayout.CSSLayout.POSITION_BOTTOM; +import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH; +import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT; + /** * Tests for {@link LayoutEngine} */ @@ -69,10 +76,10 @@ public class LayoutEngineTest { private static boolean areLayoutsEqual(CSSNode a, CSSNode b) { boolean doNodesHaveSameLayout = - areFloatsEqual(a.layout.left, b.layout.left) && - areFloatsEqual(a.layout.top, b.layout.top) && - areFloatsEqual(a.layout.width, b.layout.width) && - areFloatsEqual(a.layout.height, b.layout.height); + areFloatsEqual(a.layout.position[POSITION_LEFT], b.layout.position[POSITION_LEFT]) && + areFloatsEqual(a.layout.position[POSITION_TOP], b.layout.position[POSITION_TOP]) && + areFloatsEqual(a.layout.dimensions[DIMENSION_WIDTH], b.layout.dimensions[DIMENSION_WIDTH]) && + areFloatsEqual(a.layout.dimensions[DIMENSION_HEIGHT], b.layout.dimensions[DIMENSION_HEIGHT]); if (!doNodesHaveSameLayout) { return false; } @@ -95,17 +102,17 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; } test("should layout a single node with width and height", root_node, root_layout); @@ -117,48 +124,48 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.style.width = 250; - node_1.style.height = 250; + node_1.style.dimensions[DIMENSION_WIDTH] = 250; + node_1.style.dimensions[DIMENSION_HEIGHT] = 250; node_1 = node_0.getChildAt(2); - node_1.style.width = 125; - node_1.style.height = 125; + node_1.style.dimensions[DIMENSION_WIDTH] = 125; + node_1.style.dimensions[DIMENSION_HEIGHT] = 125; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 250; - node_1.layout.height = 250; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 250; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 250; node_1 = node_0.getChildAt(2); - node_1.layout.top = 750; - node_1.layout.left = 0; - node_1.layout.width = 125; - node_1.layout.height = 125; + node_1.layout.position[POSITION_TOP] = 750; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 125; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 125; } } @@ -172,48 +179,48 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.style.width = 250; - node_1.style.height = 250; + node_1.style.dimensions[DIMENSION_WIDTH] = 250; + node_1.style.dimensions[DIMENSION_HEIGHT] = 250; node_1 = node_0.getChildAt(2); - node_1.style.width = 125; - node_1.style.height = 125; + node_1.style.dimensions[DIMENSION_WIDTH] = 125; + node_1.style.dimensions[DIMENSION_HEIGHT] = 125; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.layout.top = 250; - node_1.layout.left = 0; - node_1.layout.width = 250; - node_1.layout.height = 250; + node_1.layout.position[POSITION_TOP] = 250; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 250; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 250; node_1 = node_0.getChildAt(2); - node_1.layout.top = 125; - node_1.layout.left = 0; - node_1.layout.width = 125; - node_1.layout.height = 125; + node_1.layout.position[POSITION_TOP] = 125; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 125; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 125; } } @@ -226,26 +233,26 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 250; - node_2.style.height = 250; + node_2.style.dimensions[DIMENSION_WIDTH] = 250; + node_2.style.dimensions[DIMENSION_HEIGHT] = 250; node_2 = node_1.getChildAt(1); - node_2.style.width = 250; - node_2.style.height = 250; + node_2.style.dimensions[DIMENSION_WIDTH] = 250; + node_2.style.dimensions[DIMENSION_HEIGHT] = 250; } } } @@ -253,36 +260,36 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 250; - node_2.layout.height = 250; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 250; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 250; node_2 = node_1.getChildAt(1); - node_2.layout.top = 250; - node_2.layout.left = 0; - node_2.layout.width = 250; - node_2.layout.height = 250; + node_2.layout.position[POSITION_TOP] = 250; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 250; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 250; } } } @@ -297,27 +304,27 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); node_1.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_1.style.width = 500; - node_1.style.height = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; + node_1.style.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 250; - node_2.style.height = 250; + node_2.style.dimensions[DIMENSION_WIDTH] = 250; + node_2.style.dimensions[DIMENSION_HEIGHT] = 250; node_2 = node_1.getChildAt(1); - node_2.style.width = 250; - node_2.style.height = 250; + node_2.style.dimensions[DIMENSION_WIDTH] = 250; + node_2.style.dimensions[DIMENSION_HEIGHT] = 250; } } } @@ -325,36 +332,36 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 250; - node_2.layout.left = 0; - node_2.layout.width = 250; - node_2.layout.height = 250; + node_2.layout.position[POSITION_TOP] = 250; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 250; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 250; node_2 = node_1.getChildAt(1); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 250; - node_2.layout.height = 250; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 250; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 250; } } } @@ -368,8 +375,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.setMargin(Spacing.LEFT, 10); node_0.setMargin(Spacing.TOP, 10); node_0.setMargin(Spacing.RIGHT, 10); @@ -381,10 +388,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 10; - node_0.layout.width = 100; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 10; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; } test("should layout node with margin", root_node, root_layout); @@ -396,8 +403,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; node_0.setMargin(Spacing.LEFT, 10); node_0.setMargin(Spacing.TOP, 10); node_0.setMargin(Spacing.RIGHT, 10); @@ -408,8 +415,8 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 50); node_1.setMargin(Spacing.TOP, 50); node_1.setMargin(Spacing.RIGHT, 50); @@ -417,8 +424,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 50); node_1.setMargin(Spacing.END, 50); node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 25); node_1.setMargin(Spacing.TOP, 25); node_1.setMargin(Spacing.RIGHT, 25); @@ -426,8 +433,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 25); node_1.setMargin(Spacing.END, 25); node_1 = node_0.getChildAt(2); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -440,28 +447,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 10; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 10; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 50; - node_1.layout.left = 50; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 50; + node_1.layout.position[POSITION_LEFT] = 50; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 225; - node_1.layout.left = 25; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 225; + node_1.layout.position[POSITION_LEFT] = 25; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(2); - node_1.layout.top = 360; - node_1.layout.left = 10; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 360; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -475,8 +482,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; node_0.setMargin(Spacing.LEFT, 10); node_0.setMargin(Spacing.TOP, 10); node_0.setMargin(Spacing.RIGHT, 10); @@ -487,8 +494,8 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 50); node_1.setMargin(Spacing.TOP, 50); node_1.setMargin(Spacing.RIGHT, 50); @@ -496,8 +503,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 50); node_1.setMargin(Spacing.END, 50); node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 25); node_1.setMargin(Spacing.TOP, 25); node_1.setMargin(Spacing.RIGHT, 25); @@ -505,8 +512,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 25); node_1.setMargin(Spacing.END, 25); node_1 = node_0.getChildAt(2); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -519,28 +526,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 10; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 10; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 850; - node_1.layout.left = 50; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 850; + node_1.layout.position[POSITION_LEFT] = 50; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 675; - node_1.layout.left = 25; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 675; + node_1.layout.position[POSITION_LEFT] = 25; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(2); - node_1.layout.top = 540; - node_1.layout.left = 10; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 540; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -555,40 +562,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.style.width = 300; - node_1.style.height = 150; + node_1.style.dimensions[DIMENSION_WIDTH] = 300; + node_1.style.dimensions[DIMENSION_HEIGHT] = 150; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 100; - node_1.layout.width = 300; - node_1.layout.height = 150; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 150; } } @@ -602,40 +609,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.style.width = 300; - node_1.style.height = 150; + node_1.style.dimensions[DIMENSION_WIDTH] = 300; + node_1.style.dimensions[DIMENSION_HEIGHT] = 150; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 100; - node_1.layout.width = 300; - node_1.layout.height = 150; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 150; } } @@ -650,40 +657,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.style.width = 300; - node_1.style.height = 150; + node_1.style.dimensions[DIMENSION_WIDTH] = 300; + node_1.style.dimensions[DIMENSION_HEIGHT] = 150; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 900; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 900; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 600; - node_1.layout.width = 300; - node_1.layout.height = 150; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 600; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 150; } } @@ -696,39 +703,39 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 300; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.style.width = 300; - node_1.style.height = 150; + node_1.style.dimensions[DIMENSION_WIDTH] = 300; + node_1.style.dimensions[DIMENSION_HEIGHT] = 150; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 350; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 350; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 200; - node_1.layout.left = 0; - node_1.layout.width = 300; - node_1.layout.height = 150; + node_1.layout.position[POSITION_TOP] = 200; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 150; } } @@ -742,39 +749,39 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 300; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.style.width = 300; - node_1.style.height = 150; + node_1.style.dimensions[DIMENSION_WIDTH] = 300; + node_1.style.dimensions[DIMENSION_HEIGHT] = 150; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 350; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 350; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 150; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 150; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 300; - node_1.layout.height = 150; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 150; } } @@ -787,40 +794,40 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); node_1.style.flex = 1; - node_1.style.width = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 200; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 800; + node_1.layout.position[POSITION_TOP] = 200; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 800; } } @@ -834,40 +841,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); node_1.style.flex = 1; - node_1.style.width = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 800; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 800; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 800; } } @@ -880,26 +887,26 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flex = 1; - node_1.style.width = 1000; + node_1.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); node_2.style.flex = 1; - node_2.style.width = 1000; + node_2.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_2, 1); { TestCSSNode node_3; node_3 = node_2.getChildAt(0); node_3.style.flex = 1; - node_3.style.width = 1000; + node_3.style.dimensions[DIMENSION_WIDTH] = 1000; } } } @@ -908,34 +915,34 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 1000; - node_1.layout.height = 1000; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 1000; - node_2.layout.height = 1000; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_2, 1); { TestCSSNode node_3; node_3 = node_2.getChildAt(0); - node_3.layout.top = 0; - node_3.layout.left = 0; - node_3.layout.width = 1000; - node_3.layout.height = 1000; + node_3.layout.position[POSITION_TOP] = 0; + node_3.layout.position[POSITION_LEFT] = 0; + node_3.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_3.layout.dimensions[DIMENSION_HEIGHT] = 1000; } } } @@ -951,29 +958,29 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_1.style.flex = 1; - node_1.style.width = 1000; + node_1.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); node_2.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_2.style.flex = 1; - node_2.style.width = 1000; + node_2.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_2, 1); { TestCSSNode node_3; node_3 = node_2.getChildAt(0); node_3.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_3.style.flex = 1; - node_3.style.width = 1000; + node_3.style.dimensions[DIMENSION_WIDTH] = 1000; } } } @@ -982,34 +989,34 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 1000; - node_1.layout.height = 1000; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 1000; - node_2.layout.height = 1000; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_2, 1); { TestCSSNode node_3; node_3 = node_2.getChildAt(0); - node_3.layout.top = 0; - node_3.layout.left = 0; - node_3.layout.width = 1000; - node_3.layout.height = 1000; + node_3.layout.position[POSITION_TOP] = 0; + node_3.layout.position[POSITION_LEFT] = 0; + node_3.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_3.layout.dimensions[DIMENSION_HEIGHT] = 1000; } } } @@ -1024,22 +1031,22 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; node_0.setMargin(Spacing.LEFT, 5); node_0.setMargin(Spacing.TOP, 10); addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 15); node_1.setMargin(Spacing.TOP, 50); node_1.setMargin(Spacing.BOTTOM, 20); node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 30); } } @@ -1047,23 +1054,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 5; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 5; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 50; - node_1.layout.left = 15; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 50; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 170; - node_1.layout.left = 30; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 170; + node_1.layout.position[POSITION_LEFT] = 30; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1077,22 +1084,22 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; node_0.setMargin(Spacing.LEFT, 5); node_0.setMargin(Spacing.TOP, 10); addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 15); node_1.setMargin(Spacing.TOP, 50); node_1.setMargin(Spacing.BOTTOM, 20); node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 30); } } @@ -1100,23 +1107,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 5; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 5; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 880; - node_1.layout.left = 15; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 880; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 730; - node_1.layout.left = 30; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 730; + node_1.layout.position[POSITION_LEFT] = 30; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1130,40 +1137,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.FLEX_START; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1178,40 +1185,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.FLEX_START; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 800; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1225,40 +1232,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 800; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1273,40 +1280,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1320,40 +1327,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.SPACE_BETWEEN; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1368,40 +1375,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.SPACE_BETWEEN; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1415,40 +1422,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.SPACE_AROUND; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 200; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 200; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 700; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 700; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1463,40 +1470,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.SPACE_AROUND; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 700; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 700; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 200; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 200; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1510,40 +1517,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.CENTER; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 400; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 400; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1558,40 +1565,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.CENTER; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 400; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 400; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1604,33 +1611,33 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flex = 1; - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 1000; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 1000; } } @@ -1644,40 +1651,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.FLEX_START; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1692,40 +1699,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignItems = CSSAlign.FLEX_START; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 800; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1739,40 +1746,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.CENTER; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 400; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 400; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 450; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 450; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1787,40 +1794,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignItems = CSSAlign.CENTER; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 400; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 400; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 800; - node_1.layout.left = 450; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 450; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1834,40 +1841,40 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 800; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 800; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 900; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 900; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1882,40 +1889,40 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignItems = CSSAlign.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 800; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 800; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 800; - node_1.layout.left = 900; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 900; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1929,41 +1936,41 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); node_1.style.alignSelf = CSSAlign.CENTER; - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 800; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 800; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 450; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 450; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -1978,41 +1985,41 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignItems = CSSAlign.FLEX_END; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); node_1.style.alignSelf = CSSAlign.CENTER; - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 800; - node_1.layout.width = 200; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 800; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 800; - node_1.layout.left = 450; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 800; + node_1.layout.position[POSITION_LEFT] = 450; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -2026,31 +2033,31 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.STRETCH; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 1000; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -2065,31 +2072,31 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignItems = CSSAlign.STRETCH; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 1000; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -2112,18 +2119,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2147,18 +2154,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2187,18 +2194,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 5; - node_1.layout.left = 5; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 5; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2228,18 +2235,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 5; - node_1.layout.left = 5; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 5; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2252,37 +2259,37 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -2296,37 +2303,37 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = -200; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = -200; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -2345,10 +2352,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; } test("should layout for center", root_node, root_layout); @@ -2361,7 +2368,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; @@ -2373,18 +2380,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2399,7 +2406,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; @@ -2411,18 +2418,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 10; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2451,7 +2458,7 @@ public class LayoutEngineTest { node_2.setMargin(Spacing.START, 10); node_2.setMargin(Spacing.END, 10); node_2 = node_1.getChildAt(1); - node_2.style.height = 100; + node_2.style.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -2459,31 +2466,31 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 20; - node_0.layout.height = 120; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 20; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 120; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 20; - node_1.layout.height = 120; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 20; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 120; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 10; - node_2.layout.left = 10; - node_2.layout.width = 0; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 10; + node_2.layout.position[POSITION_LEFT] = 10; + node_2.layout.dimensions[DIMENSION_WIDTH] = 0; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; node_2 = node_1.getChildAt(1); - node_2.layout.top = 20; - node_2.layout.left = 20; - node_2.layout.width = 0; - node_2.layout.height = 100; + node_2.layout.position[POSITION_TOP] = 20; + node_2.layout.position[POSITION_LEFT] = 20; + node_2.layout.dimensions[DIMENSION_WIDTH] = 0; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -2514,7 +2521,7 @@ public class LayoutEngineTest { node_2.setMargin(Spacing.START, 10); node_2.setMargin(Spacing.END, 10); node_2 = node_1.getChildAt(1); - node_2.style.height = 100; + node_2.style.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -2522,31 +2529,31 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 20; - node_0.layout.height = 120; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 20; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 120; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 20; - node_1.layout.height = 120; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 20; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 120; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 110; - node_2.layout.left = 10; - node_2.layout.width = 0; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 110; + node_2.layout.position[POSITION_LEFT] = 10; + node_2.layout.dimensions[DIMENSION_WIDTH] = 0; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; node_2 = node_1.getChildAt(1); - node_2.layout.top = 0; - node_2.layout.left = 20; - node_2.layout.width = 0; - node_2.layout.height = 100; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 20; + node_2.layout.dimensions[DIMENSION_WIDTH] = 0; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -2571,18 +2578,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2607,18 +2614,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 10; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2644,18 +2651,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 10; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2679,10 +2686,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; } test("should layout node with padding", root_node, root_layout); @@ -2710,18 +2717,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 5; - node_1.layout.left = 5; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 5; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2756,18 +2763,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 20; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 20; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 10; - node_1.layout.left = 10; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2797,18 +2804,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 20; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 20; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 20; - node_1.layout.height = 20; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 20; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 20; } } @@ -2844,18 +2851,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 120; - node_0.layout.height = 120; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 120; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 120; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 50; - node_1.layout.left = 50; - node_1.layout.width = 20; - node_1.layout.height = 20; + node_1.layout.position[POSITION_TOP] = 50; + node_1.layout.position[POSITION_LEFT] = 50; + node_1.layout.dimensions[DIMENSION_WIDTH] = 20; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 20; } } @@ -2890,26 +2897,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 32; - node_0.layout.height = 32; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 32; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 32; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 32; - node_1.layout.height = 32; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 32; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 32; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 16; - node_2.layout.left = 16; - node_2.layout.width = 0; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 16; + node_2.layout.position[POSITION_LEFT] = 16; + node_2.layout.dimensions[DIMENSION_WIDTH] = 0; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; } } } @@ -2923,17 +2930,17 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.positionLeft = 5; - node_0.style.positionTop = 5; + node_0.style.position[POSITION_LEFT] = 5; + node_0.style.position[POSITION_TOP] = 5; } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 5; - node_0.layout.left = 5; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 5; + node_0.layout.position[POSITION_LEFT] = 5; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; } test("should layout node with top and left", root_node, root_layout); @@ -2946,7 +2953,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.SPACE_AROUND; - node_0.style.height = 10; + node_0.style.dimensions[DIMENSION_HEIGHT] = 10; node_0.setPadding(Spacing.TOP, 5); addChildren(node_0, 1); { @@ -2958,18 +2965,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 7.5f; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 7.5f; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -2982,16 +2989,16 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.positionBottom = 5; + node_0.style.position[POSITION_BOTTOM] = 5; } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = -5; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = -5; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; } test("should layout node with bottom", root_node, root_layout); @@ -3003,17 +3010,17 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.positionTop = 10; - node_0.style.positionBottom = 5; + node_0.style.position[POSITION_TOP] = 10; + node_0.style.position[POSITION_BOTTOM] = 5; } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 10; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 10; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; } test("should layout node with both top and bottom", root_node, root_layout); @@ -3026,7 +3033,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 500; + node_0.style.dimensions[DIMENSION_WIDTH] = 500; addChildren(node_0, 3); { TestCSSNode node_1; @@ -3034,7 +3041,7 @@ public class LayoutEngineTest { node_1.style.flex = 1; node_1 = node_0.getChildAt(1); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.width = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; node_1 = node_0.getChildAt(2); node_1.style.flex = 1; } @@ -3043,28 +3050,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 500; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 500; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 250; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 250; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 250; - node_1.layout.width = 50; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 250; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 250; - node_1.layout.width = 250; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 250; + node_1.layout.dimensions[DIMENSION_WIDTH] = 250; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3089,18 +3096,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3126,18 +3133,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 12; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 12; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3150,17 +3157,17 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 5; + node_0.style.dimensions[DIMENSION_HEIGHT] = 5; node_0.setPadding(Spacing.BOTTOM, 20); } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; } test("should work with height smaller than paddingBottom", root_node, root_layout); @@ -3172,17 +3179,17 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 5; + node_0.style.dimensions[DIMENSION_WIDTH] = 5; node_0.setPadding(Spacing.LEFT, 20); } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 20; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 20; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; } test("should work with width smaller than paddingLeft", root_node, root_layout); @@ -3202,43 +3209,43 @@ public class LayoutEngineTest { { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 400; + node_2.style.dimensions[DIMENSION_WIDTH] = 400; } node_1 = node_0.getChildAt(1); node_1.style.alignSelf = CSSAlign.STRETCH; - node_1.style.width = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 400; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 400; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 400; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 400; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 400; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 400; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; } node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3268,18 +3275,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 5; - node_1.layout.left = 5; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 5; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3296,34 +3303,34 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 10; - node_1.style.positionTop = 10; + node_1.style.position[POSITION_LEFT] = 10; + node_1.style.position[POSITION_TOP] = 10; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 10; - node_1.layout.left = 10; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3347,25 +3354,25 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 5; + node_1.style.position[POSITION_LEFT] = 5; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 40; - node_0.layout.height = 40; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 40; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 40; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 20; - node_1.layout.left = 5; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 20; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3384,25 +3391,25 @@ public class LayoutEngineTest { node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; node_1.setMargin(Spacing.TOP, 5); - node_1.style.positionTop = 5; + node_1.style.position[POSITION_TOP] = 5; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 10; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3421,25 +3428,25 @@ public class LayoutEngineTest { node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; node_1.setMargin(Spacing.LEFT, 5); - node_1.style.positionLeft = 5; + node_1.style.position[POSITION_LEFT] = 5; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 10; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3453,7 +3460,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.SPACE_AROUND; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3466,23 +3473,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3497,7 +3504,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.SPACE_AROUND; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3510,23 +3517,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3540,7 +3547,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 1); { TestCSSNode node_1; @@ -3553,18 +3560,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 5; - node_1.layout.width = 695; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 695; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3579,7 +3586,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 1); { TestCSSNode node_1; @@ -3592,18 +3599,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 695; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 695; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3617,7 +3624,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3632,23 +3639,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 347.5f; - node_1.layout.width = 352.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 347.5f; + node_1.layout.dimensions[DIMENSION_WIDTH] = 352.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3663,7 +3670,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3678,23 +3685,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 352.5f; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 352.5f; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 352.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 352.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3708,7 +3715,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3723,23 +3730,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 352.5f; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 352.5f; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3754,7 +3761,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 700; + node_0.style.dimensions[DIMENSION_WIDTH] = 700; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3769,23 +3776,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 700; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 700; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 352.5f; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 352.5f; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 347.5f; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 347.5f; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3798,12 +3805,12 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 300; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 600; + node_1.style.dimensions[DIMENSION_HEIGHT] = 600; node_1 = node_0.getChildAt(1); node_1.style.flex = 1; } @@ -3812,23 +3819,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 300; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 300; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 600; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 600; node_1 = node_0.getChildAt(1); - node_1.layout.top = 600; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 600; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3842,7 +3849,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 600; + node_0.style.dimensions[DIMENSION_WIDTH] = 600; addChildren(node_0, 1); { TestCSSNode node_1; @@ -3855,18 +3862,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 600; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 600; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3881,7 +3888,7 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 600; + node_0.style.dimensions[DIMENSION_WIDTH] = 600; addChildren(node_0, 1); { TestCSSNode node_1; @@ -3894,18 +3901,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 600; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 600; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 600; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 600; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3918,7 +3925,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 500; + node_0.style.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_0, 2); { TestCSSNode node_1; @@ -3933,23 +3940,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 500; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 500; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 500; node_1 = node_0.getChildAt(1); - node_1.layout.top = 500; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 500; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -3973,10 +3980,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 10; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 10; } test("should layout node with borderWidth", root_node, root_layout); @@ -3994,25 +4001,25 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionTop = -1; + node_1.style.position[POSITION_TOP] = -1; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 1; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4036,25 +4043,25 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 5; + node_1.style.position[POSITION_LEFT] = 5; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 2; - node_0.layout.height = 2; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 2; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 2; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 1; - node_1.layout.left = 6; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 1; + node_1.layout.position[POSITION_LEFT] = 6; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4067,7 +4074,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 50; + node_0.style.dimensions[DIMENSION_WIDTH] = 50; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4086,18 +4093,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 50; - node_0.layout.height = 40; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 50; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 40; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 20; - node_1.layout.width = 40; - node_1.layout.height = 40; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 20; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 40; } } @@ -4110,7 +4117,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = -31; + node_0.style.dimensions[DIMENSION_WIDTH] = -31; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4122,18 +4129,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 5; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 5; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 5; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 5; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4159,18 +4166,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4197,18 +4204,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 1; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 1; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4228,10 +4235,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 35; - node_0.layout.height = 18; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 35; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 18; } test("should layout node with just text", root_node, root_layout); @@ -4243,7 +4250,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 10; + node_0.style.dimensions[DIMENSION_WIDTH] = 10; node_0.setMeasureFunction(sTestMeasureFunction); node_0.context = "small"; } @@ -4251,10 +4258,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 10; - node_0.layout.height = 18; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 10; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 18; } test("should layout node with text and width", root_node, root_layout); @@ -4273,10 +4280,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 172; - node_0.layout.height = 18; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 172; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 18; } test("should layout node with text, padding and margin", root_node, root_layout); @@ -4288,7 +4295,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 300; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4306,26 +4313,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 300; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 300; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 300; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; } } } @@ -4344,7 +4351,7 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flexDirection = CSSFlexDirection.ROW; - node_1.style.width = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; addChildren(node_1, 1); { TestCSSNode node_2; @@ -4359,26 +4366,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 500; - node_0.layout.height = 18; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 500; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 18; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 18; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 18; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 500; - node_2.layout.height = 18; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 500; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 18; } } } @@ -4398,7 +4405,7 @@ public class LayoutEngineTest { node_1 = node_0.getChildAt(0); node_1.style.direction = CSSDirection.RTL; node_1.style.flexDirection = CSSFlexDirection.ROW; - node_1.style.width = 500; + node_1.style.dimensions[DIMENSION_WIDTH] = 500; addChildren(node_1, 1); { TestCSSNode node_2; @@ -4413,26 +4420,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 500; - node_0.layout.height = 18; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 500; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 18; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 500; - node_1.layout.height = 18; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 18; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 500; - node_2.layout.height = 18; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 500; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 18; } } } @@ -4446,7 +4453,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 130; + node_0.style.dimensions[DIMENSION_WIDTH] = 130; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4466,26 +4473,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 130; - node_0.layout.height = 36; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 130; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 130; - node_1.layout.height = 36; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 130; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 130; - node_2.layout.height = 36; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 130; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 36; } } } @@ -4499,7 +4506,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4510,7 +4517,7 @@ public class LayoutEngineTest { { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 130; + node_2.style.dimensions[DIMENSION_WIDTH] = 130; node_2.setMeasureFunction(sTestMeasureFunction); node_2.context = "loooooooooong with space"; } @@ -4520,26 +4527,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 36; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 36; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 130; - node_2.layout.height = 36; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 130; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 36; } } } @@ -4554,7 +4561,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignSelf = CSSAlign.FLEX_START; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; addChildren(node_0, 1); { TestCSSNode node_1; @@ -4568,18 +4575,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 36; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 36; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 36; } } @@ -4593,7 +4600,7 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignSelf = CSSAlign.FLEX_START; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; node_0.setPadding(Spacing.LEFT, 10); node_0.setPadding(Spacing.TOP, 10); node_0.setPadding(Spacing.RIGHT, 10); @@ -4624,26 +4631,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 76; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 76; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 20; - node_1.layout.left = 20; - node_1.layout.width = 100; - node_1.layout.height = 36; + node_1.layout.position[POSITION_TOP] = 20; + node_1.layout.position[POSITION_LEFT] = 20; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 36; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 100; - node_2.layout.height = 36; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 100; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 36; } } } @@ -4658,12 +4665,12 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.justifyContent = CSSJustify.SPACE_BETWEEN; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 900; + node_1.style.dimensions[DIMENSION_HEIGHT] = 900; node_1 = node_0.getChildAt(1); } } @@ -4671,23 +4678,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 900; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 900; node_1 = node_0.getChildAt(1); - node_1.layout.top = 900; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 900; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4702,12 +4709,12 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.justifyContent = CSSJustify.SPACE_BETWEEN; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 900; + node_1.style.dimensions[DIMENSION_HEIGHT] = 900; node_1 = node_0.getChildAt(1); } } @@ -4715,23 +4722,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = -800; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 900; + node_1.layout.position[POSITION_TOP] = -800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 900; node_1 = node_0.getChildAt(1); - node_1.layout.top = -800; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = -800; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4746,30 +4753,30 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 900; + node_1.style.dimensions[DIMENSION_WIDTH] = 900; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = -700; - node_1.layout.width = 900; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = -700; + node_1.layout.dimensions[DIMENSION_WIDTH] = 900; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4785,30 +4792,30 @@ public class LayoutEngineTest { node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; node_0.style.justifyContent = CSSJustify.FLEX_END; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 900; + node_1.style.dimensions[DIMENSION_WIDTH] = 900; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 900; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 900; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -4826,7 +4833,7 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flexDirection = CSSFlexDirection.ROW; - node_1.style.width = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_1, 1); { TestCSSNode node_2; @@ -4846,26 +4853,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 58; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 58; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 58; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 58; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 20; - node_2.layout.left = 20; - node_2.layout.width = 172; - node_2.layout.height = 18; + node_2.layout.position[POSITION_TOP] = 20; + node_2.layout.position[POSITION_LEFT] = 20; + node_2.layout.dimensions[DIMENSION_WIDTH] = 172; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 18; } } } @@ -4885,7 +4892,7 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.flexDirection = CSSFlexDirection.ROW; - node_1.style.width = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_1, 1); { TestCSSNode node_2; @@ -4905,26 +4912,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 58; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 58; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 58; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 58; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 20; - node_2.layout.left = 8; - node_2.layout.width = 172; - node_2.layout.height = 18; + node_2.layout.position[POSITION_TOP] = 20; + node_2.layout.position[POSITION_LEFT] = 8; + node_2.layout.dimensions[DIMENSION_WIDTH] = 172; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 18; } } } @@ -4942,7 +4949,7 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_1, 1); { TestCSSNode node_2; @@ -4962,26 +4969,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 76; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 76; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 76; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 76; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 20; - node_2.layout.left = 20; - node_2.layout.width = 160; - node_2.layout.height = 36; + node_2.layout.position[POSITION_TOP] = 20; + node_2.layout.position[POSITION_LEFT] = 20; + node_2.layout.dimensions[DIMENSION_WIDTH] = 160; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 36; } } } @@ -4995,35 +5002,35 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 0; - node_1.style.positionTop = 0; - node_1.style.positionRight = 0; - node_1.style.positionBottom = 0; + node_1.style.position[POSITION_LEFT] = 0; + node_1.style.position[POSITION_TOP] = 0; + node_1.style.position[POSITION_RIGHT] = 0; + node_1.style.position[POSITION_BOTTOM] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -5037,8 +5044,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignSelf = CSSAlign.FLEX_START; - node_0.style.width = 100; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; @@ -5054,23 +5061,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 25; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 25; node_1 = node_0.getChildAt(1); - node_1.layout.top = 25; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 75; + node_1.layout.position[POSITION_TOP] = 25; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 75; } } @@ -5085,8 +5092,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignSelf = CSSAlign.FLEX_START; - node_0.style.width = 100; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; @@ -5102,23 +5109,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 75; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 25; + node_1.layout.position[POSITION_TOP] = 75; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 25; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 75; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 75; } } @@ -5133,8 +5140,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.COLUMN_REVERSE; node_0.style.alignSelf = CSSAlign.FLEX_START; - node_0.style.width = 100; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; @@ -5150,23 +5157,23 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5183,35 +5190,35 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 50; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 0; - node_1.style.positionRight = 0; + node_1.style.position[POSITION_LEFT] = 0; + node_1.style.position[POSITION_RIGHT] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 50; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 50; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 50; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 50; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5224,32 +5231,32 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionTop = 0; - node_1.style.positionBottom = 20; + node_1.style.position[POSITION_TOP] = 0; + node_1.style.position[POSITION_BOTTOM] = 20; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 80; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 80; } } @@ -5262,24 +5269,24 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.justifyContent = CSSJustify.CENTER; node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionLeft = 0; - node_1.style.positionTop = 0; - node_1.style.positionRight = 0; - node_1.style.positionBottom = 0; + node_1.style.position[POSITION_LEFT] = 0; + node_1.style.position[POSITION_TOP] = 0; + node_1.style.position[POSITION_RIGHT] = 0; + node_1.style.position[POSITION_BOTTOM] = 0; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 100; - node_2.style.height = 100; + node_2.style.dimensions[DIMENSION_WIDTH] = 100; + node_2.style.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -5287,26 +5294,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 50; - node_2.layout.left = 0; - node_2.layout.width = 100; - node_2.layout.height = 100; + node_2.layout.position[POSITION_TOP] = 50; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 100; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 100; } } } @@ -5320,31 +5327,31 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionBottom = 0; + node_1.style.position[POSITION_BOTTOM] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5357,31 +5364,31 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.positionRight = 0; + node_1.style.position[POSITION_RIGHT] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 100; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5394,32 +5401,32 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.height = 10; - node_1.style.positionBottom = 0; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; + node_1.style.position[POSITION_BOTTOM] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 90; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 90; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; } } @@ -5432,32 +5439,32 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.width = 10; - node_1.style.positionRight = 0; + node_1.style.dimensions[DIMENSION_WIDTH] = 10; + node_1.style.position[POSITION_RIGHT] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 90; - node_1.layout.width = 10; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 90; + node_1.layout.dimensions[DIMENSION_WIDTH] = 10; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5475,26 +5482,26 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.height = 10; - node_1.style.positionBottom = 0; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; + node_1.style.position[POSITION_BOTTOM] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = -10; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = -10; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; } } @@ -5512,26 +5519,26 @@ public class LayoutEngineTest { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.positionType = CSSPositionType.ABSOLUTE; - node_1.style.width = 10; - node_1.style.positionRight = 0; + node_1.style.dimensions[DIMENSION_WIDTH] = 10; + node_1.style.position[POSITION_RIGHT] = 0; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = -10; - node_1.layout.width = 10; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = -10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 10; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5556,18 +5563,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 1; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 1; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 1; } } @@ -5592,18 +5599,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = -3; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = -3; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5628,18 +5635,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 20; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 20; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5664,18 +5671,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 5; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 5; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; } } @@ -5688,12 +5695,12 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 800; + node_0.style.dimensions[DIMENSION_WIDTH] = 800; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.positionLeft = 5; + node_1.style.position[POSITION_LEFT] = 5; addChildren(node_1, 1); { TestCSSNode node_2; @@ -5705,26 +5712,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 800; - node_0.layout.height = 0; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 800; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 5; - node_1.layout.width = 800; - node_1.layout.height = 0; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 800; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 0; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 800; - node_2.layout.height = 0; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 800; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 0; } } } @@ -5740,47 +5747,47 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; node_0.style.flexWrap = CSSWrap.WRAP; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(1); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(2); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 40; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 40; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(2); - node_1.layout.top = 10; - node_1.layout.left = 0; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; } } @@ -5796,47 +5803,47 @@ public class LayoutEngineTest { node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; node_0.style.flexWrap = CSSWrap.WRAP; - node_0.style.width = 100; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(1); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(2); - node_1.style.width = 40; - node_1.style.height = 10; + node_1.style.dimensions[DIMENSION_WIDTH] = 40; + node_1.style.dimensions[DIMENSION_HEIGHT] = 10; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 20; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 20; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 60; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 60; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 20; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 20; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; node_1 = node_0.getChildAt(2); - node_1.layout.top = 10; - node_1.layout.left = 60; - node_1.layout.width = 40; - node_1.layout.height = 10; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 60; + node_1.layout.dimensions[DIMENSION_WIDTH] = 40; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 10; } } @@ -5850,37 +5857,37 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexWrap = CSSWrap.WRAP; - node_0.style.height = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.height = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 200; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 0; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 0; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 0; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 0; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -5893,8 +5900,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.maxWidth = 90; node_0.style.maxHeight = 190; } @@ -5902,10 +5909,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 90; - node_0.layout.height = 190; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 90; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 190; } test("should use max bounds", root_node, root_layout); @@ -5917,8 +5924,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.minWidth = 110; node_0.style.minHeight = 210; } @@ -5926,10 +5933,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 110; - node_0.layout.height = 210; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 110; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 210; } test("should use min bounds", root_node, root_layout); @@ -5941,8 +5948,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.maxWidth = 90; node_0.style.maxHeight = 190; node_0.style.minWidth = 110; @@ -5952,10 +5959,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 110; - node_0.layout.height = 210; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 110; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 210; } test("should use min bounds over max bounds", root_node, root_layout); @@ -5967,8 +5974,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.maxWidth = 80; node_0.style.maxHeight = 180; node_0.style.minWidth = 90; @@ -5978,10 +5985,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 90; - node_0.layout.height = 190; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 90; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 190; } test("should use min bounds over max bounds and natural width", root_node, root_layout); @@ -5993,8 +6000,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.minWidth = -10; node_0.style.minHeight = -20; } @@ -6002,10 +6009,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; } test("should ignore negative min bounds", root_node, root_layout); @@ -6017,8 +6024,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 100; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 100; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; node_0.style.maxWidth = -10; node_0.style.maxHeight = -20; } @@ -6026,10 +6033,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; } test("should ignore negative max bounds", root_node, root_layout); @@ -6052,10 +6059,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 40; - node_0.layout.height = 30; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 40; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 30; } test("should use padded size over max bounds", root_node, root_layout); @@ -6078,10 +6085,10 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 50; - node_0.layout.height = 40; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 50; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 40; } test("should use min size over padded size", root_node, root_layout); @@ -6094,8 +6101,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6112,28 +6119,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 50; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 50; - node_1.layout.width = 200; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 50; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 250; - node_1.layout.width = 50; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 250; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6148,8 +6155,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6166,28 +6173,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 250; - node_1.layout.width = 50; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 250; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 50; - node_1.layout.width = 200; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 50; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 50; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6201,8 +6208,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6220,28 +6227,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 100; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 200; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 200; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6256,8 +6263,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6275,28 +6282,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 200; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 200; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 100; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6310,8 +6317,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6328,28 +6335,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 120; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 120; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 180; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 180; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6364,8 +6371,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6382,28 +6389,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 180; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 180; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 120; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 120; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6417,8 +6424,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6437,28 +6444,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 60; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 60; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 120; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 120; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6473,8 +6480,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6493,28 +6500,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 240; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 240; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 180; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 180; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 120; - node_1.layout.width = 60; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 120; + node_1.layout.dimensions[DIMENSION_WIDTH] = 60; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6528,8 +6535,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6548,28 +6555,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 120; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 120; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 240; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 240; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6584,8 +6591,8 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; @@ -6604,28 +6611,28 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 3); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 180; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 180; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 60; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 60; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = -60; - node_1.layout.width = 120; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = -60; + node_1.layout.dimensions[DIMENSION_WIDTH] = 120; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6638,8 +6645,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; @@ -6653,18 +6660,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 300; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 300; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6677,8 +6684,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; @@ -6691,18 +6698,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 290; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 290; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6715,8 +6722,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 300; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; @@ -6729,18 +6736,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 310; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 310; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; } } @@ -6761,34 +6768,34 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 600; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 600; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.layout.top = 300; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 300; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; } } @@ -6807,34 +6814,34 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 100; - node_0.layout.height = 500; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 100; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 500; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.layout.top = 300; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 300; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; } } @@ -6853,34 +6860,34 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.style.width = 200; - node_1.style.height = 300; + node_1.style.dimensions[DIMENSION_WIDTH] = 200; + node_1.style.dimensions[DIMENSION_HEIGHT] = 300; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 700; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 700; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; node_1 = node_0.getChildAt(1); - node_1.layout.top = 300; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 300; + node_1.layout.position[POSITION_TOP] = 300; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 300; } } @@ -6894,12 +6901,12 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.STRETCH; - node_0.style.width = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.style.maxWidth = 1100; node_1.style.maxHeight = 110; node_1.style.minWidth = 900; @@ -6910,18 +6917,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 100; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 100; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 1000; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -6935,12 +6942,12 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.STRETCH; - node_0.style.width = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.style.maxWidth = 900; node_1.style.maxHeight = 90; } @@ -6949,18 +6956,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 90; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 90; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 900; - node_1.layout.height = 90; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 900; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 90; } } @@ -6974,12 +6981,12 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.alignItems = CSSAlign.STRETCH; - node_0.style.width = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.style.minWidth = 1100; node_1.style.minHeight = 110; } @@ -6988,18 +6995,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 110; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 110; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 1100; - node_1.layout.height = 110; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 1100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 110; } } @@ -7013,12 +7020,12 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.style.minWidth = 100; node_1.style.minHeight = 110; } @@ -7027,18 +7034,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 110; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 110; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 110; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 110; } } @@ -7053,12 +7060,12 @@ public class LayoutEngineTest { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; node_0.style.flexDirection = CSSFlexDirection.ROW; - node_0.style.width = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.style.minWidth = 100; node_1.style.minHeight = 110; } @@ -7067,18 +7074,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 110; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 110; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 900; - node_1.layout.width = 100; - node_1.layout.height = 110; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 900; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 110; } } @@ -7091,8 +7098,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; @@ -7100,28 +7107,28 @@ public class LayoutEngineTest { node_1.style.positionType = CSSPositionType.ABSOLUTE; node_1.style.maxWidth = 500; node_1.style.maxHeight = 600; - node_1.style.positionLeft = 100; - node_1.style.positionTop = 100; - node_1.style.positionRight = 100; - node_1.style.positionBottom = 100; + node_1.style.position[POSITION_LEFT] = 100; + node_1.style.position[POSITION_TOP] = 100; + node_1.style.position[POSITION_RIGHT] = 100; + node_1.style.position[POSITION_BOTTOM] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 100; - node_1.layout.width = 500; - node_1.layout.height = 600; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 500; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 600; } } @@ -7134,8 +7141,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 1000; - node_0.style.height = 1000; + node_0.style.dimensions[DIMENSION_WIDTH] = 1000; + node_0.style.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; @@ -7143,28 +7150,28 @@ public class LayoutEngineTest { node_1.style.positionType = CSSPositionType.ABSOLUTE; node_1.style.minWidth = 900; node_1.style.minHeight = 1000; - node_1.style.positionLeft = 100; - node_1.style.positionTop = 100; - node_1.style.positionRight = 100; - node_1.style.positionBottom = 100; + node_1.style.position[POSITION_LEFT] = 100; + node_1.style.position[POSITION_TOP] = 100; + node_1.style.position[POSITION_RIGHT] = 100; + node_1.style.position[POSITION_BOTTOM] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 1000; - node_0.layout.height = 1000; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 1000; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 1000; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 100; - node_1.layout.width = 900; - node_1.layout.height = 1000; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 900; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 1000; } } @@ -7177,8 +7184,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 400; - node_0.style.height = 400; + node_0.style.dimensions[DIMENSION_WIDTH] = 400; + node_0.style.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; @@ -7190,19 +7197,19 @@ public class LayoutEngineTest { node_1.setPadding(Spacing.BOTTOM, 10); node_1.setPadding(Spacing.START, 10); node_1.setPadding(Spacing.END, 10); - node_1.style.positionLeft = 100; - node_1.style.positionTop = 100; - node_1.style.positionRight = 100; - node_1.style.positionBottom = 100; + node_1.style.position[POSITION_LEFT] = 100; + node_1.style.position[POSITION_TOP] = 100; + node_1.style.position[POSITION_RIGHT] = 100; + node_1.style.position[POSITION_BOTTOM] = 100; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); node_2.style.positionType = CSSPositionType.ABSOLUTE; - node_2.style.positionLeft = 10; - node_2.style.positionTop = 10; - node_2.style.positionRight = 10; - node_2.style.positionBottom = 10; + node_2.style.position[POSITION_LEFT] = 10; + node_2.style.position[POSITION_TOP] = 10; + node_2.style.position[POSITION_RIGHT] = 10; + node_2.style.position[POSITION_BOTTOM] = 10; } } } @@ -7210,26 +7217,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 400; - node_0.layout.height = 400; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 400; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 100; - node_1.layout.width = 200; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 10; - node_2.layout.left = 10; - node_2.layout.width = 180; - node_2.layout.height = 180; + node_2.layout.position[POSITION_TOP] = 10; + node_2.layout.position[POSITION_LEFT] = 10; + node_2.layout.dimensions[DIMENSION_WIDTH] = 180; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 180; } } } @@ -7243,8 +7250,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 400; - node_0.style.height = 400; + node_0.style.dimensions[DIMENSION_WIDTH] = 400; + node_0.style.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; @@ -7262,19 +7269,19 @@ public class LayoutEngineTest { node_1.setBorder(Spacing.BOTTOM, 1); node_1.setBorder(Spacing.START, 1); node_1.setBorder(Spacing.END, 1); - node_1.style.positionLeft = 100; - node_1.style.positionTop = 100; - node_1.style.positionRight = 100; - node_1.style.positionBottom = 100; + node_1.style.position[POSITION_LEFT] = 100; + node_1.style.position[POSITION_TOP] = 100; + node_1.style.position[POSITION_RIGHT] = 100; + node_1.style.position[POSITION_BOTTOM] = 100; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); node_2.style.positionType = CSSPositionType.ABSOLUTE; - node_2.style.positionLeft = 10; - node_2.style.positionTop = 10; - node_2.style.positionRight = 10; - node_2.style.positionBottom = 10; + node_2.style.position[POSITION_LEFT] = 10; + node_2.style.position[POSITION_TOP] = 10; + node_2.style.position[POSITION_RIGHT] = 10; + node_2.style.position[POSITION_BOTTOM] = 10; } } } @@ -7282,26 +7289,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 400; - node_0.layout.height = 400; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 400; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 100; - node_1.layout.left = 100; - node_1.layout.width = 200; - node_1.layout.height = 200; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 100; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 11; - node_2.layout.left = 11; - node_2.layout.width = 178; - node_2.layout.height = 178; + node_2.layout.position[POSITION_TOP] = 11; + node_2.layout.position[POSITION_LEFT] = 11; + node_2.layout.dimensions[DIMENSION_WIDTH] = 178; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 178; } } } @@ -7315,8 +7322,8 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 400; - node_0.style.height = 400; + node_0.style.dimensions[DIMENSION_WIDTH] = 400; + node_0.style.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; @@ -7333,10 +7340,10 @@ public class LayoutEngineTest { TestCSSNode node_2; node_2 = node_1.getChildAt(0); node_2.style.positionType = CSSPositionType.ABSOLUTE; - node_2.style.positionLeft = 10; - node_2.style.positionTop = 10; - node_2.style.positionRight = 10; - node_2.style.positionBottom = 10; + node_2.style.position[POSITION_LEFT] = 10; + node_2.style.position[POSITION_TOP] = 10; + node_2.style.position[POSITION_RIGHT] = 10; + node_2.style.position[POSITION_BOTTOM] = 10; } } } @@ -7344,26 +7351,26 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 400; - node_0.layout.height = 400; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 400; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 400; - node_1.layout.height = 400; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 400; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 400; addChildren(node_1, 1); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 10; - node_2.layout.left = 10; - node_2.layout.width = 380; - node_2.layout.height = 380; + node_2.layout.position[POSITION_TOP] = 10; + node_2.layout.position[POSITION_LEFT] = 10; + node_2.layout.dimensions[DIMENSION_WIDTH] = 380; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 380; } } } @@ -7378,8 +7385,8 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; - node_0.style.width = 200; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; @@ -7389,11 +7396,11 @@ public class LayoutEngineTest { { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 50; - node_2.style.height = 50; + node_2.style.dimensions[DIMENSION_WIDTH] = 50; + node_2.style.dimensions[DIMENSION_HEIGHT] = 50; node_2 = node_1.getChildAt(1); - node_2.style.width = 50; - node_2.style.height = 50; + node_2.style.dimensions[DIMENSION_WIDTH] = 50; + node_2.style.dimensions[DIMENSION_HEIGHT] = 50; } node_1 = node_0.getChildAt(1); node_1.style.direction = CSSDirection.LTR; @@ -7402,11 +7409,11 @@ public class LayoutEngineTest { { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.style.width = 50; - node_2.style.height = 50; + node_2.style.dimensions[DIMENSION_WIDTH] = 50; + node_2.style.dimensions[DIMENSION_HEIGHT] = 50; node_2 = node_1.getChildAt(1); - node_2.style.width = 50; - node_2.style.height = 50; + node_2.style.dimensions[DIMENSION_WIDTH] = 50; + node_2.style.dimensions[DIMENSION_HEIGHT] = 50; } } } @@ -7414,50 +7421,50 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 2); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 150; - node_2.layout.width = 50; - node_2.layout.height = 50; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 150; + node_2.layout.dimensions[DIMENSION_WIDTH] = 50; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 50; node_2 = node_1.getChildAt(1); - node_2.layout.top = 0; - node_2.layout.left = 100; - node_2.layout.width = 50; - node_2.layout.height = 50; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 100; + node_2.layout.dimensions[DIMENSION_WIDTH] = 50; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 50; } node_1 = node_0.getChildAt(1); - node_1.layout.top = 50; - node_1.layout.left = 0; - node_1.layout.width = 200; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 50; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 200; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_1, 2); { TestCSSNode node_2; node_2 = node_1.getChildAt(0); - node_2.layout.top = 0; - node_2.layout.left = 0; - node_2.layout.width = 50; - node_2.layout.height = 50; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 0; + node_2.layout.dimensions[DIMENSION_WIDTH] = 50; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 50; node_2 = node_1.getChildAt(1); - node_2.layout.top = 0; - node_2.layout.left = 50; - node_2.layout.width = 50; - node_2.layout.height = 50; + node_2.layout.position[POSITION_TOP] = 0; + node_2.layout.position[POSITION_LEFT] = 50; + node_2.layout.dimensions[DIMENSION_WIDTH] = 50; + node_2.layout.dimensions[DIMENSION_HEIGHT] = 50; } } } @@ -7474,72 +7481,72 @@ public class LayoutEngineTest { node_0.style.flexDirection = CSSFlexDirection.ROW; node_0.style.justifyContent = CSSJustify.SPACE_BETWEEN; node_0.style.flexWrap = CSSWrap.WRAP; - node_0.style.width = 320; - node_0.style.height = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 320; + node_0.style.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 6); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(2); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(3); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(4); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(5); - node_1.style.width = 100; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 100; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 320; - node_0.layout.height = 200; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 320; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 200; addChildren(node_0, 6); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(1); - node_1.layout.top = 0; - node_1.layout.left = 110; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 110; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(2); - node_1.layout.top = 0; - node_1.layout.left = 220; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 220; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(3); - node_1.layout.top = 100; - node_1.layout.left = 0; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 0; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(4); - node_1.layout.top = 100; - node_1.layout.left = 110; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 110; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(5); - node_1.layout.top = 100; - node_1.layout.left = 220; - node_1.layout.width = 100; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 100; + node_1.layout.position[POSITION_LEFT] = 220; + node_1.layout.dimensions[DIMENSION_WIDTH] = 100; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; } } @@ -7552,7 +7559,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setPadding(Spacing.LEFT, 5); node_0.setPadding(Spacing.RIGHT, 5); node_0.setPadding(Spacing.START, 15); @@ -7561,25 +7568,25 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 170; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 170; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7592,12 +7599,12 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 5); node_1.setMargin(Spacing.RIGHT, 5); node_1.setMargin(Spacing.START, 15); @@ -7608,18 +7615,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 170; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 170; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7632,7 +7639,7 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setBorder(Spacing.LEFT, 5); node_0.setBorder(Spacing.RIGHT, 5); node_0.setBorder(Spacing.START, 15); @@ -7641,25 +7648,25 @@ public class LayoutEngineTest { { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 170; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 170; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7672,32 +7679,32 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setPadding(Spacing.START, 15); node_0.setPadding(Spacing.END, 5); addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7711,32 +7718,32 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setPadding(Spacing.START, 15); node_0.setPadding(Spacing.END, 5); addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 5; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7749,12 +7756,12 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.START, 15); node_1.setMargin(Spacing.END, 5); } @@ -7763,18 +7770,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7787,13 +7794,13 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); node_1.style.direction = CSSDirection.RTL; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.START, 15); node_1.setMargin(Spacing.END, 5); } @@ -7802,18 +7809,18 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 5; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7826,32 +7833,32 @@ public class LayoutEngineTest { TestCSSNode root_node = new TestCSSNode(); { TestCSSNode node_0 = root_node; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setBorder(Spacing.START, 15); node_0.setBorder(Spacing.END, 5); addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 15; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 15; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7865,32 +7872,32 @@ public class LayoutEngineTest { { TestCSSNode node_0 = root_node; node_0.style.direction = CSSDirection.RTL; - node_0.style.width = 200; + node_0.style.dimensions[DIMENSION_WIDTH] = 200; node_0.setBorder(Spacing.START, 15); node_0.setBorder(Spacing.END, 5); addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; } } TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 200; - node_0.layout.height = 50; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 200; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 50; addChildren(node_0, 1); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 0; - node_1.layout.left = 5; - node_1.layout.width = 180; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 0; + node_1.layout.position[POSITION_LEFT] = 5; + node_1.layout.dimensions[DIMENSION_WIDTH] = 180; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } @@ -7907,14 +7914,14 @@ public class LayoutEngineTest { node_0.style.alignContent = CSSAlign.STRETCH; node_0.style.alignItems = CSSAlign.FLEX_START; node_0.style.flexWrap = CSSWrap.WRAP; - node_0.style.width = 300; - node_0.style.height = 380; + node_0.style.dimensions[DIMENSION_WIDTH] = 300; + node_0.style.dimensions[DIMENSION_HEIGHT] = 380; addChildren(node_0, 15); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7922,8 +7929,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(1); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7931,8 +7938,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(2); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7940,8 +7947,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(3); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7949,8 +7956,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(4); - node_1.style.width = 50; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7959,8 +7966,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(5); node_1.style.alignSelf = CSSAlign.FLEX_START; - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7968,8 +7975,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(6); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7977,8 +7984,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(7); - node_1.style.width = 50; - node_1.style.height = 100; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 100; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7986,8 +7993,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(8); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -7995,8 +8002,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(9); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8005,8 +8012,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(10); node_1.style.alignSelf = CSSAlign.FLEX_START; - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8014,8 +8021,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(11); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8023,8 +8030,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(12); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8033,8 +8040,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(13); node_1.style.alignSelf = CSSAlign.FLEX_START; - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8042,8 +8049,8 @@ public class LayoutEngineTest { node_1.setMargin(Spacing.START, 10); node_1.setMargin(Spacing.END, 10); node_1 = node_0.getChildAt(14); - node_1.style.width = 50; - node_1.style.height = 50; + node_1.style.dimensions[DIMENSION_WIDTH] = 50; + node_1.style.dimensions[DIMENSION_HEIGHT] = 50; node_1.setMargin(Spacing.LEFT, 10); node_1.setMargin(Spacing.TOP, 10); node_1.setMargin(Spacing.RIGHT, 10); @@ -8056,88 +8063,88 @@ public class LayoutEngineTest { TestCSSNode root_layout = new TestCSSNode(); { TestCSSNode node_0 = root_layout; - node_0.layout.top = 0; - node_0.layout.left = 0; - node_0.layout.width = 300; - node_0.layout.height = 380; + node_0.layout.position[POSITION_TOP] = 0; + node_0.layout.position[POSITION_LEFT] = 0; + node_0.layout.dimensions[DIMENSION_WIDTH] = 300; + node_0.layout.dimensions[DIMENSION_HEIGHT] = 380; addChildren(node_0, 15); { TestCSSNode node_1; node_1 = node_0.getChildAt(0); - node_1.layout.top = 10; - node_1.layout.left = 10; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(1); - node_1.layout.top = 10; - node_1.layout.left = 80; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 80; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(2); - node_1.layout.top = 10; - node_1.layout.left = 150; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 150; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(3); - node_1.layout.top = 10; - node_1.layout.left = 220; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 10; + node_1.layout.position[POSITION_LEFT] = 220; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(4); - node_1.layout.top = 92.5f; - node_1.layout.left = 10; - node_1.layout.width = 50; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 92.5f; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(5); - node_1.layout.top = 92.5f; - node_1.layout.left = 80; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 92.5f; + node_1.layout.position[POSITION_LEFT] = 80; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(6); - node_1.layout.top = 92.5f; - node_1.layout.left = 150; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 92.5f; + node_1.layout.position[POSITION_LEFT] = 150; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(7); - node_1.layout.top = 92.5f; - node_1.layout.left = 220; - node_1.layout.width = 50; - node_1.layout.height = 100; + node_1.layout.position[POSITION_TOP] = 92.5f; + node_1.layout.position[POSITION_LEFT] = 220; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 100; node_1 = node_0.getChildAt(8); - node_1.layout.top = 225; - node_1.layout.left = 10; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 225; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(9); - node_1.layout.top = 225; - node_1.layout.left = 80; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 225; + node_1.layout.position[POSITION_LEFT] = 80; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(10); - node_1.layout.top = 225; - node_1.layout.left = 150; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 225; + node_1.layout.position[POSITION_LEFT] = 150; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(11); - node_1.layout.top = 225; - node_1.layout.left = 220; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 225; + node_1.layout.position[POSITION_LEFT] = 220; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(12); - node_1.layout.top = 307.5f; - node_1.layout.left = 10; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 307.5f; + node_1.layout.position[POSITION_LEFT] = 10; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(13); - node_1.layout.top = 307.5f; - node_1.layout.left = 80; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 307.5f; + node_1.layout.position[POSITION_LEFT] = 80; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; node_1 = node_0.getChildAt(14); - node_1.layout.top = 307.5f; - node_1.layout.left = 150; - node_1.layout.width = 50; - node_1.layout.height = 50; + node_1.layout.position[POSITION_TOP] = 307.5f; + node_1.layout.position[POSITION_LEFT] = 150; + node_1.layout.dimensions[DIMENSION_WIDTH] = 50; + node_1.layout.dimensions[DIMENSION_HEIGHT] = 50; } } diff --git a/src/transpile.js b/src/transpile.js index 32727bfe..e343ac51 100644 --- a/src/transpile.js +++ b/src/transpile.js @@ -261,6 +261,7 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/node\./g, 'node->') .replace(/child\./g, 'child->') .replace(/parent\./g, 'parent->') + .replace(/var\/\*\(c\)!([^*]+)\*\//g, '$1') .replace(/var\/\*([^\/]+)\*\//g, '$1') .replace(/ === /g, ' == ') .replace(/ !== /g, ' != ') From 1ab785b7a385feca5547b83e7f3dcd02abcd756b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 2 Sep 2015 20:24:26 +0100 Subject: [PATCH 02/11] Inline immutable values in layout algorithm Store immutable values from the node being laid out to avoid unnecessary method invocations during layout calculation. This gives us a 3%-5% performance boost in my benchmarks on Android. --- src/JavaTranspiler.js | 5 +- src/Layout.c | 161 +++++++++--------- src/Layout.js | 131 +++++++------- .../com/facebook/csslayout/LayoutEngine.java | 161 +++++++++--------- src/transpile.js | 3 + 5 files changed, 236 insertions(+), 225 deletions(-) diff --git a/src/JavaTranspiler.js b/src/JavaTranspiler.js index 1c888bc5..46b18d97 100644 --- a/src/JavaTranspiler.js +++ b/src/JavaTranspiler.js @@ -12,6 +12,7 @@ function __transpileToJavaCommon(code) { .replace(/CSS_UNDEFINED/g, 'CSSConstants.UNDEFINED') .replace(/CSS_JUSTIFY_/g, 'CSSJustify.') .replace(/CSS_ALIGN_/g, 'CSSAlign.') + .replace(/CSS_POSITION_/g, 'CSSPositionType.') .replace(/css_flex_direction_t/g, 'CSSFlexDirection') .replace(/css_direction_t/g, 'CSSDirection') .replace(/css_align_t/g, 'CSSAlign') @@ -25,6 +26,9 @@ function __transpileToJavaCommon(code) { .replace(/layout\[pos/g, 'layout.position[pos') .replace(/layout\[leading/g, 'layout.position[leading') .replace(/layout\[trailing/g, 'layout.position[trailing') + .replace(/getPositionType\((.+?)\)/g, '$1.style.positionType') + .replace(/getJustifyContent\((.+?)\)/g, '$1.style.justifyContent') + .replace(/getAlignContent\((.+?)\)/g, '$1.style.alignContent') .replace(/\/\*\(c\)!([^*]+)\*\//g, '') .replace(/var\/\*\(java\)!([^*]+)\*\//g, '$1') .replace(/\/\*\(java\)!([^*]+)\*\//g, '$1') @@ -35,7 +39,6 @@ function __transpileSingleTestToJava(code) { .replace(/CSS_DIRECTION_/g, 'CSSDirection.') .replace(/CSS_FLEX_DIRECTION_/g, 'CSSFlexDirection.') .replace(/CSS_WRAP/g, 'CSSWrap.WRAP') - .replace(/CSS_POSITION_/g, 'CSSPositionType.') .replace(/new_test_css_node/g, 'new TestCSSNode') .replace( // style.position[CSS_TOP] => style.position[CSSLayout.POSITION_TOP] /(style|layout)\.position\[CSS_(LEFT|TOP|RIGHT|BOTTOM)\]/g, diff --git a/src/Layout.c b/src/Layout.c index c4da1d7e..4e8d9862 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -376,18 +376,6 @@ static float getPaddingAndBorderAxis(css_node_t *node, css_flex_direction_t axis return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis); } -static css_position_type_t getPositionType(css_node_t *node) { - return node->style.position_type; -} - -static css_justify_t getJustifyContent(css_node_t *node) { - return node->style.justify_content; -} - -static css_align_t getAlignContent(css_node_t *node) { - return node->style.align_content; -} - static css_align_t getAlignItem(css_node_t *node, css_node_t *child) { if (child->style.align_self != CSS_ALIGN_AUTO) { return child->style.align_self; @@ -435,7 +423,7 @@ static float getFlex(css_node_t *node) { static bool isFlex(css_node_t *node) { return ( - getPositionType(node) == CSS_POSITION_RELATIVE && + node->style.position_type == CSS_POSITION_RELATIVE && getFlex(node) > 0 ); } @@ -553,23 +541,29 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction node->layout.position[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) + getRelativePosition(node, crossAxis); + // Inline immutable values from the target node to avoid excessive method + // invocations during the layout calculation. + int childCount = node->children_count; + float paddingAndBorderAxisResolvedRow = getPaddingAndBorderAxis(node, resolvedRowAxis); + if (isMeasureDefined(node)) { + bool isResolvedRowDimDefined = !isUndefined(node->layout.dimensions[dim[resolvedRowAxis]]); + float width = CSS_UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { width = node->style.dimensions[CSS_WIDTH]; - } else if (!isUndefined(node->layout.dimensions[dim[resolvedRowAxis]])) { + } else if (isResolvedRowDimDefined) { width = node->layout.dimensions[dim[resolvedRowAxis]]; } else { width = parentMaxWidth - getMarginAxis(node, resolvedRowAxis); } - width -= getPaddingAndBorderAxis(node, resolvedRowAxis); + width -= paddingAndBorderAxisResolvedRow; // We only need to give a dimension for the text if we haven't got any // for it computed yet. It can either be from the style attribute or because // the element is flexible. - bool isRowUndefined = !isDimDefined(node, resolvedRowAxis) && - isUndefined(node->layout.dimensions[dim[resolvedRowAxis]]); + bool isRowUndefined = !isDimDefined(node, resolvedRowAxis) && !isResolvedRowDimDefined; bool isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) && isUndefined(node->layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]); @@ -582,40 +576,50 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction ); if (isRowUndefined) { node->layout.dimensions[CSS_WIDTH] = measureDim.dimensions[CSS_WIDTH] + - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } if (isColumnUndefined) { node->layout.dimensions[CSS_HEIGHT] = measureDim.dimensions[CSS_HEIGHT] + getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN); } } - if (node->children_count == 0) { + if (childCount == 0) { return; } } + bool isNodeFlexWrap = isFlexWrap(node); + + float leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); + float leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); + float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); + float paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis); + + bool isMainDimDefined = !isUndefined(node->layout.dimensions[dim[mainAxis]]); + bool isCrossDimDefined = !isUndefined(node->layout.dimensions[dim[crossAxis]]); + bool isMainRowDirection = isRowDirection(mainAxis); + int i; int ii; css_node_t* child; css_flex_direction_t axis; // Pre-fill some dimensions straight from the parent - for (i = 0; i < node->children_count; ++i) { + for (i = 0; i < childCount; ++i) { child = node->get_child(node->context, i); // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) == CSS_ALIGN_STRETCH && - getPositionType(child) == CSS_POSITION_RELATIVE && - !isUndefined(node->layout.dimensions[dim[crossAxis]]) && + child->style.position_type == CSS_POSITION_RELATIVE && + isCrossDimDefined && !isDimDefined(child, crossAxis)) { child->layout.dimensions[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, node->layout.dimensions[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); - } else if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { + } else if (child->style.position_type == CSS_POSITION_ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { @@ -639,9 +643,8 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } float definedMainDim = CSS_UNDEFINED; - if (!isUndefined(node->layout.dimensions[dim[mainAxis]])) { - definedMainDim = node->layout.dimensions[dim[mainAxis]] - - getPaddingAndBorderAxis(node, mainAxis); + if (isMainDimDefined) { + definedMainDim = node->layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; } // We want to execute the next two loops one per line with flex-wrap @@ -653,7 +656,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction float linesCrossDim = 0; float linesMainDim = 0; int linesCount = 0; - while (endLine < node->children_count) { + while (endLine < childCount) { // Layout non flexible children and count children by type // mainContentDim is accumulation of the dimensions and margin of all the @@ -669,15 +672,15 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction int nonFlexibleChildrenCount = 0; float maxWidth; - for (i = startLine; i < node->children_count; ++i) { + for (i = startLine; i < childCount; ++i) { child = node->get_child(node->context, i); float nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed // dimension for the node-> - if (!isUndefined(node->layout.dimensions[dim[mainAxis]]) && isFlex(child)) { + if (isMainDimDefined && isFlex(child)) { flexibleChildrenCount++; - totalFlexible += getFlex(child); + totalFlexible += child->style.flex; // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents @@ -688,14 +691,14 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } else { maxWidth = CSS_UNDEFINED; - if (!isRowDirection(mainAxis)) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); - + if (!isMainRowDirection) { if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node->layout.dimensions[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; + } else { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } } @@ -706,7 +709,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // Absolute positioned elements do not take part of the layout, so we // don't use them to compute mainContentDim - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child->style.position_type == CSS_POSITION_RELATIVE) { nonFlexibleChildrenCount++; // At this point we know the final size and margin of the element. nextContentDim = getDimWithMargin(child, mainAxis); @@ -714,8 +717,8 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } // The element we are about to add would make us go to the next line - if (isFlexWrap(node) && - !isUndefined(node->layout.dimensions[dim[mainAxis]]) && + if (isNodeFlexWrap && + isMainDimDefined && mainContentDim + nextContentDim > definedMainDim && // If there's only one element, then it's bigger than the content // and needs its own line @@ -739,7 +742,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // The remaining available space that needs to be allocated float remainingMainDim = 0; - if (!isUndefined(node->layout.dimensions[dim[mainAxis]])) { + if (isMainDimDefined) { remainingMainDim = definedMainDim - mainContentDim; } else { remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim; @@ -758,13 +761,13 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction for (i = startLine; i < endLine; ++i) { child = node->get_child(node->context, i); if (isFlex(child)) { - baseMainDim = flexibleMainDim * getFlex(child) + + baseMainDim = flexibleMainDim * child->style.flex + getPaddingAndBorderAxis(child, mainAxis); boundMainDim = boundAxis(child, mainAxis, baseMainDim); if (baseMainDim != boundMainDim) { remainingMainDim -= boundMainDim; - totalFlexible -= getFlex(child); + totalFlexible -= child->style.flex; } } } @@ -784,17 +787,17 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // At this point we know the final size of the element in the main // dimension child->layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis) + flexibleMainDim * child->style.flex + getPaddingAndBorderAxis(child, mainAxis) ); maxWidth = CSS_UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node->layout.dimensions[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); - } else if (!isRowDirection(mainAxis)) { + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { maxWidth = parentMaxWidth - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } // And we recursively call the layout algorithm for this child @@ -805,7 +808,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // We use justifyContent to figure out how to allocate the remaining // space available } else { - css_justify_t justifyContent = getJustifyContent(node); + css_justify_t justifyContent = node->style.justify_content; if (justifyContent == CSS_JUSTIFY_CENTER) { leadingMainDim = remainingMainDim / 2; } else if (justifyContent == CSS_JUSTIFY_FLEX_END) { @@ -833,14 +836,13 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // variables that are also useful to compute the total dimensions of the // container! float crossDim = 0; - float mainDim = leadingMainDim + - getLeadingPaddingAndBorder(node, mainAxis); + float mainDim = leadingMainDim + leadingPaddingAndBorderMain; for (i = startLine; i < endLine; ++i) { child = node->get_child(node->context, i); child->line_index = linesCount; - if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + if (child->style.position_type == CSS_POSITION_ABSOLUTE && isPosDefined(child, leading[mainAxis])) { // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said @@ -854,7 +856,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction child->layout.position[pos[mainAxis]] += mainDim; // Define the trailing position accordingly. - if (!isUndefined(node->layout.dimensions[dim[mainAxis]])) { + if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } } @@ -862,7 +864,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // Now that we placed the element, we need to update the variables // We only need to do that for relative elements. Absolute elements // do not take part in that phase. - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child->style.position_type == CSS_POSITION_RELATIVE) { // The main dimension is the sum of all the elements dimension plus // the spacing. mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); @@ -873,13 +875,13 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } float containerCrossAxis = node->layout.dimensions[dim[crossAxis]]; - if (isUndefined(node->layout.dimensions[dim[crossAxis]])) { + if (!isCrossDimDefined) { containerCrossAxis = fmaxf( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, crossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); } @@ -887,7 +889,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction for (i = startLine; i < endLine; ++i) { child = node->get_child(node->context, i); - if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + if (child->style.position_type == CSS_POSITION_ABSOLUTE && isPosDefined(child, leading[crossAxis])) { // In case the child is absolutely positionned and has a // top/left/bottom/right being set, we override all the previously @@ -897,11 +899,11 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction getLeadingMargin(child, crossAxis); } else { - float leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis); + float leadingCrossDim = leadingPaddingAndBorderCross; // For a relative children, we're either using alignItems (parent) or // alignSelf (child) in order to determine the position in the cross axis - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child->style.position_type == CSS_POSITION_RELATIVE) { css_align_t alignItem = getAlignItem(node, child); if (alignItem == CSS_ALIGN_STRETCH) { // You can only stretch if the dimension has not already been set @@ -909,8 +911,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction if (!isDimDefined(child, crossAxis)) { child->layout.dimensions[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); @@ -919,8 +920,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // The remaining space between the parent dimensions+padding and child // dimensions+margin. float remainingCrossDim = containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getDimWithMargin(child, crossAxis); + paddingAndBorderAxisCross - getDimWithMargin(child, crossAxis); if (alignItem == CSS_ALIGN_CENTER) { leadingCrossDim += remainingCrossDim / 2; @@ -934,7 +934,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction child->layout.position[pos[crossAxis]] += linesCrossDim + leadingCrossDim; // Define the trailing position accordingly. - if (!isUndefined(node->layout.dimensions[dim[crossAxis]])) { + if (isCrossDimDefined) { setTrailingPosition(node, child, crossAxis); } } @@ -959,16 +959,15 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm // section 9.4 // - if (linesCount > 1 && - !isUndefined(node->layout.dimensions[dim[crossAxis]])) { + if (linesCount > 1 && isCrossDimDefined) { float nodeCrossAxisInnerSize = node->layout.dimensions[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis); + paddingAndBorderAxisCross; float remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim; float crossDimLead = 0; - float currentLead = getLeadingPaddingAndBorder(node, crossAxis); + float currentLead = leadingPaddingAndBorderCross; - css_align_t alignContent = getAlignContent(node); + css_align_t alignContent = node->style.align_content; if (alignContent == CSS_ALIGN_FLEX_END) { currentLead += remainingAlignContentDim; } else if (alignContent == CSS_ALIGN_CENTER) { @@ -985,9 +984,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // compute the line's height and find the endIndex float lineHeight = 0; - for (ii = startIndex; ii < node->children_count; ++ii) { + for (ii = startIndex; ii < childCount; ++ii) { child = node->get_child(node->context, ii); - if (getPositionType(child) != CSS_POSITION_RELATIVE) { + if (child->style.position_type != CSS_POSITION_RELATIVE) { continue; } if (child->line_index != i) { @@ -1005,7 +1004,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction for (ii = startIndex; ii < endIndex; ++ii) { child = node->get_child(node->context, ii); - if (getPositionType(child) != CSS_POSITION_RELATIVE) { + if (child->style.position_type != CSS_POSITION_RELATIVE) { continue; } @@ -1033,25 +1032,25 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // If the user didn't specify a width or height, and it has not been set // by the container, then we set it via the children. - if (isUndefined(node->layout.dimensions[dim[mainAxis]])) { + if (!isMainDimDefined) { node->layout.dimensions[dim[mainAxis]] = fmaxf( // We're missing the last padding at this point to get the final // dimension boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)), // We can never assign a width smaller than the padding and borders - getPaddingAndBorderAxis(node, mainAxis) + paddingAndBorderAxisMain ); needsMainTrailingPos = true; } - if (isUndefined(node->layout.dimensions[dim[crossAxis]])) { + if (!isCrossDimDefined) { node->layout.dimensions[dim[crossAxis]] = fmaxf( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); needsCrossTrailingPos = true; @@ -1059,7 +1058,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // Set trailing position if necessary if (needsMainTrailingPos || needsCrossTrailingPos) { - for (i = 0; i < node->children_count; ++i) { + for (i = 0; i < childCount; ++i) { child = node->get_child(node->context, i); if (needsMainTrailingPos) { @@ -1073,9 +1072,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < node->children_count; ++i) { + for (i = 0; i < childCount; ++i) { child = node->get_child(node->context, i); - if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { + if (child->style.position_type == CSS_POSITION_ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { diff --git a/src/Layout.js b/src/Layout.js index bb9eeb9b..9d8a4abc 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -287,14 +287,10 @@ var computeLayout = (function() { return 'relative'; } - function getFlex(node) { - return node.style.flex; - } - function isFlex(node) { return ( getPositionType(node) === CSS_POSITION_RELATIVE && - getFlex(node) > 0 + node.style.flex > 0 ); } @@ -413,23 +409,29 @@ var computeLayout = (function() { node.layout[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) + getRelativePosition(node, crossAxis); + // Inline immutable values from the target node to avoid excessive method + // invocations during the layout calculation. + var/*int*/ childCount = node.children.length; + var/*float*/ paddingAndBorderAxisResolvedRow = getPaddingAndBorderAxis(node, resolvedRowAxis); + if (isMeasureDefined(node)) { + var/*bool*/ isResolvedRowDimDefined = !isUndefined(node.layout[dim[resolvedRowAxis]]); + var/*float*/ width = CSS_UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { width = node.style.width; - } else if (!isUndefined(node.layout[dim[resolvedRowAxis]])) { + } else if (isResolvedRowDimDefined) { width = node.layout[dim[resolvedRowAxis]]; } else { width = parentMaxWidth - getMarginAxis(node, resolvedRowAxis); } - width -= getPaddingAndBorderAxis(node, resolvedRowAxis); + width -= paddingAndBorderAxisResolvedRow; // We only need to give a dimension for the text if we haven't got any // for it computed yet. It can either be from the style attribute or because // the element is flexible. - var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) && - isUndefined(node.layout[dim[resolvedRowAxis]]); + var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) && !isResolvedRowDimDefined; var/*bool*/ isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) && isUndefined(node.layout[dim[CSS_FLEX_DIRECTION_COLUMN]]); @@ -442,36 +444,46 @@ var computeLayout = (function() { ); if (isRowUndefined) { node.layout.width = measureDim.width + - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } if (isColumnUndefined) { node.layout.height = measureDim.height + getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN); } } - if (node.children.length === 0) { + if (childCount === 0) { return; } } + var/*bool*/ isNodeFlexWrap = isFlexWrap(node); + + var/*float*/ leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); + var/*float*/ leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); + var/*float*/ paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); + var/*float*/ paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis); + + var/*bool*/ isMainDimDefined = !isUndefined(node.layout[dim[mainAxis]]); + var/*bool*/ isCrossDimDefined = !isUndefined(node.layout[dim[crossAxis]]); + var/*bool*/ isMainRowDirection = isRowDirection(mainAxis); + var/*int*/ i; var/*int*/ ii; var/*css_node_t**/ child; var/*(c)!css_flex_direction_t*//*(java)!int*/ axis; // Pre-fill some dimensions straight from the parent - for (i = 0; i < node.children.length; ++i) { + for (i = 0; i < childCount; ++i) { child = node.children[i]; // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) === CSS_ALIGN_STRETCH && getPositionType(child) === CSS_POSITION_RELATIVE && - !isUndefined(node.layout[dim[crossAxis]]) && + isCrossDimDefined && !isDimDefined(child, crossAxis)) { child.layout[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, node.layout[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); @@ -499,9 +511,8 @@ var computeLayout = (function() { } var/*float*/ definedMainDim = CSS_UNDEFINED; - if (!isUndefined(node.layout[dim[mainAxis]])) { - definedMainDim = node.layout[dim[mainAxis]] - - getPaddingAndBorderAxis(node, mainAxis); + if (isMainDimDefined) { + definedMainDim = node.layout[dim[mainAxis]] - paddingAndBorderAxisMain; } // We want to execute the next two loops one per line with flex-wrap @@ -513,7 +524,7 @@ var computeLayout = (function() { var/*float*/ linesCrossDim = 0; var/*float*/ linesMainDim = 0; var/*int*/ linesCount = 0; - while (endLine < node.children.length) { + while (endLine < childCount) { // Layout non flexible children and count children by type // mainContentDim is accumulation of the dimensions and margin of all the @@ -529,15 +540,15 @@ var computeLayout = (function() { var/*int*/ nonFlexibleChildrenCount = 0; var/*float*/ maxWidth; - for (i = startLine; i < node.children.length; ++i) { + for (i = startLine; i < childCount; ++i) { child = node.children[i]; var/*float*/ nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed // dimension for the node. - if (!isUndefined(node.layout[dim[mainAxis]]) && isFlex(child)) { + if (isMainDimDefined && isFlex(child)) { flexibleChildrenCount++; - totalFlexible += getFlex(child); + totalFlexible += child.style.flex; // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents @@ -548,14 +559,14 @@ var computeLayout = (function() { } else { maxWidth = CSS_UNDEFINED; - if (!isRowDirection(mainAxis)) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); - + if (!isMainRowDirection) { if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node.layout[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; + } else { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } } @@ -574,8 +585,8 @@ var computeLayout = (function() { } // The element we are about to add would make us go to the next line - if (isFlexWrap(node) && - !isUndefined(node.layout[dim[mainAxis]]) && + if (isNodeFlexWrap && + isMainDimDefined && mainContentDim + nextContentDim > definedMainDim && // If there's only one element, then it's bigger than the content // and needs its own line @@ -599,7 +610,7 @@ var computeLayout = (function() { // The remaining available space that needs to be allocated var/*float*/ remainingMainDim = 0; - if (!isUndefined(node.layout[dim[mainAxis]])) { + if (isMainDimDefined) { remainingMainDim = definedMainDim - mainContentDim; } else { remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim; @@ -618,13 +629,13 @@ var computeLayout = (function() { for (i = startLine; i < endLine; ++i) { child = node.children[i]; if (isFlex(child)) { - baseMainDim = flexibleMainDim * getFlex(child) + + baseMainDim = flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis); boundMainDim = boundAxis(child, mainAxis, baseMainDim); if (baseMainDim !== boundMainDim) { remainingMainDim -= boundMainDim; - totalFlexible -= getFlex(child); + totalFlexible -= child.style.flex; } } } @@ -644,17 +655,17 @@ var computeLayout = (function() { // At this point we know the final size of the element in the main // dimension child.layout[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis) + flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis) ); maxWidth = CSS_UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node.layout[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); - } else if (!isRowDirection(mainAxis)) { + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { maxWidth = parentMaxWidth - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } // And we recursively call the layout algorithm for this child @@ -693,8 +704,7 @@ var computeLayout = (function() { // variables that are also useful to compute the total dimensions of the // container! var/*float*/ crossDim = 0; - var/*float*/ mainDim = leadingMainDim + - getLeadingPaddingAndBorder(node, mainAxis); + var/*float*/ mainDim = leadingMainDim + leadingPaddingAndBorderMain; for (i = startLine; i < endLine; ++i) { child = node.children[i]; @@ -714,7 +724,7 @@ var computeLayout = (function() { child.layout[pos[mainAxis]] += mainDim; // Define the trailing position accordingly. - if (!isUndefined(node.layout[dim[mainAxis]])) { + if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } } @@ -733,13 +743,13 @@ var computeLayout = (function() { } var/*float*/ containerCrossAxis = node.layout[dim[crossAxis]]; - if (isUndefined(node.layout[dim[crossAxis]])) { + if (!isCrossDimDefined) { containerCrossAxis = fmaxf( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, crossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); } @@ -757,7 +767,7 @@ var computeLayout = (function() { getLeadingMargin(child, crossAxis); } else { - var/*float*/ leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis); + var/*float*/ leadingCrossDim = leadingPaddingAndBorderCross; // For a relative children, we're either using alignItems (parent) or // alignSelf (child) in order to determine the position in the cross axis @@ -769,8 +779,7 @@ var computeLayout = (function() { if (!isDimDefined(child, crossAxis)) { child.layout[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); @@ -779,8 +788,7 @@ var computeLayout = (function() { // The remaining space between the parent dimensions+padding and child // dimensions+margin. var/*float*/ remainingCrossDim = containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getDimWithMargin(child, crossAxis); + paddingAndBorderAxisCross - getDimWithMargin(child, crossAxis); if (alignItem === CSS_ALIGN_CENTER) { leadingCrossDim += remainingCrossDim / 2; @@ -794,7 +802,7 @@ var computeLayout = (function() { child.layout[pos[crossAxis]] += linesCrossDim + leadingCrossDim; // Define the trailing position accordingly. - if (!isUndefined(node.layout[dim[crossAxis]])) { + if (isCrossDimDefined) { setTrailingPosition(node, child, crossAxis); } } @@ -819,14 +827,13 @@ var computeLayout = (function() { // http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm // section 9.4 // - if (linesCount > 1 && - !isUndefined(node.layout[dim[crossAxis]])) { + if (linesCount > 1 && isCrossDimDefined) { var/*float*/ nodeCrossAxisInnerSize = node.layout[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis); + paddingAndBorderAxisCross; var/*float*/ remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim; var/*float*/ crossDimLead = 0; - var/*float*/ currentLead = getLeadingPaddingAndBorder(node, crossAxis); + var/*float*/ currentLead = leadingPaddingAndBorderCross; var/*css_align_t*/ alignContent = getAlignContent(node); if (alignContent === CSS_ALIGN_FLEX_END) { @@ -845,7 +852,7 @@ var computeLayout = (function() { // compute the line's height and find the endIndex var/*float*/ lineHeight = 0; - for (ii = startIndex; ii < node.children.length; ++ii) { + for (ii = startIndex; ii < childCount; ++ii) { child = node.children[ii]; if (getPositionType(child) !== CSS_POSITION_RELATIVE) { continue; @@ -893,25 +900,25 @@ var computeLayout = (function() { // If the user didn't specify a width or height, and it has not been set // by the container, then we set it via the children. - if (isUndefined(node.layout[dim[mainAxis]])) { + if (!isMainDimDefined) { node.layout[dim[mainAxis]] = fmaxf( // We're missing the last padding at this point to get the final // dimension boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)), // We can never assign a width smaller than the padding and borders - getPaddingAndBorderAxis(node, mainAxis) + paddingAndBorderAxisMain ); needsMainTrailingPos = true; } - if (isUndefined(node.layout[dim[crossAxis]])) { + if (!isCrossDimDefined) { node.layout[dim[crossAxis]] = fmaxf( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); needsCrossTrailingPos = true; @@ -919,7 +926,7 @@ var computeLayout = (function() { // Set trailing position if necessary if (needsMainTrailingPos || needsCrossTrailingPos) { - for (i = 0; i < node.children.length; ++i) { + for (i = 0; i < childCount; ++i) { child = node.children[i]; if (needsMainTrailingPos) { @@ -933,7 +940,7 @@ var computeLayout = (function() { } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < node.children.length; ++i) { + for (i = 0; i < childCount; ++i) { child = node.children[i]; if (getPositionType(child) === CSS_POSITION_ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both @@ -981,4 +988,4 @@ var computeLayout = (function() { // the public API. if (typeof exports === 'object') { module.exports = computeLayout; -} \ No newline at end of file +} diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 2b8a5ed8..a4b7baea 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -269,10 +269,6 @@ public class LayoutEngine { } } - private static int getPositionType(CSSNode node) { - return node.style.positionType.ordinal(); - } - private static CSSAlign getAlignItem(CSSNode node, CSSNode child) { if (child.style.alignSelf != CSSAlign.AUTO) { return child.style.alignSelf; @@ -280,20 +276,12 @@ public class LayoutEngine { return node.style.alignItems; } - private static CSSAlign getAlignContent(CSSNode node) { - return node.style.alignContent; - } - - private static CSSJustify getJustifyContent(CSSNode node) { - return node.style.justifyContent; - } - private static boolean isFlexWrap(CSSNode node) { return node.style.flexWrap == CSSWrap.WRAP; } private static boolean isFlex(CSSNode node) { - return getPositionType(node) == CSS_POSITION_RELATIVE && node.style.flex > 0; + return node.style.positionType == CSSPositionType.RELATIVE && node.style.flex > 0; } private static boolean isMeasureDefined(CSSNode node) { @@ -370,23 +358,29 @@ public class LayoutEngine { node.layout.position[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) + getRelativePosition(node, crossAxis); + // Inline immutable values from the target node to avoid excessive method + // invocations during the layout calculation. + int childCount = node.getChildCount(); + float paddingAndBorderAxisResolvedRow = getPaddingAndBorderAxis(node, resolvedRowAxis); + if (isMeasureDefined(node)) { + boolean isResolvedRowDimDefined = !isUndefined(node.layout.dimensions[dim[resolvedRowAxis]]); + float width = CSSConstants.UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { width = node.style.dimensions[DIMENSION_WIDTH]; - } else if (!isUndefined(node.layout.dimensions[dim[resolvedRowAxis]])) { + } else if (isResolvedRowDimDefined) { width = node.layout.dimensions[dim[resolvedRowAxis]]; } else { width = parentMaxWidth - getMarginAxis(node, resolvedRowAxis); } - width -= getPaddingAndBorderAxis(node, resolvedRowAxis); + width -= paddingAndBorderAxisResolvedRow; // We only need to give a dimension for the text if we haven't got any // for it computed yet. It can either be from the style attribute or because // the element is flexible. - boolean isRowUndefined = !isDimDefined(node, resolvedRowAxis) && - isUndefined(node.layout.dimensions[dim[resolvedRowAxis]]); + boolean isRowUndefined = !isDimDefined(node, resolvedRowAxis) && !isResolvedRowDimDefined; boolean isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) && isUndefined(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]); @@ -399,40 +393,50 @@ public class LayoutEngine { ); if (isRowUndefined) { node.layout.dimensions[DIMENSION_WIDTH] = measureDim.width + - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } if (isColumnUndefined) { node.layout.dimensions[DIMENSION_HEIGHT] = measureDim.height + getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN); } } - if (node.getChildCount() == 0) { + if (childCount == 0) { return; } } + boolean isNodeFlexWrap = isFlexWrap(node); + + float leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); + float leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); + float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); + float paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis); + + boolean isMainDimDefined = !isUndefined(node.layout.dimensions[dim[mainAxis]]); + boolean isCrossDimDefined = !isUndefined(node.layout.dimensions[dim[crossAxis]]); + boolean isMainRowDirection = isRowDirection(mainAxis); + int i; int ii; CSSNode child; int axis; // Pre-fill some dimensions straight from the parent - for (i = 0; i < node.getChildCount(); ++i) { + for (i = 0; i < childCount; ++i) { child = node.getChildAt(i); // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) == CSSAlign.STRETCH && - getPositionType(child) == CSS_POSITION_RELATIVE && - !isUndefined(node.layout.dimensions[dim[crossAxis]]) && + child.style.positionType == CSSPositionType.RELATIVE && + isCrossDimDefined && !isDimDefined(child, crossAxis)) { child.layout.dimensions[dim[crossAxis]] = Math.max( boundAxis(child, crossAxis, node.layout.dimensions[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); - } else if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { + } else if (child.style.positionType == CSSPositionType.ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { @@ -456,9 +460,8 @@ public class LayoutEngine { } float definedMainDim = CSSConstants.UNDEFINED; - if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { - definedMainDim = node.layout.dimensions[dim[mainAxis]] - - getPaddingAndBorderAxis(node, mainAxis); + if (isMainDimDefined) { + definedMainDim = node.layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; } // We want to execute the next two loops one per line with flex-wrap @@ -470,7 +473,7 @@ public class LayoutEngine { float linesCrossDim = 0; float linesMainDim = 0; int linesCount = 0; - while (endLine < node.getChildCount()) { + while (endLine < childCount) { // Layout non flexible children and count children by type // mainContentDim is accumulation of the dimensions and margin of all the @@ -486,15 +489,15 @@ public class LayoutEngine { int nonFlexibleChildrenCount = 0; float maxWidth; - for (i = startLine; i < node.getChildCount(); ++i) { + for (i = startLine; i < childCount; ++i) { child = node.getChildAt(i); float nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed // dimension for the node. - if (!isUndefined(node.layout.dimensions[dim[mainAxis]]) && isFlex(child)) { + if (isMainDimDefined && isFlex(child)) { flexibleChildrenCount++; - totalFlexible += getFlex(child); + totalFlexible += child.style.flex; // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents @@ -505,14 +508,14 @@ public class LayoutEngine { } else { maxWidth = CSSConstants.UNDEFINED; - if (!isRowDirection(mainAxis)) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); - + if (!isMainRowDirection) { if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; + } else { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } } @@ -523,7 +526,7 @@ public class LayoutEngine { // Absolute positioned elements do not take part of the layout, so we // don't use them to compute mainContentDim - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child.style.positionType == CSSPositionType.RELATIVE) { nonFlexibleChildrenCount++; // At this point we know the final size and margin of the element. nextContentDim = getDimWithMargin(child, mainAxis); @@ -531,8 +534,8 @@ public class LayoutEngine { } // The element we are about to add would make us go to the next line - if (isFlexWrap(node) && - !isUndefined(node.layout.dimensions[dim[mainAxis]]) && + if (isNodeFlexWrap && + isMainDimDefined && mainContentDim + nextContentDim > definedMainDim && // If there's only one element, then it's bigger than the content // and needs its own line @@ -556,7 +559,7 @@ public class LayoutEngine { // The remaining available space that needs to be allocated float remainingMainDim = 0; - if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { + if (isMainDimDefined) { remainingMainDim = definedMainDim - mainContentDim; } else { remainingMainDim = Math.max(mainContentDim, 0) - mainContentDim; @@ -575,13 +578,13 @@ public class LayoutEngine { for (i = startLine; i < endLine; ++i) { child = node.getChildAt(i); if (isFlex(child)) { - baseMainDim = flexibleMainDim * getFlex(child) + + baseMainDim = flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis); boundMainDim = boundAxis(child, mainAxis, baseMainDim); if (baseMainDim != boundMainDim) { remainingMainDim -= boundMainDim; - totalFlexible -= getFlex(child); + totalFlexible -= child.style.flex; } } } @@ -601,17 +604,17 @@ public class LayoutEngine { // At this point we know the final size of the element in the main // dimension child.layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis) + flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis) ); maxWidth = CSSConstants.UNDEFINED; if (isDimDefined(node, resolvedRowAxis)) { maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - - getPaddingAndBorderAxis(node, resolvedRowAxis); - } else if (!isRowDirection(mainAxis)) { + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { maxWidth = parentMaxWidth - getMarginAxis(node, resolvedRowAxis) - - getPaddingAndBorderAxis(node, resolvedRowAxis); + paddingAndBorderAxisResolvedRow; } // And we recursively call the layout algorithm for this child @@ -622,7 +625,7 @@ public class LayoutEngine { // We use justifyContent to figure out how to allocate the remaining // space available } else { - CSSJustify justifyContent = getJustifyContent(node); + CSSJustify justifyContent = node.style.justifyContent; if (justifyContent == CSSJustify.CENTER) { leadingMainDim = remainingMainDim / 2; } else if (justifyContent == CSSJustify.FLEX_END) { @@ -650,14 +653,13 @@ public class LayoutEngine { // variables that are also useful to compute the total dimensions of the // container! float crossDim = 0; - float mainDim = leadingMainDim + - getLeadingPaddingAndBorder(node, mainAxis); + float mainDim = leadingMainDim + leadingPaddingAndBorderMain; for (i = startLine; i < endLine; ++i) { child = node.getChildAt(i); child.lineIndex = linesCount; - if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + if (child.style.positionType == CSSPositionType.ABSOLUTE && isPosDefined(child, leading[mainAxis])) { // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said @@ -671,7 +673,7 @@ public class LayoutEngine { child.layout.position[pos[mainAxis]] += mainDim; // Define the trailing position accordingly. - if (!isUndefined(node.layout.dimensions[dim[mainAxis]])) { + if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } } @@ -679,7 +681,7 @@ public class LayoutEngine { // Now that we placed the element, we need to update the variables // We only need to do that for relative elements. Absolute elements // do not take part in that phase. - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child.style.positionType == CSSPositionType.RELATIVE) { // The main dimension is the sum of all the elements dimension plus // the spacing. mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); @@ -690,13 +692,13 @@ public class LayoutEngine { } float containerCrossAxis = node.layout.dimensions[dim[crossAxis]]; - if (isUndefined(node.layout.dimensions[dim[crossAxis]])) { + if (!isCrossDimDefined) { containerCrossAxis = Math.max( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, crossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); } @@ -704,7 +706,7 @@ public class LayoutEngine { for (i = startLine; i < endLine; ++i) { child = node.getChildAt(i); - if (getPositionType(child) == CSS_POSITION_ABSOLUTE && + if (child.style.positionType == CSSPositionType.ABSOLUTE && isPosDefined(child, leading[crossAxis])) { // In case the child is absolutely positionned and has a // top/left/bottom/right being set, we override all the previously @@ -714,11 +716,11 @@ public class LayoutEngine { getLeadingMargin(child, crossAxis); } else { - float leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis); + float leadingCrossDim = leadingPaddingAndBorderCross; // For a relative children, we're either using alignItems (parent) or // alignSelf (child) in order to determine the position in the cross axis - if (getPositionType(child) == CSS_POSITION_RELATIVE) { + if (child.style.positionType == CSSPositionType.RELATIVE) { CSSAlign alignItem = getAlignItem(node, child); if (alignItem == CSSAlign.STRETCH) { // You can only stretch if the dimension has not already been set @@ -726,8 +728,7 @@ public class LayoutEngine { if (!isDimDefined(child, crossAxis)) { child.layout.dimensions[dim[crossAxis]] = Math.max( boundAxis(child, crossAxis, containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getMarginAxis(child, crossAxis)), + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), // You never want to go smaller than padding getPaddingAndBorderAxis(child, crossAxis) ); @@ -736,8 +737,7 @@ public class LayoutEngine { // The remaining space between the parent dimensions+padding and child // dimensions+margin. float remainingCrossDim = containerCrossAxis - - getPaddingAndBorderAxis(node, crossAxis) - - getDimWithMargin(child, crossAxis); + paddingAndBorderAxisCross - getDimWithMargin(child, crossAxis); if (alignItem == CSSAlign.CENTER) { leadingCrossDim += remainingCrossDim / 2; @@ -751,7 +751,7 @@ public class LayoutEngine { child.layout.position[pos[crossAxis]] += linesCrossDim + leadingCrossDim; // Define the trailing position accordingly. - if (!isUndefined(node.layout.dimensions[dim[crossAxis]])) { + if (isCrossDimDefined) { setTrailingPosition(node, child, crossAxis); } } @@ -776,16 +776,15 @@ public class LayoutEngine { // http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm // section 9.4 // - if (linesCount > 1 && - !isUndefined(node.layout.dimensions[dim[crossAxis]])) { + if (linesCount > 1 && isCrossDimDefined) { float nodeCrossAxisInnerSize = node.layout.dimensions[dim[crossAxis]] - - getPaddingAndBorderAxis(node, crossAxis); + paddingAndBorderAxisCross; float remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim; float crossDimLead = 0; - float currentLead = getLeadingPaddingAndBorder(node, crossAxis); + float currentLead = leadingPaddingAndBorderCross; - CSSAlign alignContent = getAlignContent(node); + CSSAlign alignContent = node.style.alignContent; if (alignContent == CSSAlign.FLEX_END) { currentLead += remainingAlignContentDim; } else if (alignContent == CSSAlign.CENTER) { @@ -802,9 +801,9 @@ public class LayoutEngine { // compute the line's height and find the endIndex float lineHeight = 0; - for (ii = startIndex; ii < node.getChildCount(); ++ii) { + for (ii = startIndex; ii < childCount; ++ii) { child = node.getChildAt(ii); - if (getPositionType(child) != CSS_POSITION_RELATIVE) { + if (child.style.positionType != CSSPositionType.RELATIVE) { continue; } if (child.lineIndex != i) { @@ -822,7 +821,7 @@ public class LayoutEngine { for (ii = startIndex; ii < endIndex; ++ii) { child = node.getChildAt(ii); - if (getPositionType(child) != CSS_POSITION_RELATIVE) { + if (child.style.positionType != CSSPositionType.RELATIVE) { continue; } @@ -850,25 +849,25 @@ public class LayoutEngine { // If the user didn't specify a width or height, and it has not been set // by the container, then we set it via the children. - if (isUndefined(node.layout.dimensions[dim[mainAxis]])) { + if (!isMainDimDefined) { node.layout.dimensions[dim[mainAxis]] = Math.max( // We're missing the last padding at this point to get the final // dimension boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)), // We can never assign a width smaller than the padding and borders - getPaddingAndBorderAxis(node, mainAxis) + paddingAndBorderAxisMain ); needsMainTrailingPos = true; } - if (isUndefined(node.layout.dimensions[dim[crossAxis]])) { + if (!isCrossDimDefined) { node.layout.dimensions[dim[crossAxis]] = Math.max( // For the cross dim, we add both sides at the end because the value // is aggregate via a max function. Intermediate negative values // can mess this computation otherwise - boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)), - getPaddingAndBorderAxis(node, crossAxis) + boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross), + paddingAndBorderAxisCross ); needsCrossTrailingPos = true; @@ -876,7 +875,7 @@ public class LayoutEngine { // Set trailing position if necessary if (needsMainTrailingPos || needsCrossTrailingPos) { - for (i = 0; i < node.getChildCount(); ++i) { + for (i = 0; i < childCount; ++i) { child = node.getChildAt(i); if (needsMainTrailingPos) { @@ -890,9 +889,9 @@ public class LayoutEngine { } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < node.getChildCount(); ++i) { + for (i = 0; i < childCount; ++i) { child = node.getChildAt(i); - if (getPositionType(child) == CSS_POSITION_ABSOLUTE) { + if (child.style.positionType == CSSPositionType.ABSOLUTE) { // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { diff --git a/src/transpile.js b/src/transpile.js index e343ac51..2f93d154 100644 --- a/src/transpile.js +++ b/src/transpile.js @@ -261,6 +261,9 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/node\./g, 'node->') .replace(/child\./g, 'child->') .replace(/parent\./g, 'parent->') + .replace(/getPositionType\((.+?)\)/g, '$1->style.position_type') + .replace(/getJustifyContent\((.+?)\)/g, '$1->style.justify_content') + .replace(/getAlignContent\((.+?)\)/g, '$1->style.align_content') .replace(/var\/\*\(c\)!([^*]+)\*\//g, '$1') .replace(/var\/\*([^\/]+)\*\//g, '$1') .replace(/ === /g, ' == ') From 877a2838a63136e53c3f0e327507c1b0f41ac479 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 8 Sep 2015 15:33:26 +0100 Subject: [PATCH 03/11] Skip trailing position loop, if possible There's no need to set the trailing position on left-to-right layouts as the nodes will already have what we need (x, y, width, and height). This means we still have an extra cost for reversed layout directions but they are not as common as LTR ones. --- src/Layout.c | 10 ++++++++-- src/Layout.js | 10 ++++++++-- src/java/src/com/facebook/csslayout/LayoutEngine.java | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index 4e8d9862..51311d8e 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -1041,7 +1041,10 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction paddingAndBorderAxisMain ); - needsMainTrailingPos = true; + if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsMainTrailingPos = true; + } } if (!isCrossDimDefined) { @@ -1053,7 +1056,10 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction paddingAndBorderAxisCross ); - needsCrossTrailingPos = true; + if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsCrossTrailingPos = true; + } } // Set trailing position if necessary diff --git a/src/Layout.js b/src/Layout.js index 9d8a4abc..9691767d 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -909,7 +909,10 @@ var computeLayout = (function() { paddingAndBorderAxisMain ); - needsMainTrailingPos = true; + if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsMainTrailingPos = true; + } } if (!isCrossDimDefined) { @@ -921,7 +924,10 @@ var computeLayout = (function() { paddingAndBorderAxisCross ); - needsCrossTrailingPos = true; + if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsCrossTrailingPos = true; + } } // Set trailing position if necessary diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index a4b7baea..f75e5795 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -858,7 +858,10 @@ public class LayoutEngine { paddingAndBorderAxisMain ); - needsMainTrailingPos = true; + if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsMainTrailingPos = true; + } } if (!isCrossDimDefined) { @@ -870,7 +873,10 @@ public class LayoutEngine { paddingAndBorderAxisCross ); - needsCrossTrailingPos = true; + if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE || + crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { + needsCrossTrailingPos = true; + } } // Set trailing position if necessary From 996f2a03d598c593074da6c921d96b849ec9e308 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 8 Sep 2015 15:34:27 +0100 Subject: [PATCH 04/11] Merge pre-fill loop into main line loop There's no need to go through all children before starting the main line loop as we'll visit all children in the former loop anyway. This diff merges the pre-fill loop into the main line one to avoid an extraneous traversal on the node's children. --- src/Layout.c | 73 +++++++++---------- src/Layout.js | 73 +++++++++---------- .../com/facebook/csslayout/LayoutEngine.java | 73 +++++++++---------- 3 files changed, 105 insertions(+), 114 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index 51311d8e..be0d7d20 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -604,44 +604,6 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction css_node_t* child; css_flex_direction_t axis; - // Pre-fill some dimensions straight from the parent - for (i = 0; i < childCount; ++i) { - child = node->get_child(node->context, i); - // Pre-fill cross axis dimensions when the child is using stretch before - // we call the recursive layout pass - if (getAlignItem(node, child) == CSS_ALIGN_STRETCH && - child->style.position_type == CSS_POSITION_RELATIVE && - isCrossDimDefined && - !isDimDefined(child, crossAxis)) { - child->layout.dimensions[dim[crossAxis]] = fmaxf( - boundAxis(child, crossAxis, node->layout.dimensions[dim[crossAxis]] - - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, crossAxis) - ); - } else if (child->style.position_type == CSS_POSITION_ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node->layout.dimensions[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child->layout.dimensions[dim[axis]] = fmaxf( - boundAxis(child, axis, node->layout.dimensions[dim[axis]] - - getPaddingAndBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis])), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } - } - } - } - float definedMainDim = CSS_UNDEFINED; if (isMainDimDefined) { definedMainDim = node->layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -674,6 +636,41 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction float maxWidth; for (i = startLine; i < childCount; ++i) { child = node->get_child(node->context, i); + + // Pre-fill cross axis dimensions when the child is using stretch before + // we call the recursive layout pass + if (getAlignItem(node, child) == CSS_ALIGN_STRETCH && + child->style.position_type == CSS_POSITION_RELATIVE && + isCrossDimDefined && + !isDimDefined(child, crossAxis)) { + child->layout.dimensions[dim[crossAxis]] = fmaxf( + boundAxis(child, crossAxis, node->layout.dimensions[dim[crossAxis]] - + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, crossAxis) + ); + } else if (child->style.position_type == CSS_POSITION_ABSOLUTE) { + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both + // left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node->layout.dimensions[dim[axis]]) && + !isDimDefined(child, axis) && + isPosDefined(child, leading[axis]) && + isPosDefined(child, trailing[axis])) { + child->layout.dimensions[dim[axis]] = fmaxf( + boundAxis(child, axis, node->layout.dimensions[dim[axis]] - + getPaddingAndBorderAxis(node, axis) - + getMarginAxis(child, axis) - + getPosition(child, leading[axis]) - + getPosition(child, trailing[axis])), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, axis) + ); + } + } + } + float nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed diff --git a/src/Layout.js b/src/Layout.js index 9691767d..957e4455 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -472,44 +472,6 @@ var computeLayout = (function() { var/*css_node_t**/ child; var/*(c)!css_flex_direction_t*//*(java)!int*/ axis; - // Pre-fill some dimensions straight from the parent - for (i = 0; i < childCount; ++i) { - child = node.children[i]; - // Pre-fill cross axis dimensions when the child is using stretch before - // we call the recursive layout pass - if (getAlignItem(node, child) === CSS_ALIGN_STRETCH && - getPositionType(child) === CSS_POSITION_RELATIVE && - isCrossDimDefined && - !isDimDefined(child, crossAxis)) { - child.layout[dim[crossAxis]] = fmaxf( - boundAxis(child, crossAxis, node.layout[dim[crossAxis]] - - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, crossAxis) - ); - } else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node.layout[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child.layout[dim[axis]] = fmaxf( - boundAxis(child, axis, node.layout[dim[axis]] - - getPaddingAndBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis])), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } - } - } - } - var/*float*/ definedMainDim = CSS_UNDEFINED; if (isMainDimDefined) { definedMainDim = node.layout[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -542,6 +504,41 @@ var computeLayout = (function() { var/*float*/ maxWidth; for (i = startLine; i < childCount; ++i) { child = node.children[i]; + + // Pre-fill cross axis dimensions when the child is using stretch before + // we call the recursive layout pass + if (getAlignItem(node, child) === CSS_ALIGN_STRETCH && + getPositionType(child) === CSS_POSITION_RELATIVE && + isCrossDimDefined && + !isDimDefined(child, crossAxis)) { + child.layout[dim[crossAxis]] = fmaxf( + boundAxis(child, crossAxis, node.layout[dim[crossAxis]] - + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, crossAxis) + ); + } else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) { + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both + // left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout[dim[axis]]) && + !isDimDefined(child, axis) && + isPosDefined(child, leading[axis]) && + isPosDefined(child, trailing[axis])) { + child.layout[dim[axis]] = fmaxf( + boundAxis(child, axis, node.layout[dim[axis]] - + getPaddingAndBorderAxis(node, axis) - + getMarginAxis(child, axis) - + getPosition(child, leading[axis]) - + getPosition(child, trailing[axis])), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, axis) + ); + } + } + } + var/*float*/ nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index f75e5795..cc92377d 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -421,44 +421,6 @@ public class LayoutEngine { CSSNode child; int axis; - // Pre-fill some dimensions straight from the parent - for (i = 0; i < childCount; ++i) { - child = node.getChildAt(i); - // Pre-fill cross axis dimensions when the child is using stretch before - // we call the recursive layout pass - if (getAlignItem(node, child) == CSSAlign.STRETCH && - child.style.positionType == CSSPositionType.RELATIVE && - isCrossDimDefined && - !isDimDefined(child, crossAxis)) { - child.layout.dimensions[dim[crossAxis]] = Math.max( - boundAxis(child, crossAxis, node.layout.dimensions[dim[crossAxis]] - - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, crossAxis) - ); - } else if (child.style.positionType == CSSPositionType.ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node.layout.dimensions[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child.layout.dimensions[dim[axis]] = Math.max( - boundAxis(child, axis, node.layout.dimensions[dim[axis]] - - getPaddingAndBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis])), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } - } - } - } - float definedMainDim = CSSConstants.UNDEFINED; if (isMainDimDefined) { definedMainDim = node.layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -491,6 +453,41 @@ public class LayoutEngine { float maxWidth; for (i = startLine; i < childCount; ++i) { child = node.getChildAt(i); + + // Pre-fill cross axis dimensions when the child is using stretch before + // we call the recursive layout pass + if (getAlignItem(node, child) == CSSAlign.STRETCH && + child.style.positionType == CSSPositionType.RELATIVE && + isCrossDimDefined && + !isDimDefined(child, crossAxis)) { + child.layout.dimensions[dim[crossAxis]] = Math.max( + boundAxis(child, crossAxis, node.layout.dimensions[dim[crossAxis]] - + paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, crossAxis) + ); + } else if (child.style.positionType == CSSPositionType.ABSOLUTE) { + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both + // left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout.dimensions[dim[axis]]) && + !isDimDefined(child, axis) && + isPosDefined(child, leading[axis]) && + isPosDefined(child, trailing[axis])) { + child.layout.dimensions[dim[axis]] = Math.max( + boundAxis(child, axis, node.layout.dimensions[dim[axis]] - + getPaddingAndBorderAxis(node, axis) - + getMarginAxis(child, axis) - + getPosition(child, leading[axis]) - + getPosition(child, trailing[axis])), + // You never want to go smaller than padding + getPaddingAndBorderAxis(child, axis) + ); + } + } + } + float nextContentDim = 0; // It only makes sense to consider a child flexible if we have a computed From 793220faf8641265c0383b8276074169ea2c0aaa Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 4 Sep 2015 17:37:07 +0100 Subject: [PATCH 05/11] Skip final loop on absolute children, if possible There's no need to go through all absolute children at the end of the layout calculation if the node at hand doesn't have any. This also ensures only absolutely positioned children are traversed in the final loop. --- src/Layout.c | 77 +++++++++++-------- src/Layout.h | 7 +- src/Layout.js | 77 +++++++++++-------- .../src/com/facebook/csslayout/CSSNode.java | 2 + .../com/facebook/csslayout/LayoutEngine.java | 77 +++++++++++-------- src/transpile.js | 3 + 6 files changed, 148 insertions(+), 95 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index be0d7d20..a59d7045 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -604,6 +604,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction css_node_t* child; css_flex_direction_t axis; + css_node_t* firstAbsoluteChild = NULL; + css_node_t* currentAbsoluteChild = NULL; + float definedMainDim = CSS_UNDEFINED; if (isMainDimDefined) { definedMainDim = node->layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -637,6 +640,8 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction for (i = startLine; i < childCount; ++i) { child = node->get_child(node->context, i); + child->next_absolute_child = NULL; + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) == CSS_ALIGN_STRETCH && @@ -650,6 +655,16 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction getPaddingAndBorderAxis(child, crossAxis) ); } else if (child->style.position_type == CSS_POSITION_ABSOLUTE) { + // Store a private linked list of absolutely positioned children + // so that we can efficiently traverse them later. + if (firstAbsoluteChild == NULL) { + firstAbsoluteChild = child; + } + if (currentAbsoluteChild != NULL) { + currentAbsoluteChild->next_absolute_child = child; + } + currentAbsoluteChild = child; + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { @@ -1075,40 +1090,40 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < childCount; ++i) { - child = node->get_child(node->context, i); - if (child->style.position_type == CSS_POSITION_ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node->layout.dimensions[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child->layout.dimensions[dim[axis]] = fmaxf( - boundAxis(child, axis, node->layout.dimensions[dim[axis]] - - getBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis]) - ), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } + currentAbsoluteChild = firstAbsoluteChild; + while (currentAbsoluteChild != NULL) { + // Pre-fill dimensions when using absolute position and both offsets for + // the axis are defined (either both left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node->layout.dimensions[dim[axis]]) && + !isDimDefined(currentAbsoluteChild, axis) && + isPosDefined(currentAbsoluteChild, leading[axis]) && + isPosDefined(currentAbsoluteChild, trailing[axis])) { + currentAbsoluteChild->layout.dimensions[dim[axis]] = fmaxf( + boundAxis(currentAbsoluteChild, axis, node->layout.dimensions[dim[axis]] - + getBorderAxis(node, axis) - + getMarginAxis(currentAbsoluteChild, axis) - + getPosition(currentAbsoluteChild, leading[axis]) - + getPosition(currentAbsoluteChild, trailing[axis]) + ), + // You never want to go smaller than padding + getPaddingAndBorderAxis(currentAbsoluteChild, axis) + ); } - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (isPosDefined(child, trailing[axis]) && - !isPosDefined(child, leading[axis])) { - child->layout.position[leading[axis]] = - node->layout.dimensions[dim[axis]] - - child->layout.dimensions[dim[axis]] - - getPosition(child, trailing[axis]); - } + + if (isPosDefined(currentAbsoluteChild, trailing[axis]) && + !isPosDefined(currentAbsoluteChild, leading[axis])) { + currentAbsoluteChild->layout.position[leading[axis]] = + node->layout.dimensions[dim[axis]] - + currentAbsoluteChild->layout.dimensions[dim[axis]] - + getPosition(currentAbsoluteChild, trailing[axis]); } } + + child = currentAbsoluteChild; + currentAbsoluteChild = currentAbsoluteChild->next_absolute_child; + child->next_absolute_child = NULL; } /** END_GENERATED **/ } diff --git a/src/Layout.h b/src/Layout.h index 54d31589..820f54c1 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -129,18 +129,21 @@ typedef struct { float maxDimensions[2]; } css_style_t; -typedef struct css_node { +typedef struct css_node css_node_t; +struct css_node { css_style_t style; css_layout_t layout; int children_count; int line_index; + css_node_t* next_absolute_child; + css_dim_t (*measure)(void *context, float width); void (*print)(void *context); struct css_node* (*get_child)(void *context, int i); bool (*is_dirty)(void *context); void *context; -} css_node_t; +}; // Lifecycle of nodes and children diff --git a/src/Layout.js b/src/Layout.js index 957e4455..ac111e3c 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -472,6 +472,9 @@ var computeLayout = (function() { var/*css_node_t**/ child; var/*(c)!css_flex_direction_t*//*(java)!int*/ axis; + var/*css_node_t**/ firstAbsoluteChild = null; + var/*css_node_t**/ currentAbsoluteChild = null; + var/*float*/ definedMainDim = CSS_UNDEFINED; if (isMainDimDefined) { definedMainDim = node.layout[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -505,6 +508,8 @@ var computeLayout = (function() { for (i = startLine; i < childCount; ++i) { child = node.children[i]; + child.nextAbsoluteChild = null; + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) === CSS_ALIGN_STRETCH && @@ -518,6 +523,16 @@ var computeLayout = (function() { getPaddingAndBorderAxis(child, crossAxis) ); } else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) { + // Store a private linked list of absolutely positioned children + // so that we can efficiently traverse them later. + if (firstAbsoluteChild === null) { + firstAbsoluteChild = child; + } + if (currentAbsoluteChild !== null) { + currentAbsoluteChild.nextAbsoluteChild = child; + } + currentAbsoluteChild = child; + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { @@ -943,40 +958,40 @@ var computeLayout = (function() { } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < childCount; ++i) { - child = node.children[i]; - if (getPositionType(child) === CSS_POSITION_ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node.layout[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child.layout[dim[axis]] = fmaxf( - boundAxis(child, axis, node.layout[dim[axis]] - - getBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis]) - ), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } + currentAbsoluteChild = firstAbsoluteChild; + while (currentAbsoluteChild !== null) { + // Pre-fill dimensions when using absolute position and both offsets for + // the axis are defined (either both left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout[dim[axis]]) && + !isDimDefined(currentAbsoluteChild, axis) && + isPosDefined(currentAbsoluteChild, leading[axis]) && + isPosDefined(currentAbsoluteChild, trailing[axis])) { + currentAbsoluteChild.layout[dim[axis]] = fmaxf( + boundAxis(currentAbsoluteChild, axis, node.layout[dim[axis]] - + getBorderAxis(node, axis) - + getMarginAxis(currentAbsoluteChild, axis) - + getPosition(currentAbsoluteChild, leading[axis]) - + getPosition(currentAbsoluteChild, trailing[axis]) + ), + // You never want to go smaller than padding + getPaddingAndBorderAxis(currentAbsoluteChild, axis) + ); } - for (ii = 0; ii < 2; ii++) { - axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (isPosDefined(child, trailing[axis]) && - !isPosDefined(child, leading[axis])) { - child.layout[leading[axis]] = - node.layout[dim[axis]] - - child.layout[dim[axis]] - - getPosition(child, trailing[axis]); - } + + if (isPosDefined(currentAbsoluteChild, trailing[axis]) && + !isPosDefined(currentAbsoluteChild, leading[axis])) { + currentAbsoluteChild.layout[leading[axis]] = + node.layout[dim[axis]] - + currentAbsoluteChild.layout[dim[axis]] - + getPosition(currentAbsoluteChild, trailing[axis]); } } + + child = currentAbsoluteChild; + currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild; + child.nextAbsoluteChild = null; } } diff --git a/src/java/src/com/facebook/csslayout/CSSNode.java b/src/java/src/com/facebook/csslayout/CSSNode.java index 91d7ed83..bd2ec4a3 100644 --- a/src/java/src/com/facebook/csslayout/CSSNode.java +++ b/src/java/src/com/facebook/csslayout/CSSNode.java @@ -63,6 +63,8 @@ public class CSSNode { public int lineIndex = 0; + CSSNode nextAbsoluteChild; + private @Nullable ArrayList mChildren; private @Nullable CSSNode mParent; private @Nullable MeasureFunction mMeasureFunction = null; diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index cc92377d..2f40c165 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -421,6 +421,9 @@ public class LayoutEngine { CSSNode child; int axis; + CSSNode firstAbsoluteChild = null; + CSSNode currentAbsoluteChild = null; + float definedMainDim = CSSConstants.UNDEFINED; if (isMainDimDefined) { definedMainDim = node.layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain; @@ -454,6 +457,8 @@ public class LayoutEngine { for (i = startLine; i < childCount; ++i) { child = node.getChildAt(i); + child.nextAbsoluteChild = null; + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass if (getAlignItem(node, child) == CSSAlign.STRETCH && @@ -467,6 +472,16 @@ public class LayoutEngine { getPaddingAndBorderAxis(child, crossAxis) ); } else if (child.style.positionType == CSSPositionType.ABSOLUTE) { + // Store a private linked list of absolutely positioned children + // so that we can efficiently traverse them later. + if (firstAbsoluteChild == null) { + firstAbsoluteChild = child; + } + if (currentAbsoluteChild != null) { + currentAbsoluteChild.nextAbsoluteChild = child; + } + currentAbsoluteChild = child; + // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both // left and right or top and bottom). for (ii = 0; ii < 2; ii++) { @@ -892,40 +907,40 @@ public class LayoutEngine { } // Calculate dimensions for absolutely positioned elements - for (i = 0; i < childCount; ++i) { - child = node.getChildAt(i); - if (child.style.positionType == CSSPositionType.ABSOLUTE) { - // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both - // left and right or top and bottom). - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (!isUndefined(node.layout.dimensions[dim[axis]]) && - !isDimDefined(child, axis) && - isPosDefined(child, leading[axis]) && - isPosDefined(child, trailing[axis])) { - child.layout.dimensions[dim[axis]] = Math.max( - boundAxis(child, axis, node.layout.dimensions[dim[axis]] - - getBorderAxis(node, axis) - - getMarginAxis(child, axis) - - getPosition(child, leading[axis]) - - getPosition(child, trailing[axis]) - ), - // You never want to go smaller than padding - getPaddingAndBorderAxis(child, axis) - ); - } + currentAbsoluteChild = firstAbsoluteChild; + while (currentAbsoluteChild != null) { + // Pre-fill dimensions when using absolute position and both offsets for + // the axis are defined (either both left and right or top and bottom). + for (ii = 0; ii < 2; ii++) { + axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout.dimensions[dim[axis]]) && + !isDimDefined(currentAbsoluteChild, axis) && + isPosDefined(currentAbsoluteChild, leading[axis]) && + isPosDefined(currentAbsoluteChild, trailing[axis])) { + currentAbsoluteChild.layout.dimensions[dim[axis]] = Math.max( + boundAxis(currentAbsoluteChild, axis, node.layout.dimensions[dim[axis]] - + getBorderAxis(node, axis) - + getMarginAxis(currentAbsoluteChild, axis) - + getPosition(currentAbsoluteChild, leading[axis]) - + getPosition(currentAbsoluteChild, trailing[axis]) + ), + // You never want to go smaller than padding + getPaddingAndBorderAxis(currentAbsoluteChild, axis) + ); } - for (ii = 0; ii < 2; ii++) { - axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; - if (isPosDefined(child, trailing[axis]) && - !isPosDefined(child, leading[axis])) { - child.layout.position[leading[axis]] = - node.layout.dimensions[dim[axis]] - - child.layout.dimensions[dim[axis]] - - getPosition(child, trailing[axis]); - } + + if (isPosDefined(currentAbsoluteChild, trailing[axis]) && + !isPosDefined(currentAbsoluteChild, leading[axis])) { + currentAbsoluteChild.layout.position[leading[axis]] = + node.layout.dimensions[dim[axis]] - + currentAbsoluteChild.layout.dimensions[dim[axis]] - + getPosition(currentAbsoluteChild, trailing[axis]); } } + + child = currentAbsoluteChild; + currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild; + child.nextAbsoluteChild = null; } } /** END_GENERATED **/ diff --git a/src/transpile.js b/src/transpile.js index 2f93d154..4666dbaf 100644 --- a/src/transpile.js +++ b/src/transpile.js @@ -243,6 +243,7 @@ function printLayout(test) { function transpileAnnotatedJStoC(jsCode) { return jsCode .replace('node.style.measure', 'node.measure') + .replace(/null/g, 'NULL') .replace(/\.children\.length/g, '.children_count') .replace(/\.width/g, '.dimensions[CSS_WIDTH]') .replace(/\.height/g, '.dimensions[CSS_HEIGHT]') @@ -251,6 +252,7 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/\.minWidth/g, '.minDimensions[CSS_WIDTH]') .replace(/\.minHeight/g, '.minDimensions[CSS_HEIGHT]') .replace(/\.lineIndex/g, '.line_index') + .replace(/\.nextAbsoluteChild/g, '.next_absolute_child') .replace(/layout\[dim/g, 'layout.dimensions[dim') .replace(/layout\[pos/g, 'layout.position[pos') .replace(/layout\[leading/g, 'layout.position[leading') @@ -261,6 +263,7 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/node\./g, 'node->') .replace(/child\./g, 'child->') .replace(/parent\./g, 'parent->') + .replace(/currentAbsoluteChild\./g, 'currentAbsoluteChild->') .replace(/getPositionType\((.+?)\)/g, '$1->style.position_type') .replace(/getJustifyContent\((.+?)\)/g, '$1->style.justify_content') .replace(/getAlignContent\((.+?)\)/g, '$1->style.align_content') From d1a49a4f0bdaf16c9e5ac1267e22d9d5ba3f335d Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 7 Sep 2015 13:54:27 +0100 Subject: [PATCH 06/11] Reduce search range of flexible children We were traversing all children to only perform calculations/changes to flexible children in order to avoid new allocations during layout. This diff ensures we only visit flexible children during layout calculations if any are present. We accomplish this by keeping a private linked list of flexible children. --- src/Layout.c | 84 +++++++++++-------- src/Layout.h | 1 + src/Layout.js | 84 +++++++++++-------- .../src/com/facebook/csslayout/CSSNode.java | 1 + .../com/facebook/csslayout/LayoutEngine.java | 84 +++++++++++-------- src/transpile.js | 2 + 6 files changed, 151 insertions(+), 105 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index a59d7045..feb4f952 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -636,11 +636,15 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction float totalFlexible = 0; int nonFlexibleChildrenCount = 0; + css_node_t* firstFlexChild = NULL; + css_node_t* currentFlexChild = NULL; + float maxWidth; for (i = startLine; i < childCount; ++i) { child = node->get_child(node->context, i); child->next_absolute_child = NULL; + child->next_flex_child = NULL; // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass @@ -694,6 +698,16 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction flexibleChildrenCount++; totalFlexible += child->style.flex; + // Store a private linked list of flexible children so that we can + // efficiently traverse them later. + if (firstFlexChild == NULL) { + firstFlexChild = child; + } + if (currentFlexChild != NULL) { + currentFlexChild->next_flex_child = child; + } + currentFlexChild = child; + // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents // the smallest possible size for the child, to compute the remaining @@ -767,21 +781,20 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction float baseMainDim; float boundMainDim; - // Iterate over every child in the axis. If the flex share of remaining - // space doesn't meet min/max bounds, remove this child from flex - // calculations. - for (i = startLine; i < endLine; ++i) { - child = node->get_child(node->context, i); - if (isFlex(child)) { - baseMainDim = flexibleMainDim * child->style.flex + - getPaddingAndBorderAxis(child, mainAxis); - boundMainDim = boundAxis(child, mainAxis, baseMainDim); + // If the flex share of remaining space doesn't meet min/max bounds, + // remove this child from flex calculations. + currentFlexChild = firstFlexChild; + while (currentFlexChild != NULL) { + baseMainDim = flexibleMainDim * currentFlexChild->style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis); + boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim); - if (baseMainDim != boundMainDim) { - remainingMainDim -= boundMainDim; - totalFlexible -= child->style.flex; - } + if (baseMainDim != boundMainDim) { + remainingMainDim -= boundMainDim; + totalFlexible -= currentFlexChild->style.flex; } + + currentFlexChild = currentFlexChild->next_flex_child; } flexibleMainDim = remainingMainDim / totalFlexible; @@ -790,31 +803,32 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction if (flexibleMainDim < 0) { flexibleMainDim = 0; } - // We iterate over the full array and only apply the action on flexible - // children. This is faster than actually allocating a new array that - // contains only flexible children. - for (i = startLine; i < endLine; ++i) { - child = node->get_child(node->context, i); - if (isFlex(child)) { - // At this point we know the final size of the element in the main - // dimension - child->layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * child->style.flex + getPaddingAndBorderAxis(child, mainAxis) - ); - maxWidth = CSS_UNDEFINED; - if (isDimDefined(node, resolvedRowAxis)) { - maxWidth = node->layout.dimensions[dim[resolvedRowAxis]] - - paddingAndBorderAxisResolvedRow; - } else if (!isMainRowDirection) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - paddingAndBorderAxisResolvedRow; - } + currentFlexChild = firstFlexChild; + while (currentFlexChild != NULL) { + // At this point we know the final size of the element in the main + // dimension + currentFlexChild->layout.dimensions[dim[mainAxis]] = boundAxis(currentFlexChild, mainAxis, + flexibleMainDim * currentFlexChild->style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis) + ); - // And we recursively call the layout algorithm for this child - layoutNode(child, maxWidth, direction); + maxWidth = CSS_UNDEFINED; + if (isDimDefined(node, resolvedRowAxis)) { + maxWidth = node->layout.dimensions[dim[resolvedRowAxis]] - + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } + + // And we recursively call the layout algorithm for this child + layoutNode(currentFlexChild, maxWidth, direction); + + child = currentFlexChild; + currentFlexChild = currentFlexChild->next_flex_child; + child->next_flex_child = NULL; } // We use justifyContent to figure out how to allocate the remaining diff --git a/src/Layout.h b/src/Layout.h index 820f54c1..535fa734 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -137,6 +137,7 @@ struct css_node { int line_index; css_node_t* next_absolute_child; + css_node_t* next_flex_child; css_dim_t (*measure)(void *context, float width); void (*print)(void *context); diff --git a/src/Layout.js b/src/Layout.js index ac111e3c..ead03eab 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -504,11 +504,15 @@ var computeLayout = (function() { var/*float*/ totalFlexible = 0; var/*int*/ nonFlexibleChildrenCount = 0; + var/*css_node_t**/ firstFlexChild = null; + var/*css_node_t**/ currentFlexChild = null; + var/*float*/ maxWidth; for (i = startLine; i < childCount; ++i) { child = node.children[i]; child.nextAbsoluteChild = null; + child.nextFlexChild = null; // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass @@ -562,6 +566,16 @@ var computeLayout = (function() { flexibleChildrenCount++; totalFlexible += child.style.flex; + // Store a private linked list of flexible children so that we can + // efficiently traverse them later. + if (firstFlexChild === null) { + firstFlexChild = child; + } + if (currentFlexChild !== null) { + currentFlexChild.nextFlexChild = child; + } + currentFlexChild = child; + // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents // the smallest possible size for the child, to compute the remaining @@ -635,21 +649,20 @@ var computeLayout = (function() { var/*float*/ baseMainDim; var/*float*/ boundMainDim; - // Iterate over every child in the axis. If the flex share of remaining - // space doesn't meet min/max bounds, remove this child from flex - // calculations. - for (i = startLine; i < endLine; ++i) { - child = node.children[i]; - if (isFlex(child)) { - baseMainDim = flexibleMainDim * child.style.flex + - getPaddingAndBorderAxis(child, mainAxis); - boundMainDim = boundAxis(child, mainAxis, baseMainDim); + // If the flex share of remaining space doesn't meet min/max bounds, + // remove this child from flex calculations. + currentFlexChild = firstFlexChild; + while (currentFlexChild !== null) { + baseMainDim = flexibleMainDim * currentFlexChild.style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis); + boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim); - if (baseMainDim !== boundMainDim) { - remainingMainDim -= boundMainDim; - totalFlexible -= child.style.flex; - } + if (baseMainDim !== boundMainDim) { + remainingMainDim -= boundMainDim; + totalFlexible -= currentFlexChild.style.flex; } + + currentFlexChild = currentFlexChild.nextFlexChild; } flexibleMainDim = remainingMainDim / totalFlexible; @@ -658,31 +671,32 @@ var computeLayout = (function() { if (flexibleMainDim < 0) { flexibleMainDim = 0; } - // We iterate over the full array and only apply the action on flexible - // children. This is faster than actually allocating a new array that - // contains only flexible children. - for (i = startLine; i < endLine; ++i) { - child = node.children[i]; - if (isFlex(child)) { - // At this point we know the final size of the element in the main - // dimension - child.layout[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis) - ); - maxWidth = CSS_UNDEFINED; - if (isDimDefined(node, resolvedRowAxis)) { - maxWidth = node.layout[dim[resolvedRowAxis]] - - paddingAndBorderAxisResolvedRow; - } else if (!isMainRowDirection) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - paddingAndBorderAxisResolvedRow; - } + currentFlexChild = firstFlexChild; + while (currentFlexChild !== null) { + // At this point we know the final size of the element in the main + // dimension + currentFlexChild.layout[dim[mainAxis]] = boundAxis(currentFlexChild, mainAxis, + flexibleMainDim * currentFlexChild.style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis) + ); - // And we recursively call the layout algorithm for this child - layoutNode(/*(java)!layoutContext, */child, maxWidth, direction); + maxWidth = CSS_UNDEFINED; + if (isDimDefined(node, resolvedRowAxis)) { + maxWidth = node.layout[dim[resolvedRowAxis]] - + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } + + // And we recursively call the layout algorithm for this child + layoutNode(/*(java)!layoutContext, */currentFlexChild, maxWidth, direction); + + child = currentFlexChild; + currentFlexChild = currentFlexChild.nextFlexChild; + child.nextFlexChild = null; } // We use justifyContent to figure out how to allocate the remaining diff --git a/src/java/src/com/facebook/csslayout/CSSNode.java b/src/java/src/com/facebook/csslayout/CSSNode.java index bd2ec4a3..85d165e8 100644 --- a/src/java/src/com/facebook/csslayout/CSSNode.java +++ b/src/java/src/com/facebook/csslayout/CSSNode.java @@ -64,6 +64,7 @@ public class CSSNode { public int lineIndex = 0; CSSNode nextAbsoluteChild; + CSSNode nextFlexChild; private @Nullable ArrayList mChildren; private @Nullable CSSNode mParent; diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 2f40c165..1e867671 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -453,11 +453,15 @@ public class LayoutEngine { float totalFlexible = 0; int nonFlexibleChildrenCount = 0; + CSSNode firstFlexChild = null; + CSSNode currentFlexChild = null; + float maxWidth; for (i = startLine; i < childCount; ++i) { child = node.getChildAt(i); child.nextAbsoluteChild = null; + child.nextFlexChild = null; // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass @@ -511,6 +515,16 @@ public class LayoutEngine { flexibleChildrenCount++; totalFlexible += child.style.flex; + // Store a private linked list of flexible children so that we can + // efficiently traverse them later. + if (firstFlexChild == null) { + firstFlexChild = child; + } + if (currentFlexChild != null) { + currentFlexChild.nextFlexChild = child; + } + currentFlexChild = child; + // Even if we don't know its exact size yet, we already know the padding, // border and margin. We'll use this partial information, which represents // the smallest possible size for the child, to compute the remaining @@ -584,21 +598,20 @@ public class LayoutEngine { float baseMainDim; float boundMainDim; - // Iterate over every child in the axis. If the flex share of remaining - // space doesn't meet min/max bounds, remove this child from flex - // calculations. - for (i = startLine; i < endLine; ++i) { - child = node.getChildAt(i); - if (isFlex(child)) { - baseMainDim = flexibleMainDim * child.style.flex + - getPaddingAndBorderAxis(child, mainAxis); - boundMainDim = boundAxis(child, mainAxis, baseMainDim); + // If the flex share of remaining space doesn't meet min/max bounds, + // remove this child from flex calculations. + currentFlexChild = firstFlexChild; + while (currentFlexChild != null) { + baseMainDim = flexibleMainDim * currentFlexChild.style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis); + boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim); - if (baseMainDim != boundMainDim) { - remainingMainDim -= boundMainDim; - totalFlexible -= child.style.flex; - } + if (baseMainDim != boundMainDim) { + remainingMainDim -= boundMainDim; + totalFlexible -= currentFlexChild.style.flex; } + + currentFlexChild = currentFlexChild.nextFlexChild; } flexibleMainDim = remainingMainDim / totalFlexible; @@ -607,31 +620,32 @@ public class LayoutEngine { if (flexibleMainDim < 0) { flexibleMainDim = 0; } - // We iterate over the full array and only apply the action on flexible - // children. This is faster than actually allocating a new array that - // contains only flexible children. - for (i = startLine; i < endLine; ++i) { - child = node.getChildAt(i); - if (isFlex(child)) { - // At this point we know the final size of the element in the main - // dimension - child.layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis, - flexibleMainDim * child.style.flex + getPaddingAndBorderAxis(child, mainAxis) - ); - maxWidth = CSSConstants.UNDEFINED; - if (isDimDefined(node, resolvedRowAxis)) { - maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - - paddingAndBorderAxisResolvedRow; - } else if (!isMainRowDirection) { - maxWidth = parentMaxWidth - - getMarginAxis(node, resolvedRowAxis) - - paddingAndBorderAxisResolvedRow; - } + currentFlexChild = firstFlexChild; + while (currentFlexChild != null) { + // At this point we know the final size of the element in the main + // dimension + currentFlexChild.layout.dimensions[dim[mainAxis]] = boundAxis(currentFlexChild, mainAxis, + flexibleMainDim * currentFlexChild.style.flex + + getPaddingAndBorderAxis(currentFlexChild, mainAxis) + ); - // And we recursively call the layout algorithm for this child - layoutNode(layoutContext, child, maxWidth, direction); + maxWidth = CSSConstants.UNDEFINED; + if (isDimDefined(node, resolvedRowAxis)) { + maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] - + paddingAndBorderAxisResolvedRow; + } else if (!isMainRowDirection) { + maxWidth = parentMaxWidth - + getMarginAxis(node, resolvedRowAxis) - + paddingAndBorderAxisResolvedRow; } + + // And we recursively call the layout algorithm for this child + layoutNode(layoutContext, currentFlexChild, maxWidth, direction); + + child = currentFlexChild; + currentFlexChild = currentFlexChild.nextFlexChild; + child.nextFlexChild = null; } // We use justifyContent to figure out how to allocate the remaining diff --git a/src/transpile.js b/src/transpile.js index 4666dbaf..ff0f1922 100644 --- a/src/transpile.js +++ b/src/transpile.js @@ -253,6 +253,7 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/\.minHeight/g, '.minDimensions[CSS_HEIGHT]') .replace(/\.lineIndex/g, '.line_index') .replace(/\.nextAbsoluteChild/g, '.next_absolute_child') + .replace(/\.nextFlexChild/g, '.next_flex_child') .replace(/layout\[dim/g, 'layout.dimensions[dim') .replace(/layout\[pos/g, 'layout.position[pos') .replace(/layout\[leading/g, 'layout.position[leading') @@ -264,6 +265,7 @@ function transpileAnnotatedJStoC(jsCode) { .replace(/child\./g, 'child->') .replace(/parent\./g, 'parent->') .replace(/currentAbsoluteChild\./g, 'currentAbsoluteChild->') + .replace(/currentFlexChild\./g, 'currentFlexChild->') .replace(/getPositionType\((.+?)\)/g, '$1->style.position_type') .replace(/getJustifyContent\((.+?)\)/g, '$1->style.justify_content') .replace(/getAlignContent\((.+?)\)/g, '$1->style.align_content') From 2321165d532fe2641bb7f7edaaca3d8017b90e3c Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 7 Sep 2015 17:08:12 +0100 Subject: [PATCH 07/11] Move condition to the non-redundant block No need to check for RELATIVE position when position type is ABSOLUTE and dimension is set. --- src/Layout.c | 23 ++++++++++--------- src/Layout.js | 23 ++++++++++--------- .../com/facebook/csslayout/LayoutEngine.java | 23 ++++++++++--------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index feb4f952..e7a80179 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -885,18 +885,18 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } - } - // Now that we placed the element, we need to update the variables - // We only need to do that for relative elements. Absolute elements - // do not take part in that phase. - if (child->style.position_type == CSS_POSITION_RELATIVE) { - // The main dimension is the sum of all the elements dimension plus - // the spacing. - mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); - // The cross dimension is the max of the elements dimension since there - // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + // Now that we placed the element, we need to update the variables + // We only need to do that for relative elements. Absolute elements + // do not take part in that phase. + if (child->style.position_type == CSS_POSITION_RELATIVE) { + // The main dimension is the sum of all the elements dimension plus + // the spacing. + mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); + // The cross dimension is the max of the elements dimension since there + // can only be one element in that cross dimension. + crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } } } @@ -1110,6 +1110,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // the axis are defined (either both left and right or top and bottom). for (ii = 0; ii < 2; ii++) { axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node->layout.dimensions[dim[axis]]) && !isDimDefined(currentAbsoluteChild, axis) && isPosDefined(currentAbsoluteChild, leading[axis]) && diff --git a/src/Layout.js b/src/Layout.js index ead03eab..bbd13387 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -753,18 +753,18 @@ var computeLayout = (function() { if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } - } - // Now that we placed the element, we need to update the variables - // We only need to do that for relative elements. Absolute elements - // do not take part in that phase. - if (getPositionType(child) === CSS_POSITION_RELATIVE) { - // The main dimension is the sum of all the elements dimension plus - // the spacing. - mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); - // The cross dimension is the max of the elements dimension since there - // can only be one element in that cross dimension. - crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + // Now that we placed the element, we need to update the variables + // We only need to do that for relative elements. Absolute elements + // do not take part in that phase. + if (getPositionType(child) === CSS_POSITION_RELATIVE) { + // The main dimension is the sum of all the elements dimension plus + // the spacing. + mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); + // The cross dimension is the max of the elements dimension since there + // can only be one element in that cross dimension. + crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } } } @@ -978,6 +978,7 @@ var computeLayout = (function() { // the axis are defined (either both left and right or top and bottom). for (ii = 0; ii < 2; ii++) { axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout[dim[axis]]) && !isDimDefined(currentAbsoluteChild, axis) && isPosDefined(currentAbsoluteChild, leading[axis]) && diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 1e867671..a251ad9b 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -702,18 +702,18 @@ public class LayoutEngine { if (isMainDimDefined) { setTrailingPosition(node, child, mainAxis); } - } - // Now that we placed the element, we need to update the variables - // We only need to do that for relative elements. Absolute elements - // do not take part in that phase. - if (child.style.positionType == CSSPositionType.RELATIVE) { - // The main dimension is the sum of all the elements dimension plus - // the spacing. - mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); - // The cross dimension is the max of the elements dimension since there - // can only be one element in that cross dimension. - crossDim = Math.max(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + // Now that we placed the element, we need to update the variables + // We only need to do that for relative elements. Absolute elements + // do not take part in that phase. + if (child.style.positionType == CSSPositionType.RELATIVE) { + // The main dimension is the sum of all the elements dimension plus + // the spacing. + mainDim += betweenMainDim + getDimWithMargin(child, mainAxis); + // The cross dimension is the max of the elements dimension since there + // can only be one element in that cross dimension. + crossDim = Math.max(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } } } @@ -927,6 +927,7 @@ public class LayoutEngine { // the axis are defined (either both left and right or top and bottom). for (ii = 0; ii < 2; ii++) { axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN; + if (!isUndefined(node.layout.dimensions[dim[axis]]) && !isDimDefined(currentAbsoluteChild, axis) && isPosDefined(currentAbsoluteChild, leading[axis]) && From 9a149c83ff43dbdb5713764f0a9a9ab25317245b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 8 Sep 2015 17:03:24 +0100 Subject: [PATCH 08/11] Avoid extra work when justifyContent is FLEX_START Remaining space and between space only need to be updated when justifyContent is not FLEX_START. --- src/Layout.c | 2 +- src/Layout.js | 4 ++-- src/java/src/com/facebook/csslayout/LayoutEngine.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index e7a80179..b1eac62f 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -833,7 +833,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // We use justifyContent to figure out how to allocate the remaining // space available - } else { + } else if (node->style.justify_content != CSS_JUSTIFY_FLEX_START) { css_justify_t justifyContent = node->style.justify_content; if (justifyContent == CSS_JUSTIFY_CENTER) { leadingMainDim = remainingMainDim / 2; diff --git a/src/Layout.js b/src/Layout.js index bbd13387..52525a08 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -20,7 +20,7 @@ var computeLayout = (function() { var CSS_FLEX_DIRECTION_COLUMN = 'column'; var CSS_FLEX_DIRECTION_COLUMN_REVERSE = 'column-reverse'; - // var CSS_JUSTIFY_FLEX_START = 'flex-start'; + var CSS_JUSTIFY_FLEX_START = 'flex-start'; var CSS_JUSTIFY_CENTER = 'center'; var CSS_JUSTIFY_FLEX_END = 'flex-end'; var CSS_JUSTIFY_SPACE_BETWEEN = 'space-between'; @@ -701,7 +701,7 @@ var computeLayout = (function() { // We use justifyContent to figure out how to allocate the remaining // space available - } else { + } else if (getJustifyContent(node) !== CSS_JUSTIFY_FLEX_START) { var/*css_justify_t*/ justifyContent = getJustifyContent(node); if (justifyContent === CSS_JUSTIFY_CENTER) { leadingMainDim = remainingMainDim / 2; diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index a251ad9b..527a3d94 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -650,7 +650,7 @@ public class LayoutEngine { // We use justifyContent to figure out how to allocate the remaining // space available - } else { + } else if (node.style.justifyContent != CSSJustify.FLEX_START) { CSSJustify justifyContent = node.style.justifyContent; if (justifyContent == CSSJustify.CENTER) { leadingMainDim = remainingMainDim / 2; From 909c14117f118c9b36e6623590e62bff2f996c1b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 9 Sep 2015 09:40:23 +0100 Subject: [PATCH 09/11] Fix dimension check for STRETCH children The correct check is on the layout state, no the style. --- src/Layout.c | 2 +- src/Layout.js | 2 +- src/java/src/com/facebook/csslayout/LayoutEngine.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index b1eac62f..81691461 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -934,7 +934,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction if (alignItem == CSS_ALIGN_STRETCH) { // You can only stretch if the dimension has not already been set // previously. - if (!isDimDefined(child, crossAxis)) { + if (isUndefined(child->layout.dimensions[dim[crossAxis]])) { child->layout.dimensions[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, containerCrossAxis - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), diff --git a/src/Layout.js b/src/Layout.js index 52525a08..5295c840 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -802,7 +802,7 @@ var computeLayout = (function() { if (alignItem === CSS_ALIGN_STRETCH) { // You can only stretch if the dimension has not already been set // previously. - if (!isDimDefined(child, crossAxis)) { + if (isUndefined(child.layout[dim[crossAxis]])) { child.layout[dim[crossAxis]] = fmaxf( boundAxis(child, crossAxis, containerCrossAxis - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 527a3d94..32b982a8 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -751,7 +751,7 @@ public class LayoutEngine { if (alignItem == CSSAlign.STRETCH) { // You can only stretch if the dimension has not already been set // previously. - if (!isDimDefined(child, crossAxis)) { + if (isUndefined(child.layout.dimensions[dim[crossAxis]])) { child.layout.dimensions[dim[crossAxis]] = Math.max( boundAxis(child, crossAxis, containerCrossAxis - paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)), From 2d869489efc19321f531476837026b6c17562511 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 9 Sep 2015 17:10:16 +0100 Subject: [PATCH 10/11] More efficient resetResult() loop in LayoutEngine --- src/java/src/com/facebook/csslayout/LayoutEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 32b982a8..68dc7fdb 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -329,7 +329,7 @@ public class LayoutEngine { CSSNode node, float parentMaxWidth, CSSDirection parentDirection) { - for (int i = 0; i < node.getChildCount(); i++) { + for (int i = 0, childCount = node.getChildCount(); i < childCount; i++) { node.getChildAt(i).layout.resetResult(); } From 765ff8463e5e94b8d4987cb4fc81b096ad68933f Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 9 Sep 2015 11:05:20 +0100 Subject: [PATCH 11/11] Add fast path for simple stack layouts Change the initial line loop to opportunistically position children in the in container with simple stacking params i.e. vertical/horizontal stacking on non-flexible STRETCH/FLEX_START aligned. This allows us to skip the main and cross axis loops (Loop C and D, respectively) partially and even completely in many common scenarios. In my benchamrks, this gives us about ~15% performance win in many setups. --- src/Layout.c | 75 +++++++++++++++++-- src/Layout.js | 75 +++++++++++++++++-- .../com/facebook/csslayout/LayoutEngine.java | 75 +++++++++++++++++-- 3 files changed, 201 insertions(+), 24 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index 81691461..bab98467 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -590,6 +590,8 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction bool isNodeFlexWrap = isFlexWrap(node); + css_justify_t justifyContent = node->style.justify_content; + float leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); float leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); @@ -636,19 +638,41 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction float totalFlexible = 0; int nonFlexibleChildrenCount = 0; + // Use the line loop to position children in the main axis for as long + // as they are using a simple stacking behaviour. Children that are + // immediately stacked in the initial loop will not be touched again + // in . + bool isSimpleStackMain = + (isMainDimDefined && justifyContent == CSS_JUSTIFY_FLEX_START) || + (!isMainDimDefined && justifyContent != CSS_JUSTIFY_CENTER); + int firstComplexMain = (isSimpleStackMain ? childCount : startLine); + + // Use the initial line loop to position children in the cross axis for + // as long as they are relatively positioned with alignment STRETCH or + // FLEX_START. Children that are immediately stacked in the initial loop + // will not be touched again in . + bool isSimpleStackCross = true; + int firstComplexCross = childCount; + css_node_t* firstFlexChild = NULL; css_node_t* currentFlexChild = NULL; + float mainDim = leadingPaddingAndBorderMain; + float crossDim = 0; + float maxWidth; for (i = startLine; i < childCount; ++i) { child = node->get_child(node->context, i); + child->line_index = linesCount; child->next_absolute_child = NULL; child->next_flex_child = NULL; + css_align_t alignItem = getAlignItem(node, child); + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass - if (getAlignItem(node, child) == CSS_ALIGN_STRETCH && + if (alignItem == CSS_ALIGN_STRETCH && child->style.position_type == CSS_POSITION_RELATIVE && isCrossDimDefined && !isDimDefined(child, crossAxis)) { @@ -753,6 +777,44 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction alreadyComputedNextLayout = 1; break; } + + // Disable simple stacking in the main axis for the current line as + // we found a non-trivial child-> The remaining children will be laid out + // in . + if (isSimpleStackMain && + (child->style.position_type != CSS_POSITION_RELATIVE || isFlex(child))) { + isSimpleStackMain = false; + firstComplexMain = i; + } + + // Disable simple stacking in the cross axis for the current line as + // we found a non-trivial child-> The remaining children will be laid out + // in . + if (isSimpleStackCross && + (child->style.position_type != CSS_POSITION_RELATIVE || + (alignItem != CSS_ALIGN_STRETCH && alignItem != CSS_ALIGN_FLEX_START) || + isUndefined(child->layout.dimensions[dim[crossAxis]]))) { + isSimpleStackCross = false; + firstComplexCross = i; + } + + if (isSimpleStackMain) { + child->layout.position[pos[mainAxis]] += mainDim; + if (isMainDimDefined) { + setTrailingPosition(node, child, mainAxis); + } + + mainDim += getDimWithMargin(child, mainAxis); + crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } + + if (isSimpleStackCross) { + child->layout.position[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross; + if (isCrossDimDefined) { + setTrailingPosition(node, child, crossAxis); + } + } + alreadyComputedNextLayout = 0; mainContentDim += nextContentDim; endLine = i + 1; @@ -833,8 +895,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // We use justifyContent to figure out how to allocate the remaining // space available - } else if (node->style.justify_content != CSS_JUSTIFY_FLEX_START) { - css_justify_t justifyContent = node->style.justify_content; + } else if (justifyContent != CSS_JUSTIFY_FLEX_START) { if (justifyContent == CSS_JUSTIFY_CENTER) { leadingMainDim = remainingMainDim / 2; } else if (justifyContent == CSS_JUSTIFY_FLEX_END) { @@ -861,12 +922,10 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction // find their position. In order to do that, we accumulate data in // variables that are also useful to compute the total dimensions of the // container! - float crossDim = 0; - float mainDim = leadingMainDim + leadingPaddingAndBorderMain; + mainDim += leadingMainDim; - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexMain; i < endLine; ++i) { child = node->get_child(node->context, i); - child->line_index = linesCount; if (child->style.position_type == CSS_POSITION_ABSOLUTE && isPosDefined(child, leading[mainAxis])) { @@ -912,7 +971,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, css_direction } // Position elements in the cross axis - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexCross; i < endLine; ++i) { child = node->get_child(node->context, i); if (child->style.position_type == CSS_POSITION_ABSOLUTE && diff --git a/src/Layout.js b/src/Layout.js index 5295c840..e97258e9 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -458,6 +458,8 @@ var computeLayout = (function() { var/*bool*/ isNodeFlexWrap = isFlexWrap(node); + var/*css_justify_t*/ justifyContent = getJustifyContent(node); + var/*float*/ leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); var/*float*/ leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); var/*float*/ paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); @@ -504,19 +506,41 @@ var computeLayout = (function() { var/*float*/ totalFlexible = 0; var/*int*/ nonFlexibleChildrenCount = 0; + // Use the line loop to position children in the main axis for as long + // as they are using a simple stacking behaviour. Children that are + // immediately stacked in the initial loop will not be touched again + // in . + var/*bool*/ isSimpleStackMain = + (isMainDimDefined && justifyContent == CSS_JUSTIFY_FLEX_START) || + (!isMainDimDefined && justifyContent != CSS_JUSTIFY_CENTER); + var/*int*/ firstComplexMain = (isSimpleStackMain ? childCount : startLine); + + // Use the initial line loop to position children in the cross axis for + // as long as they are relatively positioned with alignment STRETCH or + // FLEX_START. Children that are immediately stacked in the initial loop + // will not be touched again in . + var/*bool*/ isSimpleStackCross = true; + var/*int*/ firstComplexCross = childCount; + var/*css_node_t**/ firstFlexChild = null; var/*css_node_t**/ currentFlexChild = null; + var/*float*/ mainDim = leadingPaddingAndBorderMain; + var/*float*/ crossDim = 0; + var/*float*/ maxWidth; for (i = startLine; i < childCount; ++i) { child = node.children[i]; + child.lineIndex = linesCount; child.nextAbsoluteChild = null; child.nextFlexChild = null; + var/*css_align_t*/ alignItem = getAlignItem(node, child); + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass - if (getAlignItem(node, child) === CSS_ALIGN_STRETCH && + if (alignItem === CSS_ALIGN_STRETCH && getPositionType(child) === CSS_POSITION_RELATIVE && isCrossDimDefined && !isDimDefined(child, crossAxis)) { @@ -621,6 +645,44 @@ var computeLayout = (function() { alreadyComputedNextLayout = 1; break; } + + // Disable simple stacking in the main axis for the current line as + // we found a non-trivial child. The remaining children will be laid out + // in . + if (isSimpleStackMain && + (getPositionType(child) != CSS_POSITION_RELATIVE || isFlex(child))) { + isSimpleStackMain = false; + firstComplexMain = i; + } + + // Disable simple stacking in the cross axis for the current line as + // we found a non-trivial child. The remaining children will be laid out + // in . + if (isSimpleStackCross && + (getPositionType(child) != CSS_POSITION_RELATIVE || + (alignItem !== CSS_ALIGN_STRETCH && alignItem != CSS_ALIGN_FLEX_START) || + isUndefined(child.layout[dim[crossAxis]]))) { + isSimpleStackCross = false; + firstComplexCross = i; + } + + if (isSimpleStackMain) { + child.layout[pos[mainAxis]] += mainDim; + if (isMainDimDefined) { + setTrailingPosition(node, child, mainAxis); + } + + mainDim += getDimWithMargin(child, mainAxis); + crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } + + if (isSimpleStackCross) { + child.layout[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross; + if (isCrossDimDefined) { + setTrailingPosition(node, child, crossAxis); + } + } + alreadyComputedNextLayout = 0; mainContentDim += nextContentDim; endLine = i + 1; @@ -701,8 +763,7 @@ var computeLayout = (function() { // We use justifyContent to figure out how to allocate the remaining // space available - } else if (getJustifyContent(node) !== CSS_JUSTIFY_FLEX_START) { - var/*css_justify_t*/ justifyContent = getJustifyContent(node); + } else if (justifyContent !== CSS_JUSTIFY_FLEX_START) { if (justifyContent === CSS_JUSTIFY_CENTER) { leadingMainDim = remainingMainDim / 2; } else if (justifyContent === CSS_JUSTIFY_FLEX_END) { @@ -729,12 +790,10 @@ var computeLayout = (function() { // find their position. In order to do that, we accumulate data in // variables that are also useful to compute the total dimensions of the // container! - var/*float*/ crossDim = 0; - var/*float*/ mainDim = leadingMainDim + leadingPaddingAndBorderMain; + mainDim += leadingMainDim; - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexMain; i < endLine; ++i) { child = node.children[i]; - child.lineIndex = linesCount; if (getPositionType(child) === CSS_POSITION_ABSOLUTE && isPosDefined(child, leading[mainAxis])) { @@ -780,7 +839,7 @@ var computeLayout = (function() { } // Position elements in the cross axis - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexCross; i < endLine; ++i) { child = node.children[i]; if (getPositionType(child) === CSS_POSITION_ABSOLUTE && diff --git a/src/java/src/com/facebook/csslayout/LayoutEngine.java b/src/java/src/com/facebook/csslayout/LayoutEngine.java index 68dc7fdb..2ed0eb85 100644 --- a/src/java/src/com/facebook/csslayout/LayoutEngine.java +++ b/src/java/src/com/facebook/csslayout/LayoutEngine.java @@ -407,6 +407,8 @@ public class LayoutEngine { boolean isNodeFlexWrap = isFlexWrap(node); + CSSJustify justifyContent = node.style.justifyContent; + float leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis); float leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis); float paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis); @@ -453,19 +455,41 @@ public class LayoutEngine { float totalFlexible = 0; int nonFlexibleChildrenCount = 0; + // Use the line loop to position children in the main axis for as long + // as they are using a simple stacking behaviour. Children that are + // immediately stacked in the initial loop will not be touched again + // in . + boolean isSimpleStackMain = + (isMainDimDefined && justifyContent == CSSJustify.FLEX_START) || + (!isMainDimDefined && justifyContent != CSSJustify.CENTER); + int firstComplexMain = (isSimpleStackMain ? childCount : startLine); + + // Use the initial line loop to position children in the cross axis for + // as long as they are relatively positioned with alignment STRETCH or + // FLEX_START. Children that are immediately stacked in the initial loop + // will not be touched again in . + boolean isSimpleStackCross = true; + int firstComplexCross = childCount; + CSSNode firstFlexChild = null; CSSNode currentFlexChild = null; + float mainDim = leadingPaddingAndBorderMain; + float crossDim = 0; + float maxWidth; for (i = startLine; i < childCount; ++i) { child = node.getChildAt(i); + child.lineIndex = linesCount; child.nextAbsoluteChild = null; child.nextFlexChild = null; + CSSAlign alignItem = getAlignItem(node, child); + // Pre-fill cross axis dimensions when the child is using stretch before // we call the recursive layout pass - if (getAlignItem(node, child) == CSSAlign.STRETCH && + if (alignItem == CSSAlign.STRETCH && child.style.positionType == CSSPositionType.RELATIVE && isCrossDimDefined && !isDimDefined(child, crossAxis)) { @@ -570,6 +594,44 @@ public class LayoutEngine { alreadyComputedNextLayout = 1; break; } + + // Disable simple stacking in the main axis for the current line as + // we found a non-trivial child. The remaining children will be laid out + // in . + if (isSimpleStackMain && + (child.style.positionType != CSSPositionType.RELATIVE || isFlex(child))) { + isSimpleStackMain = false; + firstComplexMain = i; + } + + // Disable simple stacking in the cross axis for the current line as + // we found a non-trivial child. The remaining children will be laid out + // in . + if (isSimpleStackCross && + (child.style.positionType != CSSPositionType.RELATIVE || + (alignItem != CSSAlign.STRETCH && alignItem != CSSAlign.FLEX_START) || + isUndefined(child.layout.dimensions[dim[crossAxis]]))) { + isSimpleStackCross = false; + firstComplexCross = i; + } + + if (isSimpleStackMain) { + child.layout.position[pos[mainAxis]] += mainDim; + if (isMainDimDefined) { + setTrailingPosition(node, child, mainAxis); + } + + mainDim += getDimWithMargin(child, mainAxis); + crossDim = Math.max(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis))); + } + + if (isSimpleStackCross) { + child.layout.position[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross; + if (isCrossDimDefined) { + setTrailingPosition(node, child, crossAxis); + } + } + alreadyComputedNextLayout = 0; mainContentDim += nextContentDim; endLine = i + 1; @@ -650,8 +712,7 @@ public class LayoutEngine { // We use justifyContent to figure out how to allocate the remaining // space available - } else if (node.style.justifyContent != CSSJustify.FLEX_START) { - CSSJustify justifyContent = node.style.justifyContent; + } else if (justifyContent != CSSJustify.FLEX_START) { if (justifyContent == CSSJustify.CENTER) { leadingMainDim = remainingMainDim / 2; } else if (justifyContent == CSSJustify.FLEX_END) { @@ -678,12 +739,10 @@ public class LayoutEngine { // find their position. In order to do that, we accumulate data in // variables that are also useful to compute the total dimensions of the // container! - float crossDim = 0; - float mainDim = leadingMainDim + leadingPaddingAndBorderMain; + mainDim += leadingMainDim; - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexMain; i < endLine; ++i) { child = node.getChildAt(i); - child.lineIndex = linesCount; if (child.style.positionType == CSSPositionType.ABSOLUTE && isPosDefined(child, leading[mainAxis])) { @@ -729,7 +788,7 @@ public class LayoutEngine { } // Position elements in the cross axis - for (i = startLine; i < endLine; ++i) { + for (i = firstComplexCross; i < endLine; ++i) { child = node.getChildAt(i); if (child.style.positionType == CSSPositionType.ABSOLUTE &&