Merge pull request #19 from foghina/master
Add support for paddingVertical, paddingHorizontal, borderVertical, borderHorizontal
This commit is contained in:
@@ -54,12 +54,12 @@ function __transpileSingleTestToJava(code) {
|
||||
return 'layout.' + (match1 == 'TOP' ? 'y' : 'x');
|
||||
})
|
||||
.replace( // style.position[CSS_TOP] => style.positionTop
|
||||
/style\.(position|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT)\]/g,
|
||||
/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] => style.margin[CSSStyle.SPACING_TOP]
|
||||
/style\.(margin)\[CSS_(TOP|BOTTOM|LEFT|RIGHT)\]/g,
|
||||
/style\.(margin|border|padding)\[CSS_(TOP|BOTTOM|LEFT|RIGHT)\]/g,
|
||||
function (str, match1, match2) {
|
||||
return 'style.' + match1 + '[CSSStyle.SPACING_' + match2 + ']';
|
||||
})
|
||||
|
@@ -53,6 +53,26 @@ public class CSSNode {
|
||||
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();
|
||||
@@ -265,6 +285,14 @@ public class CSSNode {
|
||||
setSpacing(mMargin, spacingType, margin, style.margin);
|
||||
}
|
||||
|
||||
public void setPadding(int spacingType, float padding) {
|
||||
setSpacing(mPadding, spacingType, padding, style.padding);
|
||||
}
|
||||
|
||||
public void setBorder(int spacingType, float border) {
|
||||
setSpacing(mBorder, spacingType, border, style.border);
|
||||
}
|
||||
|
||||
protected void setSpacing(float[] spacingDef, int spacingType, float spacing, float[] cssStyle) {
|
||||
if (!valuesEqual(spacingDef[spacingType], spacing)) {
|
||||
spacingDef[spacingType] = spacing;
|
||||
@@ -292,34 +320,6 @@ public class CSSNode {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaddingTop(float paddingTop) {
|
||||
if (!valuesEqual(style.paddingTop, paddingTop)) {
|
||||
style.paddingTop = paddingTop;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaddingBottom(float paddingBottom) {
|
||||
if (!valuesEqual(style.paddingBottom, paddingBottom)) {
|
||||
style.paddingBottom = paddingBottom;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaddingLeft(float paddingLeft) {
|
||||
if (!valuesEqual(style.paddingLeft, paddingLeft)) {
|
||||
style.paddingLeft = paddingLeft;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaddingRight(float paddingRight) {
|
||||
if (!valuesEqual(style.paddingRight, paddingRight)) {
|
||||
style.paddingRight = paddingRight;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPositionTop(float positionTop) {
|
||||
if (!valuesEqual(style.positionTop, positionTop)) {
|
||||
style.positionTop = positionTop;
|
||||
@@ -348,34 +348,6 @@ public class CSSNode {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderTop(float borderTop) {
|
||||
if (!valuesEqual(style.borderTop, borderTop)) {
|
||||
style.borderTop = borderTop;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderBottom(float borderBottom) {
|
||||
if (!valuesEqual(style.borderBottom, borderBottom)) {
|
||||
style.borderBottom = borderBottom;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderLeft(float borderLeft) {
|
||||
if (!valuesEqual(style.borderLeft, borderLeft)) {
|
||||
style.borderLeft = borderLeft;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderRight(float borderRight) {
|
||||
if (!valuesEqual(style.borderRight, borderRight)) {
|
||||
style.borderRight = borderRight;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStyleWidth(float width) {
|
||||
if (!valuesEqual(style.width, width)) {
|
||||
style.width = width;
|
||||
|
@@ -26,22 +26,14 @@ public class CSSStyle {
|
||||
public float flex;
|
||||
|
||||
public float[] margin = new float[4];
|
||||
|
||||
public float paddingTop;
|
||||
public float paddingBottom;
|
||||
public float paddingLeft;
|
||||
public float paddingRight;
|
||||
public float[] padding = new float[4];
|
||||
public float[] border = new float[4];
|
||||
|
||||
public float positionTop = CSSConstants.UNDEFINED;
|
||||
public float positionBottom = CSSConstants.UNDEFINED;
|
||||
public float positionLeft = CSSConstants.UNDEFINED;
|
||||
public float positionRight = CSSConstants.UNDEFINED;
|
||||
|
||||
public float borderTop;
|
||||
public float borderBottom;
|
||||
public float borderLeft;
|
||||
public float borderRight;
|
||||
|
||||
public float width = CSSConstants.UNDEFINED;
|
||||
public float height = CSSConstants.UNDEFINED;
|
||||
}
|
||||
|
@@ -146,13 +146,13 @@ public class LayoutEngine {
|
||||
private static float getPadding(CSSNode node, PositionIndex position) {
|
||||
switch (position) {
|
||||
case TOP:
|
||||
return node.style.paddingTop;
|
||||
return node.style.padding[CSSStyle.SPACING_TOP];
|
||||
case BOTTOM:
|
||||
return node.style.paddingBottom;
|
||||
return node.style.padding[CSSStyle.SPACING_BOTTOM];
|
||||
case LEFT:
|
||||
return node.style.paddingLeft;
|
||||
return node.style.padding[CSSStyle.SPACING_LEFT];
|
||||
case RIGHT:
|
||||
return node.style.paddingRight;
|
||||
return node.style.padding[CSSStyle.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.borderTop;
|
||||
return node.style.border[CSSStyle.SPACING_TOP];
|
||||
case BOTTOM:
|
||||
return node.style.borderBottom;
|
||||
return node.style.border[CSSStyle.SPACING_BOTTOM];
|
||||
case LEFT:
|
||||
return node.style.borderLeft;
|
||||
return node.style.border[CSSStyle.SPACING_LEFT];
|
||||
case RIGHT:
|
||||
return node.style.borderRight;
|
||||
return node.style.border[CSSStyle.SPACING_RIGHT];
|
||||
default:
|
||||
throw new RuntimeException("Someone added a new cardinal direction...");
|
||||
}
|
||||
|
@@ -1401,10 +1401,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.paddingLeft = 5;
|
||||
node_0.style.paddingTop = 5;
|
||||
node_0.style.paddingRight = 5;
|
||||
node_0.style.paddingBottom = 5;
|
||||
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;
|
||||
}
|
||||
|
||||
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.paddingLeft = 5;
|
||||
node_0.style.paddingTop = 5;
|
||||
node_0.style.paddingRight = 5;
|
||||
node_0.style.paddingBottom = 5;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -1463,10 +1463,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.paddingLeft = 5;
|
||||
node_0.style.paddingTop = 5;
|
||||
node_0.style.paddingRight = 5;
|
||||
node_0.style.paddingBottom = 5;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -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.paddingLeft = 10;
|
||||
node_1.style.paddingTop = 10;
|
||||
node_1.style.paddingRight = 10;
|
||||
node_1.style.paddingBottom = 10;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1544,19 +1544,19 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.paddingLeft = 50;
|
||||
node_0.style.paddingTop = 50;
|
||||
node_0.style.paddingRight = 50;
|
||||
node_0.style.paddingBottom = 50;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.STRETCH;
|
||||
node_1.style.paddingLeft = 10;
|
||||
node_1.style.paddingTop = 10;
|
||||
node_1.style.paddingRight = 10;
|
||||
node_1.style.paddingBottom = 10;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.paddingTop = 5;
|
||||
node_0.style.padding[CSSStyle.SPACING_TOP] = 5;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -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.paddingRight = 12;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 12;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1868,7 +1868,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.height = 5;
|
||||
node_0.style.paddingBottom = 20;
|
||||
node_0.style.padding[CSSStyle.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.paddingLeft = 20;
|
||||
node_0.style.padding[CSSStyle.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.paddingLeft = 5;
|
||||
node_0.style.paddingTop = 5;
|
||||
node_0.style.paddingRight = 5;
|
||||
node_0.style.paddingBottom = 5;
|
||||
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;
|
||||
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.paddingLeft = 20;
|
||||
node_0.style.paddingTop = 20;
|
||||
node_0.style.paddingRight = 20;
|
||||
node_0.style.paddingBottom = 20;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -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.paddingRight = 5;
|
||||
node_1.style.padding[CSSStyle.SPACING_RIGHT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2461,10 +2461,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.borderLeft = 5;
|
||||
node_0.style.borderTop = 5;
|
||||
node_0.style.borderRight = 5;
|
||||
node_0.style.borderBottom = 5;
|
||||
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;
|
||||
}
|
||||
|
||||
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.borderTop = 1;
|
||||
node_0.style.border[CSSStyle.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.borderLeft = 1;
|
||||
node_0.style.borderTop = 1;
|
||||
node_0.style.borderRight = 1;
|
||||
node_0.style.borderBottom = 1;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2569,10 +2569,10 @@ public class LayoutEngineTest {
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.alignSelf = CSSAlign.STRETCH;
|
||||
node_1.style.margin[CSSStyle.SPACING_LEFT] = 20;
|
||||
node_1.style.paddingLeft = 20;
|
||||
node_1.style.paddingTop = 20;
|
||||
node_1.style.paddingRight = 20;
|
||||
node_1.style.paddingBottom = 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2607,7 +2607,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.style.borderRight = 5;
|
||||
node_1.style.border[CSSStyle.SPACING_RIGHT] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2639,7 +2639,7 @@ public class LayoutEngineTest {
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.flexDirection = CSSFlexDirection.ROW;
|
||||
node_0.style.borderRight = 1;
|
||||
node_0.style.border[CSSStyle.SPACING_RIGHT] = 1;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
@@ -2994,10 +2994,10 @@ public class LayoutEngineTest {
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.alignSelf = CSSAlign.FLEX_START;
|
||||
node_0.style.width = 100;
|
||||
node_0.style.paddingLeft = 10;
|
||||
node_0.style.paddingTop = 10;
|
||||
node_0.style.paddingRight = 10;
|
||||
node_0.style.paddingBottom = 10;
|
||||
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;
|
||||
addChildren(node_0, 1);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
|
Reference in New Issue
Block a user