Merge pull request #59 from freakboy3742/normalize_isDimDefined
Normalized C and Java definition of isDimDefined.
This commit is contained in:
@@ -287,7 +287,8 @@ static float getDimWithMargin(css_node_t *node, css_flex_direction_t axis) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool isDimDefined(css_node_t *node, css_flex_direction_t axis) {
|
static bool isDimDefined(css_node_t *node, css_flex_direction_t axis) {
|
||||||
return !isUndefined(node->style.dimensions[dim[axis]]);
|
float value = node->style.dimensions[dim[axis]];
|
||||||
|
return !isUndefined(value) && value > 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isPosDefined(css_node_t *node, css_position_t position) {
|
static bool isPosDefined(css_node_t *node, css_position_t position) {
|
||||||
|
@@ -2405,6 +2405,7 @@ int main()
|
|||||||
css_node_t *root_node = new_test_css_node();
|
css_node_t *root_node = new_test_css_node();
|
||||||
{
|
{
|
||||||
css_node_t *node_0 = root_node;
|
css_node_t *node_0 = root_node;
|
||||||
|
node_0->style.dimensions[CSS_WIDTH] = -31;
|
||||||
init_css_node_children(node_0, 1);
|
init_css_node_children(node_0, 1);
|
||||||
{
|
{
|
||||||
css_node_t *node_1;
|
css_node_t *node_1;
|
||||||
@@ -3109,6 +3110,7 @@ int main()
|
|||||||
css_node_t *node_1;
|
css_node_t *node_1;
|
||||||
node_1 = node_0->get_child(node_0->context, 0);
|
node_1 = node_0->get_child(node_0->context, 0);
|
||||||
node_1->style.align_self = CSS_ALIGN_FLEX_START;
|
node_1->style.align_self = CSS_ALIGN_FLEX_START;
|
||||||
|
node_1->style.flex = -2.5;
|
||||||
node_1 = node_0->get_child(node_0->context, 1);
|
node_1 = node_0->get_child(node_0->context, 1);
|
||||||
node_1->style.align_self = CSS_ALIGN_FLEX_START;
|
node_1->style.align_self = CSS_ALIGN_FLEX_START;
|
||||||
node_1->style.flex = 0;
|
node_1->style.flex = 0;
|
||||||
|
@@ -116,7 +116,8 @@ public class LayoutEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDimDefined(CSSNode node, CSSFlexDirection axis) {
|
private static boolean isDimDefined(CSSNode node, CSSFlexDirection axis) {
|
||||||
return !CSSConstants.isUndefined(getStyleDimension(node, getDim(axis)));
|
float value = getStyleDimension(node, getDim(axis));
|
||||||
|
return !CSSConstants.isUndefined(value) && value > 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPosDefined(CSSNode node, PositionIndex position) {
|
private static boolean isPosDefined(CSSNode node, PositionIndex position) {
|
||||||
|
@@ -2603,6 +2603,7 @@ public class LayoutEngineTest {
|
|||||||
TestCSSNode root_node = new TestCSSNode();
|
TestCSSNode root_node = new TestCSSNode();
|
||||||
{
|
{
|
||||||
TestCSSNode node_0 = root_node;
|
TestCSSNode node_0 = root_node;
|
||||||
|
node_0.style.width = -31;
|
||||||
addChildren(node_0, 1);
|
addChildren(node_0, 1);
|
||||||
{
|
{
|
||||||
TestCSSNode node_1;
|
TestCSSNode node_1;
|
||||||
@@ -3341,6 +3342,7 @@ public class LayoutEngineTest {
|
|||||||
TestCSSNode node_1;
|
TestCSSNode node_1;
|
||||||
node_1 = node_0.getChildAt(0);
|
node_1 = node_0.getChildAt(0);
|
||||||
node_1.style.alignSelf = CSSAlign.FLEX_START;
|
node_1.style.alignSelf = CSSAlign.FLEX_START;
|
||||||
|
node_1.style.flex = -2.5f;
|
||||||
node_1 = node_0.getChildAt(1);
|
node_1 = node_0.getChildAt(1);
|
||||||
node_1.style.alignSelf = CSSAlign.FLEX_START;
|
node_1.style.alignSelf = CSSAlign.FLEX_START;
|
||||||
node_1.style.flex = 0;
|
node_1.style.flex = 0;
|
||||||
|
@@ -86,24 +86,22 @@ function printLayout(test) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFloat(positive, node, jsKey, cKey) {
|
function addFloat(node, jsKey, cKey) {
|
||||||
if (jsKey in node.style) {
|
if (jsKey in node.style) {
|
||||||
if (positive !== 'positive' || node.style[jsKey] >= 0) {
|
addStyle(cKey + ' = ' + node.style[jsKey] + ';');
|
||||||
addStyle(cKey + ' = ' + node.style[jsKey] + ';');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSpacing(positive, node, spacing, suffix) {
|
function addSpacing(node, spacing, suffix) {
|
||||||
addFloat(positive, node, spacing + suffix, spacing + '[CSS_LEFT]');
|
addFloat(node, spacing + suffix, spacing + '[CSS_LEFT]');
|
||||||
addFloat(positive, node, spacing + suffix, spacing + '[CSS_TOP]');
|
addFloat(node, spacing + suffix, spacing + '[CSS_TOP]');
|
||||||
addFloat(positive, node, spacing + suffix, spacing + '[CSS_RIGHT]');
|
addFloat(node, spacing + suffix, spacing + '[CSS_RIGHT]');
|
||||||
addFloat(positive, node, spacing + suffix, spacing + '[CSS_BOTTOM]');
|
addFloat(node, spacing + suffix, spacing + '[CSS_BOTTOM]');
|
||||||
|
|
||||||
addFloat(positive, node, spacing + 'Left' + suffix, spacing + '[CSS_LEFT]');
|
addFloat(node, spacing + 'Left' + suffix, spacing + '[CSS_LEFT]');
|
||||||
addFloat(positive, node, spacing + 'Top' + suffix, spacing + '[CSS_TOP]');
|
addFloat(node, spacing + 'Top' + suffix, spacing + '[CSS_TOP]');
|
||||||
addFloat(positive, node, spacing + 'Right' + suffix, spacing + '[CSS_RIGHT]');
|
addFloat(node, spacing + 'Right' + suffix, spacing + '[CSS_RIGHT]');
|
||||||
addFloat(positive, node, spacing + 'Bottom' + suffix, spacing + '[CSS_BOTTOM]');
|
addFloat(node, spacing + 'Bottom' + suffix, spacing + '[CSS_BOTTOM]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMeasure(node) {
|
function addMeasure(node) {
|
||||||
@@ -144,16 +142,16 @@ function printLayout(test) {
|
|||||||
'nowrap': 'CSS_NOWRAP',
|
'nowrap': 'CSS_NOWRAP',
|
||||||
'wrap': 'CSS_WRAP'
|
'wrap': 'CSS_WRAP'
|
||||||
});
|
});
|
||||||
addFloat('positive', node, 'flex', 'flex');
|
addFloat(node, 'flex', 'flex');
|
||||||
addFloat('positive', node, 'width', 'dimensions[CSS_WIDTH]');
|
addFloat(node, 'width', 'dimensions[CSS_WIDTH]');
|
||||||
addFloat('positive', node, 'height', 'dimensions[CSS_HEIGHT]');
|
addFloat(node, 'height', 'dimensions[CSS_HEIGHT]');
|
||||||
addSpacing('all', node, 'margin', '');
|
addSpacing(node, 'margin', '');
|
||||||
addSpacing('positive', node, 'padding', '');
|
addSpacing(node, 'padding', '');
|
||||||
addSpacing('positive', node, 'border', 'Width');
|
addSpacing(node, 'border', 'Width');
|
||||||
addFloat('all', node, 'left', 'position[CSS_LEFT]');
|
addFloat(node, 'left', 'position[CSS_LEFT]');
|
||||||
addFloat('all', node, 'top', 'position[CSS_TOP]');
|
addFloat(node, 'top', 'position[CSS_TOP]');
|
||||||
addFloat('all', node, 'right', 'position[CSS_RIGHT]');
|
addFloat(node, 'right', 'position[CSS_RIGHT]');
|
||||||
addFloat('all', node, 'bottom', 'position[CSS_BOTTOM]');
|
addFloat(node, 'bottom', 'position[CSS_BOTTOM]');
|
||||||
addMeasure(node);
|
addMeasure(node);
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
|
Reference in New Issue
Block a user