Implement (padding|border|margin)-(start|end) support
This commit is contained in:
@@ -18,6 +18,8 @@ public class LayoutEngine {
|
||||
LEFT,
|
||||
BOTTOM,
|
||||
RIGHT,
|
||||
START,
|
||||
END,
|
||||
}
|
||||
|
||||
private static enum DimensionIndex {
|
||||
@@ -191,11 +193,37 @@ public class LayoutEngine {
|
||||
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) {
|
||||
if (isRowDirection(axis)) {
|
||||
float leadingMargin = getMargin(node, PositionIndex.START);
|
||||
if (!CSSConstants.isUndefined(leadingMargin)) {
|
||||
return leadingMargin;
|
||||
}
|
||||
}
|
||||
|
||||
return getMargin(node, getLeading(axis));
|
||||
}
|
||||
|
||||
private static float getTrailingMargin(CSSNode node, CSSFlexDirection axis) {
|
||||
if (isRowDirection(axis)) {
|
||||
float trailingMargin = getMargin(node, PositionIndex.END);
|
||||
if (!CSSConstants.isUndefined(trailingMargin)) {
|
||||
return trailingMargin;
|
||||
}
|
||||
}
|
||||
|
||||
return getMargin(node, getTrailing(axis));
|
||||
}
|
||||
|
||||
private static float getPadding(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
@@ -206,11 +234,37 @@ public class LayoutEngine {
|
||||
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) {
|
||||
if (isRowDirection(axis)) {
|
||||
float leadingPadding = getPadding(node, PositionIndex.START);
|
||||
if (!CSSConstants.isUndefined(leadingPadding)) {
|
||||
return leadingPadding;
|
||||
}
|
||||
}
|
||||
|
||||
return getPadding(node, getLeading(axis));
|
||||
}
|
||||
|
||||
private static float getTrailingPadding(CSSNode node, CSSFlexDirection axis) {
|
||||
if (isRowDirection(axis)) {
|
||||
float trailingPadding = getPadding(node, PositionIndex.END);
|
||||
if (!CSSConstants.isUndefined(trailingPadding)) {
|
||||
return trailingPadding;
|
||||
}
|
||||
}
|
||||
|
||||
return getPadding(node, getTrailing(axis));
|
||||
}
|
||||
|
||||
private static float getBorder(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
@@ -221,27 +275,55 @@ public class LayoutEngine {
|
||||
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 getPaddingAndBorder(CSSNode node, PositionIndex position) {
|
||||
return getPadding(node, position) + getBorder(node, position);
|
||||
private static float getLeadingBorder(CSSNode node, CSSFlexDirection axis) {
|
||||
if (isRowDirection(axis)) {
|
||||
float leadingBorder = getBorder(node, PositionIndex.START);
|
||||
if (!CSSConstants.isUndefined(leadingBorder)) {
|
||||
return leadingBorder;
|
||||
}
|
||||
}
|
||||
|
||||
return getBorder(node, getLeading(axis));
|
||||
}
|
||||
|
||||
private static float getTrailingBorder(CSSNode node, CSSFlexDirection axis) {
|
||||
if (isRowDirection(axis)) {
|
||||
float trailingBorder = getBorder(node, PositionIndex.END);
|
||||
if (!CSSConstants.isUndefined(trailingBorder)) {
|
||||
return trailingBorder;
|
||||
}
|
||||
}
|
||||
|
||||
return getBorder(node, getTrailing(axis));
|
||||
}
|
||||
|
||||
private static float getLeadingPaddingAndBorder(CSSNode node, CSSFlexDirection axis) {
|
||||
return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);
|
||||
}
|
||||
|
||||
private static float getTrailingPaddingAndBorder(CSSNode node, CSSFlexDirection axis) {
|
||||
return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);
|
||||
}
|
||||
|
||||
private static float getBorderAxis(CSSNode node, CSSFlexDirection axis) {
|
||||
return getBorder(node, getLeading(axis)) + getBorder(node, getTrailing(axis));
|
||||
return getLeadingBorder(node, axis) + getTrailingBorder(node, axis);
|
||||
}
|
||||
|
||||
private static float getMarginAxis(CSSNode node, CSSFlexDirection axis) {
|
||||
return getMargin(node, getLeading(axis)) + getMargin(node, getTrailing(axis));
|
||||
return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);
|
||||
}
|
||||
|
||||
private static float getPaddingAndBorderAxis(CSSNode node, CSSFlexDirection axis) {
|
||||
return getPaddingAndBorder(
|
||||
node,
|
||||
getLeading(axis)) + getPaddingAndBorder(node, getTrailing(axis));
|
||||
return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis);
|
||||
}
|
||||
|
||||
private static float boundAxis(CSSNode node, CSSFlexDirection axis, float value) {
|
||||
@@ -385,8 +467,8 @@ public class LayoutEngine {
|
||||
|
||||
private static float getDimWithMargin(CSSNode node, CSSFlexDirection axis) {
|
||||
return getLayoutDimension(node, getDim(axis)) +
|
||||
getMargin(node, getLeading(axis)) +
|
||||
getMargin(node, getTrailing(axis));
|
||||
getLeadingMargin(node, axis) +
|
||||
getTrailingMargin(node, axis);
|
||||
}
|
||||
|
||||
private static boolean needsRelayout(CSSNode node, float parentMaxWidth) {
|
||||
@@ -437,13 +519,13 @@ public class LayoutEngine {
|
||||
|
||||
// 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)) + getMargin(node, getLeading(mainAxis)) +
|
||||
setLayoutPosition(node, getLeading(mainAxis), getLayoutPosition(node, getLeading(mainAxis)) + getLeadingMargin(node, mainAxis) +
|
||||
getRelativePosition(node, mainAxis));
|
||||
setLayoutPosition(node, getTrailing(mainAxis), getLayoutPosition(node, getTrailing(mainAxis)) + getMargin(node, getTrailing(mainAxis)) +
|
||||
setLayoutPosition(node, getTrailing(mainAxis), getLayoutPosition(node, getTrailing(mainAxis)) + getTrailingMargin(node, mainAxis) +
|
||||
getRelativePosition(node, mainAxis));
|
||||
setLayoutPosition(node, getLeading(crossAxis), getLayoutPosition(node, getLeading(crossAxis)) + getMargin(node, getLeading(crossAxis)) +
|
||||
setLayoutPosition(node, getLeading(crossAxis), getLayoutPosition(node, getLeading(crossAxis)) + getLeadingMargin(node, crossAxis) +
|
||||
getRelativePosition(node, crossAxis));
|
||||
setLayoutPosition(node, getTrailing(crossAxis), getLayoutPosition(node, getTrailing(crossAxis)) + getMargin(node, getTrailing(crossAxis)) +
|
||||
setLayoutPosition(node, getTrailing(crossAxis), getLayoutPosition(node, getTrailing(crossAxis)) + getTrailingMargin(node, crossAxis) +
|
||||
getRelativePosition(node, crossAxis));
|
||||
|
||||
if (isMeasureDefined(node)) {
|
||||
@@ -725,7 +807,7 @@ public class LayoutEngine {
|
||||
// container!
|
||||
float crossDim = 0;
|
||||
float mainDim = leadingMainDim +
|
||||
getPaddingAndBorder(node, getLeading(mainAxis));
|
||||
getLeadingPaddingAndBorder(node, mainAxis);
|
||||
|
||||
for (i = startLine; i < endLine; ++i) {
|
||||
child = node.getChildAt(i);
|
||||
@@ -736,8 +818,8 @@ public class LayoutEngine {
|
||||
// defined, we override the position to whatever the user said
|
||||
// (and margin/border).
|
||||
setLayoutPosition(child, getPos(mainAxis), getPosition(child, getLeading(mainAxis)) +
|
||||
getBorder(node, getLeading(mainAxis)) +
|
||||
getMargin(child, getLeading(mainAxis)));
|
||||
getLeadingBorder(node, mainAxis) +
|
||||
getLeadingMargin(child, mainAxis));
|
||||
} else {
|
||||
// If the child is position absolute (without top/left) or relative,
|
||||
// we put it at the current accumulated offset.
|
||||
@@ -784,11 +866,11 @@ public class LayoutEngine {
|
||||
// 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)) +
|
||||
getBorder(node, getLeading(crossAxis)) +
|
||||
getMargin(child, getLeading(crossAxis)));
|
||||
getLeadingBorder(node, crossAxis) +
|
||||
getLeadingMargin(child, crossAxis));
|
||||
|
||||
} else {
|
||||
float leadingCrossDim = getPaddingAndBorder(node, getLeading(crossAxis));
|
||||
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
|
||||
@@ -823,6 +905,11 @@ public class LayoutEngine {
|
||||
|
||||
// And we apply the position
|
||||
setLayoutPosition(child, getPos(crossAxis), getLayoutPosition(child, getPos(crossAxis)) + linesCrossDim + leadingCrossDim);
|
||||
|
||||
// Define the trailing position accordingly.
|
||||
if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) {
|
||||
setTrailingPosition(node, child, crossAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,22 +918,21 @@ public class LayoutEngine {
|
||||
startLine = endLine;
|
||||
}
|
||||
|
||||
boolean needsMainTrailingPos = false;
|
||||
boolean needsCrossTrailingPos = false;
|
||||
|
||||
// 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(
|
||||
// We're missing the last padding at this point to get the final
|
||||
// dimension
|
||||
boundAxis(node, mainAxis, linesMainDim + getPaddingAndBorder(node, getTrailing(mainAxis))),
|
||||
boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)),
|
||||
// We can never assign a width smaller than the padding and borders
|
||||
getPaddingAndBorderAxis(node, mainAxis)
|
||||
));
|
||||
|
||||
// Now that the width is defined, we should update the trailing
|
||||
// positions for the children.
|
||||
for (i = 0; i < node.getChildCount(); ++i) {
|
||||
setTrailingPosition(node, node.getChildAt(i), mainAxis);
|
||||
}
|
||||
needsMainTrailingPos = true;
|
||||
}
|
||||
|
||||
if (CSSConstants.isUndefined(getLayoutDimension(node, getDim(crossAxis)))) {
|
||||
@@ -857,9 +943,27 @@ public class LayoutEngine {
|
||||
boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)),
|
||||
getPaddingAndBorderAxis(node, crossAxis)
|
||||
));
|
||||
|
||||
needsCrossTrailingPos = true;
|
||||
}
|
||||
|
||||
// <Loop E> Calculate dimensions for absolutely positioned elements
|
||||
// <Loop E> Set trailing position if necessary
|
||||
|
||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||
for (i = 0; i < node.getChildCount(); ++i) {
|
||||
child = node.getChildAt(i);
|
||||
|
||||
if (needsMainTrailingPos) {
|
||||
setTrailingPosition(node, child, mainAxis);
|
||||
}
|
||||
|
||||
if (needsCrossTrailingPos) {
|
||||
setTrailingPosition(node, child, crossAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <Loop F> Calculate dimensions for absolutely positioned elements
|
||||
|
||||
for (i = 0; i < node.getChildCount(); ++i) {
|
||||
child = node.getChildAt(i);
|
||||
|
@@ -40,10 +40,18 @@ public class Spacing {
|
||||
* {@code marginHorizontal}.
|
||||
*/
|
||||
public static final int HORIZONTAL = 5;
|
||||
/**
|
||||
* Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left.
|
||||
*/
|
||||
public static final int START = 6;
|
||||
/**
|
||||
* Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left.
|
||||
*/
|
||||
public static final int END = 7;
|
||||
/**
|
||||
* Spacing type that represents all directions (left, top, right, bottom). E.g. {@code margin}.
|
||||
*/
|
||||
public static final int ALL = 6;
|
||||
public static final int ALL = 8;
|
||||
|
||||
private final float[] mSpacing = newFullSpacingArray();
|
||||
private final float[] mDefaultSpacing = newSpacingResultArray();
|
||||
@@ -114,6 +122,7 @@ public class Spacing {
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -127,6 +136,11 @@ public class Spacing {
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
defaultValue,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,6 +184,22 @@ public class Spacing {
|
||||
: !CSSConstants.isUndefined(mSpacing[ALL])
|
||||
? mSpacing[ALL]
|
||||
: mDefaultSpacing[RIGHT];
|
||||
mSpacingResult[START] =
|
||||
!CSSConstants.isUndefined(mSpacing[START])
|
||||
? mSpacing[START]
|
||||
: !CSSConstants.isUndefined(mSpacing[HORIZONTAL])
|
||||
? mSpacing[HORIZONTAL]
|
||||
: !CSSConstants.isUndefined(mSpacing[ALL])
|
||||
? mSpacing[ALL]
|
||||
: mDefaultSpacing[START];
|
||||
mSpacingResult[END] =
|
||||
!CSSConstants.isUndefined(mSpacing[END])
|
||||
? mSpacing[END]
|
||||
: !CSSConstants.isUndefined(mSpacing[HORIZONTAL])
|
||||
? mSpacing[HORIZONTAL]
|
||||
: !CSSConstants.isUndefined(mSpacing[ALL])
|
||||
? mSpacing[ALL]
|
||||
: mDefaultSpacing[END];
|
||||
mDirty = false;
|
||||
}
|
||||
}
|
||||
|
@@ -374,6 +374,8 @@ public class LayoutEngineTest {
|
||||
node_0.setMargin(Spacing.TOP, 10);
|
||||
node_0.setMargin(Spacing.RIGHT, 10);
|
||||
node_0.setMargin(Spacing.BOTTOM, 10);
|
||||
node_0.setMargin(Spacing.START, 10);
|
||||
node_0.setMargin(Spacing.END, 10);
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -400,6 +402,8 @@ public class LayoutEngineTest {
|
||||
node_0.setMargin(Spacing.TOP, 10);
|
||||
node_0.setMargin(Spacing.RIGHT, 10);
|
||||
node_0.setMargin(Spacing.BOTTOM, 10);
|
||||
node_0.setMargin(Spacing.START, 10);
|
||||
node_0.setMargin(Spacing.END, 10);
|
||||
addChildren(node_0, 3);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -410,6 +414,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 50);
|
||||
node_1.setMargin(Spacing.RIGHT, 50);
|
||||
node_1.setMargin(Spacing.BOTTOM, 50);
|
||||
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;
|
||||
@@ -417,6 +423,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 25);
|
||||
node_1.setMargin(Spacing.RIGHT, 25);
|
||||
node_1.setMargin(Spacing.BOTTOM, 25);
|
||||
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;
|
||||
@@ -424,6 +432,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 10);
|
||||
node_1.setMargin(Spacing.RIGHT, 10);
|
||||
node_1.setMargin(Spacing.BOTTOM, 10);
|
||||
node_1.setMargin(Spacing.START, 10);
|
||||
node_1.setMargin(Spacing.END, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,6 +481,8 @@ public class LayoutEngineTest {
|
||||
node_0.setMargin(Spacing.TOP, 10);
|
||||
node_0.setMargin(Spacing.RIGHT, 10);
|
||||
node_0.setMargin(Spacing.BOTTOM, 10);
|
||||
node_0.setMargin(Spacing.START, 10);
|
||||
node_0.setMargin(Spacing.END, 10);
|
||||
addChildren(node_0, 3);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -481,6 +493,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 50);
|
||||
node_1.setMargin(Spacing.RIGHT, 50);
|
||||
node_1.setMargin(Spacing.BOTTOM, 50);
|
||||
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;
|
||||
@@ -488,6 +502,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 25);
|
||||
node_1.setMargin(Spacing.RIGHT, 25);
|
||||
node_1.setMargin(Spacing.BOTTOM, 25);
|
||||
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;
|
||||
@@ -495,6 +511,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 10);
|
||||
node_1.setMargin(Spacing.RIGHT, 10);
|
||||
node_1.setMargin(Spacing.BOTTOM, 10);
|
||||
node_1.setMargin(Spacing.START, 10);
|
||||
node_1.setMargin(Spacing.END, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2161,6 +2179,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 5);
|
||||
node_1.setMargin(Spacing.RIGHT, 5);
|
||||
node_1.setMargin(Spacing.BOTTOM, 5);
|
||||
node_1.setMargin(Spacing.START, 5);
|
||||
node_1.setMargin(Spacing.END, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2200,6 +2220,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 5);
|
||||
node_1.setMargin(Spacing.RIGHT, 5);
|
||||
node_1.setMargin(Spacing.BOTTOM, 5);
|
||||
node_1.setMargin(Spacing.START, 5);
|
||||
node_1.setMargin(Spacing.END, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2426,6 +2448,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 10);
|
||||
node_2.setMargin(Spacing.RIGHT, 10);
|
||||
node_2.setMargin(Spacing.BOTTOM, 10);
|
||||
node_2.setMargin(Spacing.START, 10);
|
||||
node_2.setMargin(Spacing.END, 10);
|
||||
node_2 = node_1.getChildAt(1);
|
||||
node_2.style.height = 100;
|
||||
}
|
||||
@@ -2487,6 +2511,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 10);
|
||||
node_2.setMargin(Spacing.RIGHT, 10);
|
||||
node_2.setMargin(Spacing.BOTTOM, 10);
|
||||
node_2.setMargin(Spacing.START, 10);
|
||||
node_2.setMargin(Spacing.END, 10);
|
||||
node_2 = node_1.getChildAt(1);
|
||||
node_2.style.height = 100;
|
||||
}
|
||||
@@ -2646,6 +2672,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 5);
|
||||
node_0.setPadding(Spacing.RIGHT, 5);
|
||||
node_0.setPadding(Spacing.BOTTOM, 5);
|
||||
node_0.setPadding(Spacing.START, 5);
|
||||
node_0.setPadding(Spacing.END, 5);
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -2670,6 +2698,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 5);
|
||||
node_0.setPadding(Spacing.RIGHT, 5);
|
||||
node_0.setPadding(Spacing.BOTTOM, 5);
|
||||
node_0.setPadding(Spacing.START, 5);
|
||||
node_0.setPadding(Spacing.END, 5);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2708,6 +2738,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 5);
|
||||
node_0.setPadding(Spacing.RIGHT, 5);
|
||||
node_0.setPadding(Spacing.BOTTOM, 5);
|
||||
node_0.setPadding(Spacing.START, 5);
|
||||
node_0.setPadding(Spacing.END, 5);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2716,6 +2748,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 5);
|
||||
node_1.setMargin(Spacing.RIGHT, 5);
|
||||
node_1.setMargin(Spacing.BOTTOM, 5);
|
||||
node_1.setMargin(Spacing.START, 5);
|
||||
node_1.setMargin(Spacing.END, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2755,6 +2789,8 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 10);
|
||||
node_1.setPadding(Spacing.RIGHT, 10);
|
||||
node_1.setPadding(Spacing.BOTTOM, 10);
|
||||
node_1.setPadding(Spacing.START, 10);
|
||||
node_1.setPadding(Spacing.END, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2789,6 +2825,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 50);
|
||||
node_0.setPadding(Spacing.RIGHT, 50);
|
||||
node_0.setPadding(Spacing.BOTTOM, 50);
|
||||
node_0.setPadding(Spacing.START, 50);
|
||||
node_0.setPadding(Spacing.END, 50);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2798,6 +2836,8 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 10);
|
||||
node_1.setPadding(Spacing.RIGHT, 10);
|
||||
node_1.setPadding(Spacing.BOTTOM, 10);
|
||||
node_1.setPadding(Spacing.START, 10);
|
||||
node_1.setPadding(Spacing.END, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2841,6 +2881,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 16);
|
||||
node_2.setMargin(Spacing.RIGHT, 16);
|
||||
node_2.setMargin(Spacing.BOTTOM, 16);
|
||||
node_2.setMargin(Spacing.START, 16);
|
||||
node_2.setMargin(Spacing.END, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3213,6 +3255,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 5);
|
||||
node_0.setPadding(Spacing.RIGHT, 5);
|
||||
node_0.setPadding(Spacing.BOTTOM, 5);
|
||||
node_0.setPadding(Spacing.START, 5);
|
||||
node_0.setPadding(Spacing.END, 5);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -3296,6 +3340,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 20);
|
||||
node_0.setPadding(Spacing.RIGHT, 20);
|
||||
node_0.setPadding(Spacing.BOTTOM, 20);
|
||||
node_0.setPadding(Spacing.START, 20);
|
||||
node_0.setPadding(Spacing.END, 20);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -3920,6 +3966,8 @@ public class LayoutEngineTest {
|
||||
node_0.setBorder(Spacing.TOP, 5);
|
||||
node_0.setBorder(Spacing.RIGHT, 5);
|
||||
node_0.setBorder(Spacing.BOTTOM, 5);
|
||||
node_0.setBorder(Spacing.START, 5);
|
||||
node_0.setBorder(Spacing.END, 5);
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -3981,6 +4029,8 @@ public class LayoutEngineTest {
|
||||
node_0.setBorder(Spacing.TOP, 1);
|
||||
node_0.setBorder(Spacing.RIGHT, 1);
|
||||
node_0.setBorder(Spacing.BOTTOM, 1);
|
||||
node_0.setBorder(Spacing.START, 1);
|
||||
node_0.setBorder(Spacing.END, 1);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -4028,6 +4078,8 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 20);
|
||||
node_1.setPadding(Spacing.RIGHT, 20);
|
||||
node_1.setPadding(Spacing.BOTTOM, 20);
|
||||
node_1.setPadding(Spacing.START, 20);
|
||||
node_1.setPadding(Spacing.END, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4546,6 +4598,8 @@ public class LayoutEngineTest {
|
||||
node_0.setPadding(Spacing.TOP, 10);
|
||||
node_0.setPadding(Spacing.RIGHT, 10);
|
||||
node_0.setPadding(Spacing.BOTTOM, 10);
|
||||
node_0.setPadding(Spacing.START, 10);
|
||||
node_0.setPadding(Spacing.END, 10);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -4555,6 +4609,8 @@ public class LayoutEngineTest {
|
||||
node_1.setMargin(Spacing.TOP, 10);
|
||||
node_1.setMargin(Spacing.RIGHT, 10);
|
||||
node_1.setMargin(Spacing.BOTTOM, 10);
|
||||
node_1.setMargin(Spacing.START, 10);
|
||||
node_1.setMargin(Spacing.END, 10);
|
||||
addChildren(node_1, 1);
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
@@ -4779,6 +4835,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 20);
|
||||
node_2.setMargin(Spacing.RIGHT, 20);
|
||||
node_2.setMargin(Spacing.BOTTOM, 20);
|
||||
node_2.setMargin(Spacing.START, 20);
|
||||
node_2.setMargin(Spacing.END, 20);
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "loooooooooong with space";
|
||||
}
|
||||
@@ -4836,6 +4894,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 20);
|
||||
node_2.setMargin(Spacing.RIGHT, 20);
|
||||
node_2.setMargin(Spacing.BOTTOM, 20);
|
||||
node_2.setMargin(Spacing.START, 20);
|
||||
node_2.setMargin(Spacing.END, 20);
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "loooooooooong with space";
|
||||
}
|
||||
@@ -4891,6 +4951,8 @@ public class LayoutEngineTest {
|
||||
node_2.setMargin(Spacing.TOP, 20);
|
||||
node_2.setMargin(Spacing.RIGHT, 20);
|
||||
node_2.setMargin(Spacing.BOTTOM, 20);
|
||||
node_2.setMargin(Spacing.START, 20);
|
||||
node_2.setMargin(Spacing.END, 20);
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "loooooooooong with space";
|
||||
}
|
||||
@@ -7126,6 +7188,8 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 10);
|
||||
node_1.setPadding(Spacing.RIGHT, 10);
|
||||
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;
|
||||
@@ -7190,10 +7254,14 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 10);
|
||||
node_1.setPadding(Spacing.RIGHT, 10);
|
||||
node_1.setPadding(Spacing.BOTTOM, 10);
|
||||
node_1.setPadding(Spacing.START, 10);
|
||||
node_1.setPadding(Spacing.END, 10);
|
||||
node_1.setBorder(Spacing.LEFT, 1);
|
||||
node_1.setBorder(Spacing.TOP, 1);
|
||||
node_1.setBorder(Spacing.RIGHT, 1);
|
||||
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;
|
||||
@@ -7258,6 +7326,8 @@ public class LayoutEngineTest {
|
||||
node_1.setPadding(Spacing.TOP, 10);
|
||||
node_1.setPadding(Spacing.RIGHT, 10);
|
||||
node_1.setPadding(Spacing.BOTTOM, 10);
|
||||
node_1.setPadding(Spacing.START, 10);
|
||||
node_1.setPadding(Spacing.END, 10);
|
||||
addChildren(node_1, 1);
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
@@ -7475,5 +7545,356 @@ public class LayoutEngineTest {
|
||||
|
||||
test("should correctly space wrapped nodes", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase168()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 200;
|
||||
node_0.setPadding(Spacing.LEFT, 5);
|
||||
node_0.setPadding(Spacing.RIGHT, 5);
|
||||
node_0.setPadding(Spacing.START, 15);
|
||||
node_0.setPadding(Spacing.END, 15);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should give start/end padding precedence over left/right padding", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase169()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 200;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.height = 50;
|
||||
node_1.setMargin(Spacing.LEFT, 5);
|
||||
node_1.setMargin(Spacing.RIGHT, 5);
|
||||
node_1.setMargin(Spacing.START, 15);
|
||||
node_1.setMargin(Spacing.END, 15);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should give start/end margin precedence over left/right margin", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase170()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 200;
|
||||
node_0.setBorder(Spacing.LEFT, 5);
|
||||
node_0.setBorder(Spacing.RIGHT, 5);
|
||||
node_0.setBorder(Spacing.START, 15);
|
||||
node_0.setBorder(Spacing.END, 15);
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should give start/end border precedence over left/right border", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase171()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end padding", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase172()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.direction = CSSDirection.RTL;
|
||||
node_0.style.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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end padding in rtl", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase173()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 200;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.height = 50;
|
||||
node_1.setMargin(Spacing.START, 15);
|
||||
node_1.setMargin(Spacing.END, 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 = 200;
|
||||
node_0.layout.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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end margin", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase174()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.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.setMargin(Spacing.START, 15);
|
||||
node_1.setMargin(Spacing.END, 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 = 200;
|
||||
node_0.layout.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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end margin in rtl", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase175()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end border", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase176()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.direction = CSSDirection.RTL;
|
||||
node_0.style.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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with correct start/end border in rtl", root_node, root_layout);
|
||||
}
|
||||
/** END_GENERATED **/
|
||||
}
|
||||
|
Reference in New Issue
Block a user