Prefix isUndefined with "CSS"

Summary:
Consistently namespace all of css-layout's public C API with "CSS". The only function that needed to be renamed was isUndefined, which I renamed to CSSValueIsUndefined.

Fixes #210.
Closes https://github.com/facebook/css-layout/pull/211

Reviewed By: lucasr

Differential Revision: D3674922

Pulled By: emilsjolander

fbshipit-source-id: 1752f477bde45586db112fe2654d0404cc52e1d1
This commit is contained in:
James Ide 2016-08-05 06:27:39 -07:00 committed by Facebook Github Bot 2
parent 4e3b484631
commit f8f7a1540d
4 changed files with 72 additions and 72 deletions

View File

@ -151,7 +151,7 @@ static CSSSize RCTMeasure(void *context, float width, CSSMeasureMode widthMode,
CSSNodeRef childNode = child.cssNode; CSSNodeRef childNode = child.cssNode;
float width = CSSNodeStyleGetWidth(childNode); float width = CSSNodeStyleGetWidth(childNode);
float height = CSSNodeStyleGetHeight(childNode); float height = CSSNodeStyleGetHeight(childNode);
if (isUndefined(width) || isUndefined(height)) { if (CSSValueIsUndefined(width) || CSSValueIsUndefined(height)) {
RCTLogError(@"Views nested within a <Text> must have a width and height"); RCTLogError(@"Views nested within a <Text> must have a width and height");
} }
UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:range.location effectiveRange:nil]; UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:range.location effectiveRange:nil];
@ -293,7 +293,7 @@ static CSSSize RCTMeasure(void *context, float width, CSSMeasureMode widthMode,
} else { } else {
float width = CSSNodeStyleGetWidth(child.cssNode); float width = CSSNodeStyleGetWidth(child.cssNode);
float height = CSSNodeStyleGetHeight(child.cssNode); float height = CSSNodeStyleGetHeight(child.cssNode);
if (isUndefined(width) || isUndefined(height)) { if (CSSValueIsUndefined(width) || CSSValueIsUndefined(height)) {
RCTLogError(@"Views nested within a <Text> must have a width and height"); RCTLogError(@"Views nested within a <Text> must have a width and height");
} }
NSTextAttachment *attachment = [NSTextAttachment new]; NSTextAttachment *attachment = [NSTextAttachment new];

View File

@ -212,11 +212,11 @@ bool layoutNodeInternal(CSSNode *node,
bool performLayout, bool performLayout,
char *reason); char *reason);
bool isUndefined(float value) { return isnan(value); } bool CSSValueIsUndefined(float value) { return isnan(value); }
static bool eq(float a, float b) { static bool eq(float a, float b) {
if (isUndefined(a)) { if (CSSValueIsUndefined(a)) {
return isUndefined(b); return CSSValueIsUndefined(b);
} }
return fabs(a - b) < 0.0001; return fabs(a - b) < 0.0001;
} }
@ -448,7 +448,7 @@ static float getFlexShrinkFactor(CSSNode *node) {
} }
static float getLeadingMargin(CSSNode *node, CSSFlexDirection axis) { static float getLeadingMargin(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.margin[CSSPositionStart])) { if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSPositionStart])) {
return node->style.margin[CSSPositionStart]; return node->style.margin[CSSPositionStart];
} }
@ -456,7 +456,7 @@ static float getLeadingMargin(CSSNode *node, CSSFlexDirection axis) {
} }
static float getTrailingMargin(CSSNode *node, CSSFlexDirection axis) { static float getTrailingMargin(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.margin[CSSPositionEnd])) { if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSPositionEnd])) {
return node->style.margin[CSSPositionEnd]; return node->style.margin[CSSPositionEnd];
} }
@ -464,7 +464,7 @@ static float getTrailingMargin(CSSNode *node, CSSFlexDirection axis) {
} }
static float getLeadingPadding(CSSNode *node, CSSFlexDirection axis) { static float getLeadingPadding(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.padding[CSSPositionStart]) if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[CSSPositionStart])
&& node->style.padding[CSSPositionStart] >= 0) { && node->style.padding[CSSPositionStart] >= 0) {
return node->style.padding[CSSPositionStart]; return node->style.padding[CSSPositionStart];
} }
@ -477,7 +477,7 @@ static float getLeadingPadding(CSSNode *node, CSSFlexDirection axis) {
} }
static float getTrailingPadding(CSSNode *node, CSSFlexDirection axis) { static float getTrailingPadding(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.padding[CSSPositionEnd]) if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.padding[CSSPositionEnd])
&& node->style.padding[CSSPositionEnd] >= 0) { && node->style.padding[CSSPositionEnd] >= 0) {
return node->style.padding[CSSPositionEnd]; return node->style.padding[CSSPositionEnd];
} }
@ -490,7 +490,7 @@ static float getTrailingPadding(CSSNode *node, CSSFlexDirection axis) {
} }
static float getLeadingBorder(CSSNode *node, CSSFlexDirection axis) { static float getLeadingBorder(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.border[CSSPositionStart]) if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[CSSPositionStart])
&& node->style.border[CSSPositionStart] >= 0) { && node->style.border[CSSPositionStart] >= 0) {
return node->style.border[CSSPositionStart]; return node->style.border[CSSPositionStart];
} }
@ -503,7 +503,7 @@ static float getLeadingBorder(CSSNode *node, CSSFlexDirection axis) {
} }
static float getTrailingBorder(CSSNode *node, CSSFlexDirection axis) { static float getTrailingBorder(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.border[CSSPositionEnd]) if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.border[CSSPositionEnd])
&& node->style.border[CSSPositionEnd] >= 0) { && node->style.border[CSSPositionEnd] >= 0) {
return node->style.border[CSSPositionEnd]; return node->style.border[CSSPositionEnd];
} }
@ -586,41 +586,41 @@ static float getDimWithMargin(CSSNode *node, CSSFlexDirection axis) {
static bool isStyleDimDefined(CSSNode *node, CSSFlexDirection axis) { static bool isStyleDimDefined(CSSNode *node, CSSFlexDirection axis) {
float value = node->style.dimensions[dim[axis]]; float value = node->style.dimensions[dim[axis]];
return !isUndefined(value) && value >= 0.0; return !CSSValueIsUndefined(value) && value >= 0.0;
} }
static bool isLayoutDimDefined(CSSNode *node, CSSFlexDirection axis) { static bool isLayoutDimDefined(CSSNode *node, CSSFlexDirection axis) {
float value = node->layout.measuredDimensions[dim[axis]]; float value = node->layout.measuredDimensions[dim[axis]];
return !isUndefined(value) && value >= 0.0; return !CSSValueIsUndefined(value) && value >= 0.0;
} }
static bool isLeadingPosDefined(CSSNode *node, CSSFlexDirection axis) { static bool isLeadingPosDefined(CSSNode *node, CSSFlexDirection axis) {
return (isRowDirection(axis) && !isUndefined(node->style.position[CSSPositionStart])) return (isRowDirection(axis) && !CSSValueIsUndefined(node->style.position[CSSPositionStart]))
|| !isUndefined(node->style.position[leading[axis]]); || !CSSValueIsUndefined(node->style.position[leading[axis]]);
} }
static bool isTrailingPosDefined(CSSNode *node, CSSFlexDirection axis) { static bool isTrailingPosDefined(CSSNode *node, CSSFlexDirection axis) {
return (isRowDirection(axis) && !isUndefined(node->style.position[CSSPositionEnd])) return (isRowDirection(axis) && !CSSValueIsUndefined(node->style.position[CSSPositionEnd]))
|| !isUndefined(node->style.position[trailing[axis]]); || !CSSValueIsUndefined(node->style.position[trailing[axis]]);
} }
static bool isMeasureDefined(CSSNode *node) { return node->measure; } static bool isMeasureDefined(CSSNode *node) { return node->measure; }
static float getLeadingPosition(CSSNode *node, CSSFlexDirection axis) { static float getLeadingPosition(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.position[CSSPositionStart])) { if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.position[CSSPositionStart])) {
return node->style.position[CSSPositionStart]; return node->style.position[CSSPositionStart];
} }
if (!isUndefined(node->style.position[leading[axis]])) { if (!CSSValueIsUndefined(node->style.position[leading[axis]])) {
return node->style.position[leading[axis]]; return node->style.position[leading[axis]];
} }
return 0; return 0;
} }
static float getTrailingPosition(CSSNode *node, CSSFlexDirection axis) { static float getTrailingPosition(CSSNode *node, CSSFlexDirection axis) {
if (isRowDirection(axis) && !isUndefined(node->style.position[CSSPositionEnd])) { if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.position[CSSPositionEnd])) {
return node->style.position[CSSPositionEnd]; return node->style.position[CSSPositionEnd];
} }
if (!isUndefined(node->style.position[trailing[axis]])) { if (!CSSValueIsUndefined(node->style.position[trailing[axis]])) {
return node->style.position[trailing[axis]]; return node->style.position[trailing[axis]];
} }
return 0; return 0;
@ -640,10 +640,10 @@ static float boundAxisWithinMinAndMax(CSSNode *node, CSSFlexDirection axis, floa
float boundValue = value; float boundValue = value;
if (!isUndefined(max) && max >= 0.0 && boundValue > max) { if (!CSSValueIsUndefined(max) && max >= 0.0 && boundValue > max) {
boundValue = max; boundValue = max;
} }
if (!isUndefined(min) && min >= 0.0 && boundValue < min) { if (!CSSValueIsUndefined(min) && min >= 0.0 && boundValue < min) {
boundValue = min; boundValue = min;
} }
@ -806,10 +806,10 @@ static void layoutNodeImpl(CSSNode *node,
CSSMeasureMode heightMeasureMode, CSSMeasureMode heightMeasureMode,
bool performLayout) { bool performLayout) {
CSS_ASSERT(isUndefined(availableWidth) ? widthMeasureMode == CSSMeasureModeUndefined : true, CSS_ASSERT(CSSValueIsUndefined(availableWidth) ? widthMeasureMode == CSSMeasureModeUndefined : true,
"availableWidth is indefinite so widthMeasureMode must be " "availableWidth is indefinite so widthMeasureMode must be "
"CSSMeasureModeUndefined"); "CSSMeasureModeUndefined");
CSS_ASSERT(isUndefined(availableHeight) ? heightMeasureMode == CSSMeasureModeUndefined : true, CSS_ASSERT(CSSValueIsUndefined(availableHeight) ? heightMeasureMode == CSSMeasureModeUndefined : true,
"availableHeight is indefinite so heightMeasureMode must be " "availableHeight is indefinite so heightMeasureMode must be "
"CSSMeasureModeUndefined"); "CSSMeasureModeUndefined");
@ -898,13 +898,13 @@ static void layoutNodeImpl(CSSNode *node,
if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) { if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) {
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0); node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0);
node->layout.measuredDimensions[CSSDimensionHeight] = boundAxis(node, CSSFlexDirectionColumn, node->layout.measuredDimensions[CSSDimensionHeight] = boundAxis(node, CSSFlexDirectionColumn,
isUndefined(availableHeight) ? 0 : (availableHeight - marginAxisColumn)); CSSValueIsUndefined(availableHeight) ? 0 : (availableHeight - marginAxisColumn));
return; return;
} }
if (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) { if (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) {
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow,
isUndefined(availableWidth) ? 0 : (availableWidth - marginAxisRow)); CSSValueIsUndefined(availableWidth) ? 0 : (availableWidth - marginAxisRow));
node->layout.measuredDimensions[CSSDimensionHeight] node->layout.measuredDimensions[CSSDimensionHeight]
= boundAxis(node, CSSFlexDirectionColumn, 0); = boundAxis(node, CSSFlexDirectionColumn, 0);
return; return;
@ -988,7 +988,7 @@ static void layoutNodeImpl(CSSNode *node,
// The height is definite, so use that as the flex basis. // The height is definite, so use that as the flex basis.
child->layout.flexBasis = fmaxf(child->style.dimensions[CSSDimensionHeight], child->layout.flexBasis = fmaxf(child->style.dimensions[CSSDimensionHeight],
getPaddingAndBorderAxis(child, CSSFlexDirectionColumn)); getPaddingAndBorderAxis(child, CSSFlexDirectionColumn));
} else if (!isFlexBasisAuto(child) && !isUndefined(availableInnerMainDim)) { } else if (!isFlexBasisAuto(child) && !CSSValueIsUndefined(availableInnerMainDim)) {
// If the basis isn't 'auto', it is assumed to be zero. // If the basis isn't 'auto', it is assumed to be zero.
child->layout.flexBasis = fmaxf(0, getPaddingAndBorderAxis(child, mainAxis)); child->layout.flexBasis = fmaxf(0, getPaddingAndBorderAxis(child, mainAxis));
@ -1016,7 +1016,7 @@ static void layoutNodeImpl(CSSNode *node,
// child's inline axis is parallel to the main axis (i.e. it's // child's inline axis is parallel to the main axis (i.e. it's
// horizontal), the child should be sized using "UNDEFINED" in // horizontal), the child should be sized using "UNDEFINED" in
// the main size. Otherwise use "AT_MOST" in the cross axis. // the main size. Otherwise use "AT_MOST" in the cross axis.
if (!isMainAxisRow && isUndefined(childWidth) && !isUndefined(availableInnerWidth)) { if (!isMainAxisRow && CSSValueIsUndefined(childWidth) && !CSSValueIsUndefined(availableInnerWidth)) {
childWidth = availableInnerWidth; childWidth = availableInnerWidth;
childWidthMeasureMode = CSSMeasureModeAtMost; childWidthMeasureMode = CSSMeasureModeAtMost;
} }
@ -1024,7 +1024,7 @@ static void layoutNodeImpl(CSSNode *node,
// The W3C spec doesn't say anything about the 'overflow' property, // The W3C spec doesn't say anything about the 'overflow' property,
// but all major browsers appear to implement the following logic. // but all major browsers appear to implement the following logic.
if (node->style.overflow == CSSOverflowHidden) { if (node->style.overflow == CSSOverflowHidden) {
if (isMainAxisRow && isUndefined(childHeight) && !isUndefined(availableInnerHeight)) { if (isMainAxisRow && CSSValueIsUndefined(childHeight) && !CSSValueIsUndefined(availableInnerHeight)) {
childHeight = availableInnerHeight; childHeight = availableInnerHeight;
childHeightMeasureMode = CSSMeasureModeAtMost; childHeightMeasureMode = CSSMeasureModeAtMost;
} }
@ -1033,14 +1033,14 @@ static void layoutNodeImpl(CSSNode *node,
// If child has no defined size in the cross axis and is set to stretch, // If child has no defined size in the cross axis and is set to stretch,
// set the cross // set the cross
// axis to be measured exactly with the available inner width // axis to be measured exactly with the available inner width
if (!isMainAxisRow && !isUndefined(availableInnerWidth) if (!isMainAxisRow && !CSSValueIsUndefined(availableInnerWidth)
&& !isStyleDimDefined(child, CSSFlexDirectionRow) && !isStyleDimDefined(child, CSSFlexDirectionRow)
&& widthMeasureMode == CSSMeasureModeExactly && widthMeasureMode == CSSMeasureModeExactly
&& getAlignItem(node, child) == CSSAlignStretch) { && getAlignItem(node, child) == CSSAlignStretch) {
childWidth = availableInnerWidth; childWidth = availableInnerWidth;
childWidthMeasureMode = CSSMeasureModeExactly; childWidthMeasureMode = CSSMeasureModeExactly;
} }
if (isMainAxisRow && !isUndefined(availableInnerHeight) if (isMainAxisRow && !CSSValueIsUndefined(availableInnerHeight)
&& !isStyleDimDefined(child, CSSFlexDirectionColumn) && !isStyleDimDefined(child, CSSFlexDirectionColumn)
&& heightMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly
&& getAlignItem(node, child) == CSSAlignStretch) { && getAlignItem(node, child) == CSSAlignStretch) {
@ -1157,7 +1157,7 @@ static void layoutNodeImpl(CSSNode *node,
// If the main dimension size isn't known, it is computed based on // If the main dimension size isn't known, it is computed based on
// the line length, so there's no more space left to distribute. // the line length, so there's no more space left to distribute.
float remainingFreeSpace = 0; float remainingFreeSpace = 0;
if (!isUndefined(availableInnerMainDim)) { if (!CSSValueIsUndefined(availableInnerMainDim)) {
remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine;
} else if (sizeConsumedOnCurrentLine < 0) { } else if (sizeConsumedOnCurrentLine < 0) {
// availableInnerMainDim is indefinite which means the node is being sized // availableInnerMainDim is indefinite which means the node is being sized
@ -1287,7 +1287,7 @@ static void layoutNodeImpl(CSSNode *node,
childWidth = updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionRow); childWidth = updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionRow);
childWidthMeasureMode = CSSMeasureModeExactly; childWidthMeasureMode = CSSMeasureModeExactly;
if (!isUndefined(availableInnerCrossDim) if (!CSSValueIsUndefined(availableInnerCrossDim)
&& !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn) && !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn)
&& heightMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly
&& getAlignItem(node, currentRelativeChild) == CSSAlignStretch) { && getAlignItem(node, currentRelativeChild) == CSSAlignStretch) {
@ -1296,7 +1296,7 @@ static void layoutNodeImpl(CSSNode *node,
} else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn)) { } else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionColumn)) {
childHeight = availableInnerCrossDim; childHeight = availableInnerCrossDim;
childHeightMeasureMode childHeightMeasureMode
= isUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost; = CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost;
} else { } else {
childHeight = currentRelativeChild->style.dimensions[CSSDimensionHeight] childHeight = currentRelativeChild->style.dimensions[CSSDimensionHeight]
+ getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn); + getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn);
@ -1307,7 +1307,7 @@ static void layoutNodeImpl(CSSNode *node,
= updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn); = updatedMainSize + getMarginAxis(currentRelativeChild, CSSFlexDirectionColumn);
childHeightMeasureMode = CSSMeasureModeExactly; childHeightMeasureMode = CSSMeasureModeExactly;
if (!isUndefined(availableInnerCrossDim) if (!CSSValueIsUndefined(availableInnerCrossDim)
&& !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow) && !isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow)
&& widthMeasureMode == CSSMeasureModeExactly && widthMeasureMode == CSSMeasureModeExactly
&& getAlignItem(node, currentRelativeChild) == CSSAlignStretch) { && getAlignItem(node, currentRelativeChild) == CSSAlignStretch) {
@ -1316,7 +1316,7 @@ static void layoutNodeImpl(CSSNode *node,
} else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow)) { } else if (!isStyleDimDefined(currentRelativeChild, CSSFlexDirectionRow)) {
childWidth = availableInnerCrossDim; childWidth = availableInnerCrossDim;
childWidthMeasureMode childWidthMeasureMode
= isUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost; = CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeAtMost;
} else { } else {
childWidth = currentRelativeChild->style.dimensions[CSSDimensionWidth] childWidth = currentRelativeChild->style.dimensions[CSSDimensionWidth]
+ getMarginAxis(currentRelativeChild, CSSFlexDirectionRow); + getMarginAxis(currentRelativeChild, CSSFlexDirectionRow);
@ -1493,9 +1493,9 @@ static void layoutNodeImpl(CSSNode *node,
// no need to stretch. // no need to stretch.
if (!isCrossSizeDefinite) { if (!isCrossSizeDefinite) {
childWidthMeasureMode childWidthMeasureMode
= isUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; = CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly;
childHeightMeasureMode childHeightMeasureMode
= isUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; = CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly;
layoutNodeInternal(child, childWidth, childHeight, direction, childWidthMeasureMode, layoutNodeInternal(child, childWidth, childHeight, direction, childWidthMeasureMode,
childHeightMeasureMode, true, "stretch"); childHeightMeasureMode, true, "stretch");
} }
@ -1525,7 +1525,7 @@ static void layoutNodeImpl(CSSNode *node,
} }
// STEP 8: MULTI-LINE CONTENT ALIGNMENT // STEP 8: MULTI-LINE CONTENT ALIGNMENT
if (lineCount > 1 && performLayout && !isUndefined(availableInnerCrossDim)) { if (lineCount > 1 && performLayout && !CSSValueIsUndefined(availableInnerCrossDim)) {
float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim; float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim;
float crossDimLead = 0; float crossDimLead = 0;
@ -1675,17 +1675,17 @@ static void layoutNodeImpl(CSSNode *node,
} }
// If we're still missing one or the other dimension, measure the content. // If we're still missing one or the other dimension, measure the content.
if (isUndefined(childWidth) || isUndefined(childHeight)) { if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) {
childWidthMeasureMode childWidthMeasureMode
= isUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; = CSSValueIsUndefined(childWidth) ? CSSMeasureModeUndefined : CSSMeasureModeExactly;
childHeightMeasureMode childHeightMeasureMode
= isUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly; = CSSValueIsUndefined(childHeight) ? CSSMeasureModeUndefined : CSSMeasureModeExactly;
// According to the spec, if the main size is not definite and the // According to the spec, if the main size is not definite and the
// child's inline axis is parallel to the main axis (i.e. it's // child's inline axis is parallel to the main axis (i.e. it's
// horizontal), the child should be sized using "UNDEFINED" in // horizontal), the child should be sized using "UNDEFINED" in
// the main size. Otherwise use "AT_MOST" in the cross axis. // the main size. Otherwise use "AT_MOST" in the cross axis.
if (!isMainAxisRow && isUndefined(childWidth) && !isUndefined(availableInnerWidth)) { if (!isMainAxisRow && CSSValueIsUndefined(childWidth) && !CSSValueIsUndefined(availableInnerWidth)) {
childWidth = availableInnerWidth; childWidth = availableInnerWidth;
childWidthMeasureMode = CSSMeasureModeAtMost; childWidthMeasureMode = CSSMeasureModeAtMost;
} }
@ -1693,7 +1693,7 @@ static void layoutNodeImpl(CSSNode *node,
// The W3C spec doesn't say anything about the 'overflow' property, // The W3C spec doesn't say anything about the 'overflow' property,
// but all major browsers appear to implement the following logic. // but all major browsers appear to implement the following logic.
if (node->style.overflow == CSSOverflowHidden) { if (node->style.overflow == CSSOverflowHidden) {
if (isMainAxisRow && isUndefined(childHeight) && !isUndefined(availableInnerHeight)) { if (isMainAxisRow && CSSValueIsUndefined(childHeight) && !CSSValueIsUndefined(availableInnerHeight)) {
childHeight = availableInnerHeight; childHeight = availableInnerHeight;
childHeightMeasureMode = CSSMeasureModeAtMost; childHeightMeasureMode = CSSMeasureModeAtMost;
} }
@ -2051,7 +2051,7 @@ void CSSNodeCalculateLayout(
CSSMeasureMode widthMeasureMode = CSSMeasureModeUndefined; CSSMeasureMode widthMeasureMode = CSSMeasureModeUndefined;
CSSMeasureMode heightMeasureMode = CSSMeasureModeUndefined; CSSMeasureMode heightMeasureMode = CSSMeasureModeUndefined;
if (!isUndefined(availableWidth)) { if (!CSSValueIsUndefined(availableWidth)) {
widthMeasureMode = CSSMeasureModeExactly; widthMeasureMode = CSSMeasureModeExactly;
} else if (isStyleDimDefined(node, CSSFlexDirectionRow)) { } else if (isStyleDimDefined(node, CSSFlexDirectionRow)) {
availableWidth = node->style.dimensions[dim[CSSFlexDirectionRow]] availableWidth = node->style.dimensions[dim[CSSFlexDirectionRow]]
@ -2062,7 +2062,7 @@ void CSSNodeCalculateLayout(
widthMeasureMode = CSSMeasureModeAtMost; widthMeasureMode = CSSMeasureModeAtMost;
} }
if (!isUndefined(availableHeight)) { if (!CSSValueIsUndefined(availableHeight)) {
heightMeasureMode = CSSMeasureModeExactly; heightMeasureMode = CSSMeasureModeExactly;
} else if (isStyleDimDefined(node, CSSFlexDirectionColumn)) { } else if (isStyleDimDefined(node, CSSFlexDirectionColumn)) {
availableHeight = node->style.dimensions[dim[CSSFlexDirectionColumn]] availableHeight = node->style.dimensions[dim[CSSFlexDirectionColumn]]

View File

@ -141,7 +141,7 @@ bool CSSNodeIsDirty(CSSNodeRef node);
void CSSNodePrint(CSSNodeRef node, CSSPrintOptions options); void CSSNodePrint(CSSNodeRef node, CSSPrintOptions options);
bool isUndefined(float value); bool CSSValueIsUndefined(float value);
#define CSS_NODE_PROPERTY(type, name, paramName) \ #define CSS_NODE_PROPERTY(type, name, paramName) \
void CSSNodeSet##name(CSSNodeRef node, type paramName); \ void CSSNodeSet##name(CSSNodeRef node, type paramName); \

View File

@ -59,41 +59,41 @@ static void RCTPrint(void *context)
// Enforces precedence rules, e.g. marginLeft > marginHorizontal > margin. // Enforces precedence rules, e.g. marginLeft > marginHorizontal > margin.
#define DEFINE_PROCESS_META_PROPS(type) \ #define DEFINE_PROCESS_META_PROPS(type) \
static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], CSSNodeRef node) { \ static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], CSSNodeRef node) { \
if (!isUndefined(metaProps[META_PROP_LEFT])) { \ if (!CSSValueIsUndefined(metaProps[META_PROP_LEFT])) { \
CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_LEFT]); \ CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_LEFT]); \
} else if (!isUndefined(metaProps[META_PROP_HORIZONTAL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_HORIZONTAL]); \ CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_HORIZONTAL]); \
} else if (!isUndefined(metaProps[META_PROP_ALL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_ALL]); \ CSSNodeStyleSet##type##Start(node, metaProps[META_PROP_ALL]); \
} else { \ } else { \
CSSNodeStyleSet##type##Start(node, 0); \ CSSNodeStyleSet##type##Start(node, 0); \
} \ } \
\ \
if (!isUndefined(metaProps[META_PROP_RIGHT])) { \ if (!CSSValueIsUndefined(metaProps[META_PROP_RIGHT])) { \
CSSNodeStyleSet##type##End(node, metaProps[META_PROP_RIGHT]); \ CSSNodeStyleSet##type##End(node, metaProps[META_PROP_RIGHT]); \
} else if (!isUndefined(metaProps[META_PROP_HORIZONTAL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
CSSNodeStyleSet##type##End(node, metaProps[META_PROP_HORIZONTAL]); \ CSSNodeStyleSet##type##End(node, metaProps[META_PROP_HORIZONTAL]); \
} else if (!isUndefined(metaProps[META_PROP_ALL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type##End(node, metaProps[META_PROP_ALL]); \ CSSNodeStyleSet##type##End(node, metaProps[META_PROP_ALL]); \
} else { \ } else { \
CSSNodeStyleSet##type##End(node, 0); \ CSSNodeStyleSet##type##End(node, 0); \
} \ } \
\ \
if (!isUndefined(metaProps[META_PROP_TOP])) { \ if (!CSSValueIsUndefined(metaProps[META_PROP_TOP])) { \
CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_TOP]); \ CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_TOP]); \
} else if (!isUndefined(metaProps[META_PROP_VERTICAL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_VERTICAL]); \ CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_VERTICAL]); \
} else if (!isUndefined(metaProps[META_PROP_ALL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_ALL]); \ CSSNodeStyleSet##type##Top(node, metaProps[META_PROP_ALL]); \
} else { \ } else { \
CSSNodeStyleSet##type##Top(node, 0); \ CSSNodeStyleSet##type##Top(node, 0); \
} \ } \
\ \
if (!isUndefined(metaProps[META_PROP_BOTTOM])) { \ if (!CSSValueIsUndefined(metaProps[META_PROP_BOTTOM])) { \
CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_BOTTOM]); \ CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_BOTTOM]); \
} else if (!isUndefined(metaProps[META_PROP_VERTICAL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_VERTICAL]); \ CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_VERTICAL]); \
} else if (!isUndefined(metaProps[META_PROP_ALL])) { \ } else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_ALL]); \ CSSNodeStyleSet##type##Bottom(node, metaProps[META_PROP_ALL]); \
} else { \ } else { \
CSSNodeStyleSet##type##Bottom(node, 0); \ CSSNodeStyleSet##type##Bottom(node, 0); \
@ -484,22 +484,22 @@ RCT_PADDING_PROPERTY(Right, RIGHT)
if (CSSNodeLayoutGetDirection(_cssNode) == CSSDirectionRTL) { if (CSSNodeLayoutGetDirection(_cssNode) == CSSDirectionRTL) {
return (UIEdgeInsets){ return (UIEdgeInsets){
CSSNodeStyleGetPaddingTop(_cssNode), CSSNodeStyleGetPaddingTop(_cssNode),
!isUndefined(CSSNodeStyleGetPaddingEnd(_cssNode)) ? !CSSValueIsUndefined(CSSNodeStyleGetPaddingEnd(_cssNode)) ?
CSSNodeStyleGetPaddingEnd(_cssNode) : CSSNodeStyleGetPaddingEnd(_cssNode) :
CSSNodeStyleGetPaddingLeft(_cssNode), CSSNodeStyleGetPaddingLeft(_cssNode),
CSSNodeStyleGetPaddingBottom(_cssNode), CSSNodeStyleGetPaddingBottom(_cssNode),
!isUndefined(CSSNodeStyleGetPaddingStart(_cssNode)) ? !CSSValueIsUndefined(CSSNodeStyleGetPaddingStart(_cssNode)) ?
CSSNodeStyleGetPaddingStart(_cssNode) : CSSNodeStyleGetPaddingStart(_cssNode) :
CSSNodeStyleGetPaddingRight(_cssNode) CSSNodeStyleGetPaddingRight(_cssNode)
}; };
} else { } else {
return (UIEdgeInsets){ return (UIEdgeInsets){
CSSNodeStyleGetPaddingTop(_cssNode), CSSNodeStyleGetPaddingTop(_cssNode),
!isUndefined(CSSNodeStyleGetPaddingStart(_cssNode)) ? !CSSValueIsUndefined(CSSNodeStyleGetPaddingStart(_cssNode)) ?
CSSNodeStyleGetPaddingStart(_cssNode) : CSSNodeStyleGetPaddingStart(_cssNode) :
CSSNodeStyleGetPaddingLeft(_cssNode), CSSNodeStyleGetPaddingLeft(_cssNode),
CSSNodeStyleGetPaddingBottom(_cssNode), CSSNodeStyleGetPaddingBottom(_cssNode),
!isUndefined(CSSNodeStyleGetPaddingEnd(_cssNode)) ? !CSSValueIsUndefined(CSSNodeStyleGetPaddingEnd(_cssNode)) ?
CSSNodeStyleGetPaddingEnd(_cssNode) : CSSNodeStyleGetPaddingEnd(_cssNode) :
CSSNodeStyleGetPaddingRight(_cssNode) CSSNodeStyleGetPaddingRight(_cssNode)
}; };