Merge pull request #23 from kmagiera/javaimprovements
Couple of major improvements for Java version.
This commit is contained in:
5
Makefile
5
Makefile
@@ -18,10 +18,11 @@ c_test: c
|
||||
java: transpile_all src/java
|
||||
@if [ ! -f lib/junit4.jar ]; then mkdir lib/; wget -O lib/junit4.jar http://search.maven.org/remotecontent?filepath=junit/junit/4.10/junit-4.10.jar; fi
|
||||
@if [ ! -f lib/jsr305.jar ]; then mkdir lib/; wget -O lib/jsr305.jar http://search.maven.org/remotecontent?filepath=net/sourceforge/findbugs/jsr305/1.3.7/jsr305-1.3.7.jar; fi
|
||||
@javac -cp ./lib/junit4.jar:./lib/jsr305.jar -sourcepath ./src/java/src:./src/java/tests src/java/tests/com/facebook/csslayout/*.java
|
||||
@if [ ! -f lib/infer-annotations-1.3.jar ]; then mkdir lib/; wget -O lib/infer-annotations-1.3.jar https://github.com/facebook/buck/raw/master/third-party/java/infer-annotations/infer-annotations-1.3.jar; fi
|
||||
@javac -cp ./lib/junit4.jar:./lib/jsr305.jar:./lib/infer-annotations-1.3.jar -sourcepath ./src/java/src:./src/java/tests src/java/tests/com/facebook/csslayout/*.java
|
||||
|
||||
java_test: java
|
||||
@java -cp ./src/java/src:./src/java/tests:./lib/junit4.jar org.junit.runner.JUnitCore \
|
||||
@java -cp ./src/java/src:./src/java/tests:./lib/junit4.jar:./lib/infer-annotations-1.3.jar org.junit.runner.JUnitCore \
|
||||
com.facebook.csslayout.LayoutEngineTest \
|
||||
com.facebook.csslayout.LayoutCachingTest \
|
||||
com.facebook.csslayout.CSSNodeTest
|
||||
|
@@ -59,10 +59,10 @@ function __transpileSingleTestToJava(code) {
|
||||
function (str, match1, match2) {
|
||||
return 'style.' + match1 + match2[0] + match2.substring(1).toLowerCase();
|
||||
})
|
||||
.replace( // style.margin[CSS_TOP] => style.margin[CSSStyle.SPACING_TOP]
|
||||
.replace( // style.margin[CSS_TOP] => style.margin[Spacing.TOP]
|
||||
/style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT)\]/g,
|
||||
function (str, match1, match2) {
|
||||
return 'style.' + match1 + '[CSSStyle.SPACING_' + match2 + ']';
|
||||
return 'style.' + match1 + '[Spacing.' + match2 + ']';
|
||||
})
|
||||
.replace(/get_child\(.*context\,\s([^\)]+)\)/g, 'getChildAt($1)')
|
||||
.replace(/init_css_node_children/g, 'addChildren')
|
||||
|
@@ -6,13 +6,14 @@
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -38,44 +39,6 @@ public class CSSNode {
|
||||
UP_TO_DATE,
|
||||
}
|
||||
|
||||
public static final int SPACING_ALL = 0;
|
||||
public static final int SPACING_VERTICAL = 1;
|
||||
public static final int SPACING_HORIZONTAL = 2;
|
||||
public static final int SPACING_LEFT = 3;
|
||||
public static final int SPACING_RIGHT = 4;
|
||||
public static final int SPACING_TOP = 5;
|
||||
public static final int SPACING_BOTTOM = 6;
|
||||
|
||||
private final float[] mMargin = new float[] {
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN
|
||||
};
|
||||
|
||||
private final float[] mPadding = new float[] {
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN
|
||||
};
|
||||
|
||||
private final float[] mBorder = new float[] {
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN,
|
||||
Float.NaN
|
||||
};
|
||||
|
||||
// Only one copy kept around to keep from allocating a bunch of MeasureOutput objects
|
||||
// NOT THREAD SAFE! NOT RE-ENTRANT SAFE!
|
||||
private static final MeasureOutput MEASURE_OUTPUT = new MeasureOutput();
|
||||
@@ -90,6 +53,10 @@ public class CSSNode {
|
||||
public void measure(CSSNode node, float width, MeasureOutput measureOutput);
|
||||
}
|
||||
|
||||
private final float[] mMargin = Spacing.newFullSpacingArray();
|
||||
private final float[] mPadding = Spacing.newFullSpacingArray();
|
||||
private final float[] mBorder = Spacing.newFullSpacingArray();
|
||||
|
||||
// VisibleForTesting
|
||||
/*package*/ final CSSStyle style = new CSSStyle();
|
||||
/*package*/ final CSSLayout layout = new CSSLayout();
|
||||
@@ -98,18 +65,9 @@ public class CSSNode {
|
||||
// 4 is kinda arbitrary, but the default of 10 seems really high for an average View.
|
||||
private final ArrayList<CSSNode> mChildren = new ArrayList<CSSNode>(4);
|
||||
|
||||
private CSSNode mParent;
|
||||
private MeasureFunction mMeasureFunction = null;
|
||||
private @Nullable CSSNode mParent;
|
||||
private @Nullable MeasureFunction mMeasureFunction = null;
|
||||
private LayoutState mLayoutState = LayoutState.DIRTY;
|
||||
private int mTag;
|
||||
|
||||
public int getTag() {
|
||||
return mTag;
|
||||
}
|
||||
|
||||
public void setTag(int tag) {
|
||||
mTag = tag;
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return mChildren.size();
|
||||
@@ -134,10 +92,17 @@ public class CSSNode {
|
||||
dirty();
|
||||
}
|
||||
|
||||
public CSSNode getParent() {
|
||||
public @Nullable CSSNode getParent() {
|
||||
return mParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the index of the given child, or -1 if the child doesn't exist in this node.
|
||||
*/
|
||||
public int indexOf(CSSNode child) {
|
||||
return mChildren.indexOf(child);
|
||||
}
|
||||
|
||||
public void setMeasureFunction(MeasureFunction measureFunction) {
|
||||
if (!valuesEqual(mMeasureFunction, measureFunction)) {
|
||||
mMeasureFunction = measureFunction;
|
||||
@@ -155,7 +120,7 @@ public class CSSNode {
|
||||
}
|
||||
MEASURE_OUTPUT.height = CSSConstants.UNDEFINED;
|
||||
MEASURE_OUTPUT.width = CSSConstants.UNDEFINED;
|
||||
mMeasureFunction.measure(this, width, MEASURE_OUTPUT);
|
||||
Assertions.assertNotNull(mMeasureFunction).measure(this, width, MEASURE_OUTPUT);
|
||||
return MEASURE_OUTPUT;
|
||||
}
|
||||
|
||||
@@ -302,40 +267,24 @@ public class CSSNode {
|
||||
}
|
||||
|
||||
public void setMargin(int spacingType, float margin) {
|
||||
setSpacing(mMargin, spacingType, margin, style.margin);
|
||||
setSpacing(mMargin, style.margin, spacingType, margin);
|
||||
}
|
||||
|
||||
public void setPadding(int spacingType, float padding) {
|
||||
setSpacing(mPadding, spacingType, padding, style.padding);
|
||||
setSpacing(mPadding, style.padding, spacingType, padding);
|
||||
}
|
||||
|
||||
public void setBorder(int spacingType, float border) {
|
||||
setSpacing(mBorder, spacingType, border, style.border);
|
||||
setSpacing(mBorder, style.border, spacingType, border);
|
||||
}
|
||||
|
||||
protected void setSpacing(float[] spacingDef, int spacingType, float spacing, float[] cssStyle) {
|
||||
protected void setSpacing(
|
||||
float[] spacingDef,
|
||||
float[] cssStyle,
|
||||
int spacingType,
|
||||
float spacing) {
|
||||
if (!valuesEqual(spacingDef[spacingType], spacing)) {
|
||||
spacingDef[spacingType] = spacing;
|
||||
cssStyle[CSSStyle.SPACING_TOP] =
|
||||
!Float.isNaN(spacingDef[SPACING_TOP]) ? spacingDef[SPACING_TOP]
|
||||
: !Float.isNaN(spacingDef[SPACING_VERTICAL]) ? spacingDef[SPACING_VERTICAL]
|
||||
: !Float.isNaN(spacingDef[SPACING_ALL]) ? spacingDef[SPACING_ALL]
|
||||
: 0;
|
||||
cssStyle[CSSStyle.SPACING_BOTTOM] =
|
||||
!Float.isNaN(spacingDef[SPACING_BOTTOM]) ? spacingDef[SPACING_BOTTOM]
|
||||
: !Float.isNaN(spacingDef[SPACING_VERTICAL]) ? spacingDef[SPACING_VERTICAL]
|
||||
: !Float.isNaN(spacingDef[SPACING_ALL]) ? spacingDef[SPACING_ALL]
|
||||
: 0;
|
||||
cssStyle[CSSStyle.SPACING_LEFT] =
|
||||
!Float.isNaN(spacingDef[SPACING_LEFT]) ? spacingDef[SPACING_LEFT]
|
||||
: !Float.isNaN(spacingDef[SPACING_HORIZONTAL]) ? spacingDef[SPACING_HORIZONTAL]
|
||||
: !Float.isNaN(spacingDef[SPACING_ALL]) ? spacingDef[SPACING_ALL]
|
||||
: 0;
|
||||
cssStyle[CSSStyle.SPACING_RIGHT] =
|
||||
!Float.isNaN(spacingDef[SPACING_RIGHT]) ? spacingDef[SPACING_RIGHT]
|
||||
: !Float.isNaN(spacingDef[SPACING_HORIZONTAL]) ? spacingDef[SPACING_HORIZONTAL]
|
||||
: !Float.isNaN(spacingDef[SPACING_ALL]) ? spacingDef[SPACING_ALL]
|
||||
: 0;
|
||||
Spacing.updateSpacing(spacingDef, cssStyle, spacingType, spacing, 0);
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
@@ -13,11 +13,6 @@ package com.facebook.csslayout;
|
||||
*/
|
||||
public class CSSStyle {
|
||||
|
||||
public static final int SPACING_TOP = 0;
|
||||
public static final int SPACING_RIGHT = 1;
|
||||
public static final int SPACING_BOTTOM = 2;
|
||||
public static final int SPACING_LEFT = 3;
|
||||
|
||||
public CSSFlexDirection flexDirection = CSSFlexDirection.COLUMN;
|
||||
public CSSJustify justifyContent = CSSJustify.FLEX_START;
|
||||
public CSSAlign alignItems = CSSAlign.STRETCH;
|
||||
@@ -26,9 +21,9 @@ public class CSSStyle {
|
||||
public CSSWrap flexWrap = CSSWrap.NOWRAP;
|
||||
public float flex;
|
||||
|
||||
public float[] margin = new float[4];
|
||||
public float[] padding = new float[4];
|
||||
public float[] border = new float[4];
|
||||
public float[] margin = Spacing.newSpacingResultArray();
|
||||
public float[] padding = Spacing.newSpacingResultArray();
|
||||
public float[] border = Spacing.newSpacingResultArray();
|
||||
|
||||
public float positionTop = CSSConstants.UNDEFINED;
|
||||
public float positionBottom = CSSConstants.UNDEFINED;
|
||||
|
@@ -131,13 +131,13 @@ public class LayoutEngine {
|
||||
private static float getMargin(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
return node.style.margin[CSSStyle.SPACING_TOP];
|
||||
return node.style.margin[Spacing.TOP];
|
||||
case BOTTOM:
|
||||
return node.style.margin[CSSStyle.SPACING_BOTTOM];
|
||||
return node.style.margin[Spacing.BOTTOM];
|
||||
case LEFT:
|
||||
return node.style.margin[CSSStyle.SPACING_LEFT];
|
||||
return node.style.margin[Spacing.LEFT];
|
||||
case RIGHT:
|
||||
return node.style.margin[CSSStyle.SPACING_RIGHT];
|
||||
return node.style.margin[Spacing.RIGHT];
|
||||
default:
|
||||
throw new RuntimeException("Someone added a new cardinal direction...");
|
||||
}
|
||||
@@ -146,13 +146,13 @@ public class LayoutEngine {
|
||||
private static float getPadding(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
return node.style.padding[CSSStyle.SPACING_TOP];
|
||||
return node.style.padding[Spacing.TOP];
|
||||
case BOTTOM:
|
||||
return node.style.padding[CSSStyle.SPACING_BOTTOM];
|
||||
return node.style.padding[Spacing.BOTTOM];
|
||||
case LEFT:
|
||||
return node.style.padding[CSSStyle.SPACING_LEFT];
|
||||
return node.style.padding[Spacing.LEFT];
|
||||
case RIGHT:
|
||||
return node.style.padding[CSSStyle.SPACING_RIGHT];
|
||||
return node.style.padding[Spacing.RIGHT];
|
||||
default:
|
||||
throw new RuntimeException("Someone added a new cardinal direction...");
|
||||
}
|
||||
@@ -161,13 +161,13 @@ public class LayoutEngine {
|
||||
private static float getBorder(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
return node.style.border[CSSStyle.SPACING_TOP];
|
||||
return node.style.border[Spacing.TOP];
|
||||
case BOTTOM:
|
||||
return node.style.border[CSSStyle.SPACING_BOTTOM];
|
||||
return node.style.border[Spacing.BOTTOM];
|
||||
case LEFT:
|
||||
return node.style.border[CSSStyle.SPACING_LEFT];
|
||||
return node.style.border[Spacing.LEFT];
|
||||
case RIGHT:
|
||||
return node.style.border[CSSStyle.SPACING_RIGHT];
|
||||
return node.style.border[Spacing.RIGHT];
|
||||
default:
|
||||
throw new RuntimeException("Someone added a new cardinal direction...");
|
||||
}
|
||||
@@ -267,12 +267,12 @@ public class LayoutEngine {
|
||||
node.lastLayout.parentMaxWidth = parentMaxWidth;
|
||||
|
||||
layoutNodeImpl(node, parentMaxWidth);
|
||||
node.markHasNewLayout();
|
||||
|
||||
node.lastLayout.copy(node.layout);
|
||||
} else {
|
||||
node.layout.copy(node.lastLayout);
|
||||
}
|
||||
|
||||
node.markHasNewLayout();
|
||||
}
|
||||
|
||||
private static void layoutNodeImpl(CSSNode node, float parentMaxWidth) {
|
||||
@@ -384,11 +384,12 @@ public class LayoutEngine {
|
||||
// We want to execute the next two loops one per line with flex-wrap
|
||||
int startLine = 0;
|
||||
int endLine = 0;
|
||||
int nextLine = 0;
|
||||
int nextOffset = 0;
|
||||
int alreadyComputedNextLayout = 0;
|
||||
// We aggregate the total dimensions of the container in those two variables
|
||||
float linesCrossDim = 0;
|
||||
float linesMainDim = 0;
|
||||
while (endLine != node.getChildCount()) {
|
||||
while (endLine < node.getChildCount()) {
|
||||
// <Loop A> Layout non flexible children and count children by type
|
||||
|
||||
// mainContentDim is accumulation of the dimensions and margin of all the
|
||||
@@ -432,7 +433,7 @@ public class LayoutEngine {
|
||||
}
|
||||
|
||||
// This is the main recursive call. We layout non flexible children.
|
||||
if (nextLine == 0) {
|
||||
if (alreadyComputedNextLayout == 0) {
|
||||
layoutNode(child, maxWidth);
|
||||
}
|
||||
|
||||
@@ -448,11 +449,14 @@ 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))) &&
|
||||
mainContentDim + nextContentDim > definedMainDim) {
|
||||
nextLine = i + 1;
|
||||
mainContentDim + nextContentDim > definedMainDim &&
|
||||
// If there's only one element, then it's bigger than the content
|
||||
// and needs its own line
|
||||
i != startLine) {
|
||||
alreadyComputedNextLayout = 1;
|
||||
break;
|
||||
}
|
||||
nextLine = 0;
|
||||
alreadyComputedNextLayout = 0;
|
||||
mainContentDim = mainContentDim + nextContentDim;
|
||||
endLine = i + 1;
|
||||
}
|
||||
|
103
src/java/src/com/facebook/csslayout/Spacing.java
Normal file
103
src/java/src/com/facebook/csslayout/Spacing.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
package com.facebook.csslayout;
|
||||
|
||||
/**
|
||||
* Utility class for handling CSS spacing (padding, margin, and borders). This is mostly necessary
|
||||
* to properly implement interactions and updates for properties like margin, marginLeft, and
|
||||
* marginHorizontal. This is not a great API and should probably be updated to use actual objects
|
||||
* for type safety, defaults safety, and simplicity.
|
||||
*/
|
||||
public class Spacing {
|
||||
|
||||
// Indices into FullSpacingArray and SpacingResultArray
|
||||
public static final int LEFT = 0;
|
||||
public static final int TOP = 1;
|
||||
public static final int RIGHT = 2;
|
||||
public static final int BOTTOM = 3;
|
||||
public static final int VERTICAL = 4;
|
||||
public static final int HORIZONTAL = 5;
|
||||
public static final int ALL = 6;
|
||||
|
||||
/**
|
||||
* @return an instance of an array that can be used with {@link #updateSpacing}. Stores
|
||||
* the value for each spacing type or NaN if it hasn't been explicitly set.
|
||||
*/
|
||||
public static float[] newFullSpacingArray() {
|
||||
return new float[] {
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #newSpacingResultArray} filled with zero.
|
||||
*/
|
||||
public static float[] newSpacingResultArray() {
|
||||
return newSpacingResultArray(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an instance of an array used to store the end result of the interactions between the
|
||||
* values in a full spacing array. Use {@link #TOP}, etc to access result values.
|
||||
*/
|
||||
public static float[] newSpacingResultArray(float defaultValue) {
|
||||
return new float[] {
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the fullSpacing from {@link #newFullSpacingArray()} and the spacingResult from
|
||||
* {@link #newSpacingResultArray()} from a View, update them both to reflect a new value for the
|
||||
* given spacingType (e.g. {@link #TOP}). defaultValue specifies the result value that should be
|
||||
* used whenever a spacing property hasn't been set.
|
||||
*/
|
||||
public static void updateSpacing(
|
||||
float[] fullSpacing,
|
||||
float[] spacingResult,
|
||||
int spacingType,
|
||||
float value,
|
||||
float defaultValue) {
|
||||
fullSpacing[spacingType] = value;
|
||||
spacingResult[Spacing.TOP] =
|
||||
!CSSConstants.isUndefined(fullSpacing[Spacing.TOP]) ? fullSpacing[Spacing.TOP]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.VERTICAL]) ?
|
||||
fullSpacing[Spacing.VERTICAL]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.ALL]) ? fullSpacing[Spacing.ALL]
|
||||
: defaultValue;
|
||||
spacingResult[Spacing.BOTTOM] =
|
||||
!CSSConstants.isUndefined(fullSpacing[Spacing.BOTTOM]) ? fullSpacing[Spacing.BOTTOM]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.VERTICAL]) ?
|
||||
fullSpacing[Spacing.VERTICAL]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.ALL]) ? fullSpacing[Spacing.ALL]
|
||||
: defaultValue;
|
||||
spacingResult[Spacing.LEFT] =
|
||||
!CSSConstants.isUndefined(fullSpacing[Spacing.LEFT]) ? fullSpacing[Spacing.LEFT]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.HORIZONTAL]) ?
|
||||
fullSpacing[Spacing.HORIZONTAL]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.ALL]) ? fullSpacing[Spacing.ALL]
|
||||
: defaultValue;
|
||||
spacingResult[Spacing.RIGHT] =
|
||||
!CSSConstants.isUndefined(fullSpacing[Spacing.RIGHT]) ? fullSpacing[Spacing.RIGHT]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.HORIZONTAL]) ?
|
||||
fullSpacing[Spacing.HORIZONTAL]
|
||||
: !CSSConstants.isUndefined(fullSpacing[Spacing.ALL]) ? fullSpacing[Spacing.ALL]
|
||||
: defaultValue;
|
||||
}
|
||||
}
|
@@ -48,7 +48,9 @@ public class LayoutCachingTest {
|
||||
markLayoutAppliedForTree(root);
|
||||
|
||||
root.calculateLayout();
|
||||
assertTreeHasNewLayout(false, root);
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTreeHasNewLayout(false, c0);
|
||||
assertTreeHasNewLayout(false, c1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,11 +60,13 @@ public class LayoutCachingTest {
|
||||
CSSNode c1 = new CSSNode();
|
||||
CSSNode c0c0 = new CSSNode();
|
||||
CSSNode c0c1 = new CSSNode();
|
||||
CSSNode c1c0 = new CSSNode();
|
||||
c0c1.setStyleWidth(200);
|
||||
c0c1.setStyleHeight(200);
|
||||
root.addChildAt(c0, 0);
|
||||
root.addChildAt(c1, 1);
|
||||
c0.addChildAt(c0c0, 0);
|
||||
c0c0.addChildAt(c1c0, 0);
|
||||
|
||||
root.calculateLayout();
|
||||
markLayoutAppliedForTree(root);
|
||||
@@ -74,8 +78,10 @@ public class LayoutCachingTest {
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertTrue(c0c1.hasNewLayout());
|
||||
|
||||
assertFalse(c0c0.hasNewLayout());
|
||||
assertFalse(c1.hasNewLayout());
|
||||
assertTrue(c0c0.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
|
||||
assertFalse(c1c0.hasNewLayout());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,7 +103,7 @@ public class LayoutCachingTest {
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
|
||||
assertFalse(c0.hasNewLayout());
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertFalse(c0c0.hasNewLayout());
|
||||
}
|
||||
|
||||
@@ -114,13 +120,13 @@ public class LayoutCachingTest {
|
||||
root.calculateLayout();
|
||||
markLayoutAppliedForTree(root);
|
||||
|
||||
c1.setMargin(CSSNode.SPACING_LEFT, 10);
|
||||
c1.setMargin(Spacing.LEFT, 10);
|
||||
root.calculateLayout();
|
||||
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
|
||||
assertFalse(c0.hasNewLayout());
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertFalse(c0c0.hasNewLayout());
|
||||
}
|
||||
|
||||
@@ -130,9 +136,11 @@ public class LayoutCachingTest {
|
||||
CSSNode c0 = new CSSNode();
|
||||
CSSNode c1 = new CSSNode();
|
||||
CSSNode c0c0 = new CSSNode();
|
||||
CSSNode c1c0 = new CSSNode();
|
||||
root.addChildAt(c0, 0);
|
||||
root.addChildAt(c1, 1);
|
||||
c0.addChildAt(c0c0, 0);
|
||||
c1.addChildAt(c1c0, 0);
|
||||
|
||||
root.calculateLayout();
|
||||
markLayoutAppliedForTree(root);
|
||||
@@ -144,7 +152,8 @@ public class LayoutCachingTest {
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertTrue(c0c0.hasNewLayout());
|
||||
|
||||
assertFalse(c1.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
assertFalse(c1c0.hasNewLayout());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -163,7 +172,32 @@ public class LayoutCachingTest {
|
||||
|
||||
root.setStyleWidth(200);
|
||||
root.calculateLayout();
|
||||
assertTreeHasNewLayout(false, root);
|
||||
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTreeHasNewLayout(false, c0);
|
||||
assertTreeHasNewLayout(false, c1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidateCacheWhenHeightChangesPosition() {
|
||||
CSSNode root = new CSSNode();
|
||||
CSSNode c0 = new CSSNode();
|
||||
CSSNode c1 = new CSSNode();
|
||||
CSSNode c1c0 = new CSSNode();
|
||||
root.addChildAt(c0, 0);
|
||||
root.addChildAt(c1, 1);
|
||||
c1.addChildAt(c1c0, 0);
|
||||
|
||||
root.calculateLayout();
|
||||
markLayoutAppliedForTree(root);
|
||||
|
||||
c0.setStyleHeight(100);
|
||||
root.calculateLayout();
|
||||
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
assertFalse(c1c0.hasNewLayout());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -192,7 +226,7 @@ public class LayoutCachingTest {
|
||||
assertTrue(root.hasNewLayout());
|
||||
assertTrue(c1.hasNewLayout());
|
||||
|
||||
assertFalse(c0.hasNewLayout());
|
||||
assertTrue(c0.hasNewLayout());
|
||||
assertFalse(c0c0.hasNewLayout());
|
||||
}
|
||||
}
|
||||
|
@@ -242,10 +242,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 100;
|
||||
node_0.style.height = 200;
|
||||
node_0.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_0.style.margin[Spacing.LEFT] = 10;
|
||||
node_0.style.margin[Spacing.TOP] = 10;
|
||||
node_0.style.margin[Spacing.RIGHT] = 10;
|
||||
node_0.style.margin[Spacing.BOTTOM] = 10;
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -268,34 +268,34 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 1000;
|
||||
node_0.style.height = 1000;
|
||||
node_0.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_0.style.margin[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_0.style.margin[Spacing.LEFT] = 10;
|
||||
node_0.style.margin[Spacing.TOP] = 10;
|
||||
node_0.style.margin[Spacing.RIGHT] = 10;
|
||||
node_0.style.margin[Spacing.BOTTOM] = 10;
|
||||
addChildren(node_0, 3);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.width = 100;
|
||||
node_1.style.height = 100;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 50;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 50;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 50;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 50;
|
||||
node_1.style.margin[Spacing.LEFT] = 50;
|
||||
node_1.style.margin[Spacing.TOP] = 50;
|
||||
node_1.style.margin[Spacing.RIGHT] = 50;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 50;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.width = 100;
|
||||
node_1.style.height = 100;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 25;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 25;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 25;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 25;
|
||||
node_1.style.margin[Spacing.LEFT] = 25;
|
||||
node_1.style.margin[Spacing.TOP] = 25;
|
||||
node_1.style.margin[Spacing.RIGHT] = 25;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 25;
|
||||
node_1 = node_0.getChildAt(2);
|
||||
node_1.style.width = 100;
|
||||
node_1.style.height = 100;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_1.style.margin[Spacing.LEFT] = 10;
|
||||
node_1.style.margin[Spacing.TOP] = 10;
|
||||
node_1.style.margin[Spacing.RIGHT] = 10;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ public class LayoutEngineTest {
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with flex", root_node, root_layout);
|
||||
test("should layout node with just flex", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -546,21 +546,21 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 1000;
|
||||
node_0.style.height = 1000;
|
||||
node_0.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_0.style.margin[Spacing.LEFT] = 5;
|
||||
node_0.style.margin[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.margin[CSSStyle.SPACING_LEFT] = 15;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 50;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_1.style.margin[Spacing.LEFT] = 15;
|
||||
node_1.style.margin[Spacing.TOP] = 50;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 20;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.width = 100;
|
||||
node_1.style.height = 100;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 30;
|
||||
node_1.style.margin[Spacing.LEFT] = 30;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1135,10 +1135,10 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_1.style.margin[Spacing.LEFT] = 5;
|
||||
node_1.style.margin[Spacing.TOP] = 5;
|
||||
node_1.style.margin[Spacing.RIGHT] = 5;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1239,7 +1239,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_1.style.margin[Spacing.TOP] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1279,10 +1279,10 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_2.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_2.style.margin[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_2.style.margin[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_2.style.margin[Spacing.LEFT] = 10;
|
||||
node_2.style.margin[Spacing.TOP] = 10;
|
||||
node_2.style.margin[Spacing.RIGHT] = 10;
|
||||
node_2.style.margin[Spacing.BOTTOM] = 10;
|
||||
node_2 = node_1.getChildAt(1);
|
||||
node_2.style.height = 100;
|
||||
}
|
||||
@@ -1370,7 +1370,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_1.style.margin[Spacing.LEFT] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1401,10 +1401,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.padding[Spacing.LEFT] = 5;
|
||||
node_0.style.padding[Spacing.TOP] = 5;
|
||||
node_0.style.padding[Spacing.RIGHT] = 5;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 5;
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -1425,10 +1425,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.padding[Spacing.LEFT] = 5;
|
||||
node_0.style.padding[Spacing.TOP] = 5;
|
||||
node_0.style.padding[Spacing.RIGHT] = 5;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -1463,18 +1463,18 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.padding[Spacing.LEFT] = 5;
|
||||
node_0.style.padding[Spacing.TOP] = 5;
|
||||
node_0.style.padding[Spacing.RIGHT] = 5;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_1.style.margin[Spacing.LEFT] = 5;
|
||||
node_1.style.margin[Spacing.TOP] = 5;
|
||||
node_1.style.margin[Spacing.RIGHT] = 5;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1510,10 +1510,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.STRETCH;
|
||||
node_1.style.padding[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_TOP] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_1.style.padding[Spacing.LEFT] = 10;
|
||||
node_1.style.padding[Spacing.TOP] = 10;
|
||||
node_1.style.padding[Spacing.RIGHT] = 10;
|
||||
node_1.style.padding[Spacing.BOTTOM] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1544,19 +1544,19 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 50;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 50;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 50;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 50;
|
||||
node_0.style.padding[Spacing.LEFT] = 50;
|
||||
node_0.style.padding[Spacing.TOP] = 50;
|
||||
node_0.style.padding[Spacing.RIGHT] = 50;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 50;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.STRETCH;
|
||||
node_1.style.padding[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_TOP] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_1.style.padding[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_1.style.padding[Spacing.LEFT] = 10;
|
||||
node_1.style.padding[Spacing.TOP] = 10;
|
||||
node_1.style.padding[Spacing.RIGHT] = 10;
|
||||
node_1.style.padding[Spacing.BOTTOM] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1596,10 +1596,10 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.style.margin[CSSStyle.SPACING_LEFT] = 16;
|
||||
node_2.style.margin[CSSStyle.SPACING_TOP] = 16;
|
||||
node_2.style.margin[CSSStyle.SPACING_RIGHT] = 16;
|
||||
node_2.style.margin[CSSStyle.SPACING_BOTTOM] = 16;
|
||||
node_2.style.margin[Spacing.LEFT] = 16;
|
||||
node_2.style.margin[Spacing.TOP] = 16;
|
||||
node_2.style.margin[Spacing.RIGHT] = 16;
|
||||
node_2.style.margin[Spacing.BOTTOM] = 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1664,7 +1664,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.justifyContent = CSSJustify.SPACE_AROUND;
|
||||
node_0.style.height = 10;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.padding[Spacing.TOP] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -1799,7 +1799,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.positionType = CSSPositionType.ABSOLUTE;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 15;
|
||||
node_1.style.margin[Spacing.RIGHT] = 15;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1836,7 +1836,7 @@ public class LayoutEngineTest {
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.CENTER;
|
||||
node_1.style.positionType = CSSPositionType.ABSOLUTE;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 12;
|
||||
node_1.style.padding[Spacing.RIGHT] = 12;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1868,7 +1868,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.height = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 20;
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -1890,7 +1890,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.width = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_0.style.padding[Spacing.LEFT] = 20;
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -1968,10 +1968,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.padding[Spacing.LEFT] = 5;
|
||||
node_0.style.padding[Spacing.TOP] = 5;
|
||||
node_0.style.padding[Spacing.RIGHT] = 5;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2051,10 +2051,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 20;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 20;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_0.style.padding[Spacing.LEFT] = 20;
|
||||
node_0.style.padding[Spacing.TOP] = 20;
|
||||
node_0.style.padding[Spacing.RIGHT] = 20;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 20;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2096,7 +2096,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.positionType = CSSPositionType.ABSOLUTE;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 5;
|
||||
node_1.style.margin[Spacing.TOP] = 5;
|
||||
node_1.style.positionTop = 5;
|
||||
}
|
||||
}
|
||||
@@ -2133,7 +2133,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.positionType = CSSPositionType.ABSOLUTE;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_1.style.margin[Spacing.LEFT] = 5;
|
||||
node_1.style.positionLeft = 5;
|
||||
}
|
||||
}
|
||||
@@ -2215,7 +2215,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.flex = 1;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_1.style.margin[Spacing.LEFT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2255,7 +2255,7 @@ public class LayoutEngineTest {
|
||||
node_1.style.flex = 1;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.flex = 1;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_1.style.padding[Spacing.RIGHT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2300,7 +2300,7 @@ public class LayoutEngineTest {
|
||||
node_1.style.flex = 1;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.flex = 1;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_1.style.margin[Spacing.LEFT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2461,10 +2461,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.border[CSSStyle.SPACING_LEFT] = 5;
|
||||
node_0.style.border[CSSStyle.SPACING_TOP] = 5;
|
||||
node_0.style.border[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_0.style.border[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.border[Spacing.LEFT] = 5;
|
||||
node_0.style.border[Spacing.TOP] = 5;
|
||||
node_0.style.border[Spacing.RIGHT] = 5;
|
||||
node_0.style.border[Spacing.BOTTOM] = 5;
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
@@ -2485,7 +2485,7 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.border[CSSStyle.SPACING_TOP] = 1;
|
||||
node_0.style.border[Spacing.TOP] = 1;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2522,10 +2522,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.border[CSSStyle.SPACING_LEFT] = 1;
|
||||
node_0.style.border[CSSStyle.SPACING_TOP] = 1;
|
||||
node_0.style.border[CSSStyle.SPACING_RIGHT] = 1;
|
||||
node_0.style.border[CSSStyle.SPACING_BOTTOM] = 1;
|
||||
node_0.style.border[Spacing.LEFT] = 1;
|
||||
node_0.style.border[Spacing.TOP] = 1;
|
||||
node_0.style.border[Spacing.RIGHT] = 1;
|
||||
node_0.style.border[Spacing.BOTTOM] = 1;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2568,11 +2568,11 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.STRETCH;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_1.style.padding[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_1.style.padding[CSSStyle.SPACING_TOP] = 20;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 20;
|
||||
node_1.style.padding[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_1.style.margin[Spacing.LEFT] = 20;
|
||||
node_1.style.padding[Spacing.LEFT] = 20;
|
||||
node_1.style.padding[Spacing.TOP] = 20;
|
||||
node_1.style.padding[Spacing.RIGHT] = 20;
|
||||
node_1.style.padding[Spacing.BOTTOM] = 20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2607,7 +2607,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.border[CSSStyle.SPACING_RIGHT] = 5;
|
||||
node_1.style.border[Spacing.RIGHT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2639,12 +2639,12 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.flexDirection = CSSFlexDirection.ROW;
|
||||
node_0.style.border[CSSStyle.SPACING_RIGHT] = 1;
|
||||
node_0.style.border[Spacing.RIGHT] = 1;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = -8;
|
||||
node_1.style.margin[Spacing.RIGHT] = -8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2994,19 +2994,19 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.alignSelf = CSSAlign.FLEX_START;
|
||||
node_0.style.width = 100;
|
||||
node_0.style.padding[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 10;
|
||||
node_0.style.padding[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_0.style.padding[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_0.style.padding[Spacing.LEFT] = 10;
|
||||
node_0.style.padding[Spacing.TOP] = 10;
|
||||
node_0.style.padding[Spacing.RIGHT] = 10;
|
||||
node_0.style.padding[Spacing.BOTTOM] = 10;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.FLEX_START;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_RIGHT] = 10;
|
||||
node_1.style.margin[CSSStyle.SPACING_BOTTOM] = 10;
|
||||
node_1.style.margin[Spacing.LEFT] = 10;
|
||||
node_1.style.margin[Spacing.TOP] = 10;
|
||||
node_1.style.margin[Spacing.RIGHT] = 10;
|
||||
node_1.style.margin[Spacing.BOTTOM] = 10;
|
||||
addChildren(node_1, 1);
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
@@ -3144,10 +3144,10 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.style.margin[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_TOP] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_RIGHT] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_2.style.margin[Spacing.LEFT] = 20;
|
||||
node_2.style.margin[Spacing.TOP] = 20;
|
||||
node_2.style.margin[Spacing.RIGHT] = 20;
|
||||
node_2.style.margin[Spacing.BOTTOM] = 20;
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "loooooooooong with space";
|
||||
}
|
||||
@@ -3199,10 +3199,10 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.style.margin[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_TOP] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_RIGHT] = 20;
|
||||
node_2.style.margin[CSSStyle.SPACING_BOTTOM] = 20;
|
||||
node_2.style.margin[Spacing.LEFT] = 20;
|
||||
node_2.style.margin[Spacing.TOP] = 20;
|
||||
node_2.style.margin[Spacing.RIGHT] = 20;
|
||||
node_2.style.margin[Spacing.BOTTOM] = 20;
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "loooooooooong with space";
|
||||
}
|
||||
@@ -3749,7 +3749,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.border[CSSStyle.SPACING_BOTTOM] = 1;
|
||||
node_1.style.border[Spacing.BOTTOM] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3785,7 +3785,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = -6;
|
||||
node_1.style.margin[Spacing.TOP] = -6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3821,7 +3821,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.margin[CSSStyle.SPACING_TOP] = 20;
|
||||
node_1.style.margin[Spacing.TOP] = 20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3853,7 +3853,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.justifyContent = CSSJustify.FLEX_END;
|
||||
node_0.style.border[CSSStyle.SPACING_BOTTOM] = 5;
|
||||
node_0.style.border[Spacing.BOTTOM] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -3986,5 +3986,49 @@ public class LayoutEngineTest {
|
||||
|
||||
test("should layout flex-wrap", root_node, root_layout);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase94()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.flexWrap = CSSWrap.WRAP;
|
||||
node_0.style.height = 100;
|
||||
addChildren(node_0, 2);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.height = 100;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.height = 200;
|
||||
}
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.y = 0;
|
||||
node_0.layout.x = 0;
|
||||
node_0.layout.width = 0;
|
||||
node_0.layout.height = 100;
|
||||
addChildren(node_0, 2);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.layout.y = 0;
|
||||
node_1.layout.x = 0;
|
||||
node_1.layout.width = 0;
|
||||
node_1.layout.height = 100;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.layout.y = 0;
|
||||
node_1.layout.x = 0;
|
||||
node_1.layout.width = 0;
|
||||
node_1.layout.height = 200;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout flex wrap with a line bigger than container", root_node, root_layout);
|
||||
}
|
||||
/** END_GENERATED **/
|
||||
}
|
||||
|
Reference in New Issue
Block a user