Fixup format file for hopefully the last time in a while and re-format code
Reviewed By: gkassabli Differential Revision: D4044545 fbshipit-source-id: 60ebb73cfdd9dbc9b5fae62ddebf37e9b1e6eecf
This commit is contained in:
parent
ffe06d3cfa
commit
9ed8cae47e
|
@ -100,8 +100,9 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node);
|
||||||
|
|
||||||
static CSSLogger gLogger = &printf;
|
static CSSLogger gLogger = &printf;
|
||||||
|
|
||||||
static float
|
static float computedEdgeValue(const float edges[CSSEdgeCount],
|
||||||
computedEdgeValue(const float edges[CSSEdgeCount], const CSSEdge edge, const float defaultValue) {
|
const CSSEdge edge,
|
||||||
|
const float defaultValue) {
|
||||||
CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get computed value of multi-edge shorthands");
|
CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get computed value of multi-edge shorthands");
|
||||||
|
|
||||||
if (!CSSValueIsUndefined(edges[edge])) {
|
if (!CSSValueIsUndefined(edges[edge])) {
|
||||||
|
@ -397,8 +398,9 @@ static bool eqFour(const float four[4]) {
|
||||||
return eq(four[0], four[1]) && eq(four[0], four[2]) && eq(four[0], four[3]);
|
return eq(four[0], four[1]) && eq(four[0], four[2]) && eq(four[0], four[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void _CSSNodePrint(const CSSNodeRef node,
|
||||||
_CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options, const uint32_t level) {
|
const CSSPrintOptions options,
|
||||||
|
const uint32_t level) {
|
||||||
indent(level);
|
indent(level);
|
||||||
gLogger("{");
|
gLogger("{");
|
||||||
|
|
||||||
|
@ -761,8 +763,9 @@ static float getTrailingPosition(const CSSNodeRef node, const CSSFlexDirection a
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float
|
static float boundAxisWithinMinAndMax(const CSSNodeRef node,
|
||||||
boundAxisWithinMinAndMax(const CSSNodeRef node, const CSSFlexDirection axis, const float value) {
|
const CSSFlexDirection axis,
|
||||||
|
const float value) {
|
||||||
float min = CSSUndefined;
|
float min = CSSUndefined;
|
||||||
float max = CSSUndefined;
|
float max = CSSUndefined;
|
||||||
|
|
||||||
|
@ -794,8 +797,9 @@ static float boundAxis(const CSSNodeRef node, const CSSFlexDirection axis, const
|
||||||
return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis));
|
return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void setTrailingPosition(const CSSNodeRef node,
|
||||||
setTrailingPosition(const CSSNodeRef node, const CSSNodeRef child, const CSSFlexDirection axis) {
|
const CSSNodeRef child,
|
||||||
|
const CSSFlexDirection axis) {
|
||||||
const float size = child->layout.measuredDimensions[dim[axis]];
|
const float size = child->layout.measuredDimensions[dim[axis]];
|
||||||
child->layout.position[trailing[axis]] =
|
child->layout.position[trailing[axis]] =
|
||||||
node->layout.measuredDimensions[dim[axis]] - size - child->layout.position[pos[axis]];
|
node->layout.measuredDimensions[dim[axis]] - size - child->layout.position[pos[axis]];
|
||||||
|
@ -824,15 +828,13 @@ static void setPosition(const CSSNodeRef node, const CSSDirection direction) {
|
||||||
getTrailingMargin(node, crossAxis) + getRelativePosition(node, crossAxis);
|
getTrailingMargin(node, crossAxis) + getRelativePosition(node, crossAxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void computeChildFlexBasis(
|
static void computeChildFlexBasis(const CSSNodeRef node,
|
||||||
const CSSNodeRef node,
|
const CSSNodeRef child,
|
||||||
const CSSNodeRef child,
|
const float width,
|
||||||
const float width,
|
const CSSMeasureMode widthMode,
|
||||||
const CSSMeasureMode widthMode,
|
const float height,
|
||||||
const float height,
|
const CSSMeasureMode heightMode,
|
||||||
const CSSMeasureMode heightMode,
|
const CSSDirection direction) {
|
||||||
const CSSDirection direction) {
|
|
||||||
|
|
||||||
const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction);
|
const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction);
|
||||||
const bool isMainAxisRow = isRowDirection(mainAxis);
|
const bool isMainAxisRow = isRowDirection(mainAxis);
|
||||||
|
|
||||||
|
@ -849,14 +851,12 @@ static void computeChildFlexBasis(
|
||||||
}
|
}
|
||||||
} else if (isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
} else if (isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
||||||
// The width is definite, so use that as the flex basis.
|
// The width is definite, so use that as the flex basis.
|
||||||
child->layout.computedFlexBasis =
|
child->layout.computedFlexBasis = fmaxf(child->style.dimensions[CSSDimensionWidth],
|
||||||
fmaxf(child->style.dimensions[CSSDimensionWidth],
|
getPaddingAndBorderAxis(child, CSSFlexDirectionRow));
|
||||||
getPaddingAndBorderAxis(child, CSSFlexDirectionRow));
|
|
||||||
} else if (!isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
} else if (!isMainAxisRow && isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
||||||
// The height is definite, so use that as the flex basis.
|
// The height is definite, so use that as the flex basis.
|
||||||
child->layout.computedFlexBasis =
|
child->layout.computedFlexBasis = fmaxf(child->style.dimensions[CSSDimensionHeight],
|
||||||
fmaxf(child->style.dimensions[CSSDimensionHeight],
|
getPaddingAndBorderAxis(child, CSSFlexDirectionColumn));
|
||||||
getPaddingAndBorderAxis(child, CSSFlexDirectionColumn));
|
|
||||||
} else {
|
} else {
|
||||||
// Compute the flex basis and hypothetical main size (i.e. the clamped
|
// Compute the flex basis and hypothetical main size (i.e. the clamped
|
||||||
// flex basis).
|
// flex basis).
|
||||||
|
@ -866,8 +866,8 @@ static void computeChildFlexBasis(
|
||||||
childHeightMeasureMode = CSSMeasureModeUndefined;
|
childHeightMeasureMode = CSSMeasureModeUndefined;
|
||||||
|
|
||||||
if (isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
if (isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
||||||
childWidth = child->style.dimensions[CSSDimensionWidth] +
|
childWidth =
|
||||||
getMarginAxis(child, CSSFlexDirectionRow);
|
child->style.dimensions[CSSDimensionWidth] + getMarginAxis(child, CSSFlexDirectionRow);
|
||||||
childWidthMeasureMode = CSSMeasureModeExactly;
|
childWidthMeasureMode = CSSMeasureModeExactly;
|
||||||
}
|
}
|
||||||
if (isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
if (isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
||||||
|
@ -898,15 +898,13 @@ static void computeChildFlexBasis(
|
||||||
// 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 && !CSSValueIsUndefined(width) &&
|
if (!isMainAxisRow && !CSSValueIsUndefined(width) &&
|
||||||
!isStyleDimDefined(child, CSSFlexDirectionRow) &&
|
!isStyleDimDefined(child, CSSFlexDirectionRow) && widthMode == CSSMeasureModeExactly &&
|
||||||
widthMode == CSSMeasureModeExactly &&
|
|
||||||
getAlignItem(node, child) == CSSAlignStretch) {
|
getAlignItem(node, child) == CSSAlignStretch) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = CSSMeasureModeExactly;
|
childWidthMeasureMode = CSSMeasureModeExactly;
|
||||||
}
|
}
|
||||||
if (isMainAxisRow && !CSSValueIsUndefined(height) &&
|
if (isMainAxisRow && !CSSValueIsUndefined(height) &&
|
||||||
!isStyleDimDefined(child, CSSFlexDirectionColumn) &&
|
!isStyleDimDefined(child, CSSFlexDirectionColumn) && heightMode == CSSMeasureModeExactly &&
|
||||||
heightMode == CSSMeasureModeExactly &&
|
|
||||||
getAlignItem(node, child) == CSSAlignStretch) {
|
getAlignItem(node, child) == CSSAlignStretch) {
|
||||||
childHeight = height;
|
childHeight = height;
|
||||||
childHeightMeasureMode = CSSMeasureModeExactly;
|
childHeightMeasureMode = CSSMeasureModeExactly;
|
||||||
|
@ -929,13 +927,11 @@ static void computeChildFlexBasis(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void absoluteLayoutChild(
|
static void absoluteLayoutChild(const CSSNodeRef node,
|
||||||
const CSSNodeRef node,
|
const CSSNodeRef child,
|
||||||
const CSSNodeRef child,
|
const float width,
|
||||||
const float width,
|
const CSSMeasureMode widthMode,
|
||||||
const CSSMeasureMode widthMode,
|
const CSSDirection direction) {
|
||||||
const CSSDirection direction) {
|
|
||||||
|
|
||||||
const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction);
|
const CSSFlexDirection mainAxis = resolveAxis(node->style.flexDirection, direction);
|
||||||
const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction);
|
const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction);
|
||||||
const bool isMainAxisRow = isRowDirection(mainAxis);
|
const bool isMainAxisRow = isRowDirection(mainAxis);
|
||||||
|
@ -946,8 +942,8 @@ static void absoluteLayoutChild(
|
||||||
CSSMeasureMode childHeightMeasureMode = CSSMeasureModeUndefined;
|
CSSMeasureMode childHeightMeasureMode = CSSMeasureModeUndefined;
|
||||||
|
|
||||||
if (isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
if (isStyleDimDefined(child, CSSFlexDirectionRow)) {
|
||||||
childWidth = child->style.dimensions[CSSDimensionWidth] +
|
childWidth =
|
||||||
getMarginAxis(child, CSSFlexDirectionRow);
|
child->style.dimensions[CSSDimensionWidth] + getMarginAxis(child, CSSFlexDirectionRow);
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified width, compute the width based
|
// If the child doesn't have a specified width, compute the width based
|
||||||
// on the left/right
|
// on the left/right
|
||||||
|
@ -964,8 +960,8 @@ static void absoluteLayoutChild(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
if (isStyleDimDefined(child, CSSFlexDirectionColumn)) {
|
||||||
childHeight = child->style.dimensions[CSSDimensionHeight] +
|
childHeight =
|
||||||
getMarginAxis(child, CSSFlexDirectionColumn);
|
child->style.dimensions[CSSDimensionHeight] + getMarginAxis(child, CSSFlexDirectionColumn);
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified height, compute the height
|
// If the child doesn't have a specified height, compute the height
|
||||||
// based on the top/bottom
|
// based on the top/bottom
|
||||||
|
@ -1020,20 +1016,16 @@ static void absoluteLayoutChild(
|
||||||
true,
|
true,
|
||||||
"abs-layout");
|
"abs-layout");
|
||||||
|
|
||||||
if (isTrailingPosDefined(child, mainAxis) &&
|
if (isTrailingPosDefined(child, mainAxis) && !isLeadingPosDefined(child, mainAxis)) {
|
||||||
!isLeadingPosDefined(child, mainAxis)) {
|
child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] -
|
||||||
child->layout.position[leading[mainAxis]] =
|
child->layout.measuredDimensions[dim[mainAxis]] -
|
||||||
node->layout.measuredDimensions[dim[mainAxis]] -
|
getTrailingPosition(child, mainAxis);
|
||||||
child->layout.measuredDimensions[dim[mainAxis]] -
|
|
||||||
getTrailingPosition(child, mainAxis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTrailingPosDefined(child, crossAxis) &&
|
if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) {
|
||||||
!isLeadingPosDefined(child, crossAxis)) {
|
child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] -
|
||||||
child->layout.position[leading[crossAxis]] =
|
child->layout.measuredDimensions[dim[crossAxis]] -
|
||||||
node->layout.measuredDimensions[dim[crossAxis]] -
|
getTrailingPosition(child, crossAxis);
|
||||||
child->layout.measuredDimensions[dim[crossAxis]] -
|
|
||||||
getTrailingPosition(child, crossAxis);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,14 +1327,13 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
currentAbsoluteChild = child;
|
currentAbsoluteChild = child;
|
||||||
child->nextChild = NULL;
|
child->nextChild = NULL;
|
||||||
} else {
|
} else {
|
||||||
computeChildFlexBasis(
|
computeChildFlexBasis(node,
|
||||||
node,
|
child,
|
||||||
child,
|
availableInnerWidth,
|
||||||
availableInnerWidth,
|
widthMeasureMode,
|
||||||
widthMeasureMode,
|
availableInnerHeight,
|
||||||
availableInnerHeight,
|
heightMeasureMode,
|
||||||
heightMeasureMode,
|
direction);
|
||||||
direction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,8 +1548,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
} else {
|
} else {
|
||||||
childSize =
|
childSize =
|
||||||
childFlexBasis +
|
childFlexBasis +
|
||||||
(remainingFreeSpace / totalFlexShrinkScaledFactors) *
|
(remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor;
|
||||||
flexShrinkScaledFactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize);
|
updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize);
|
||||||
|
@ -1658,8 +1648,11 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
// constraint by the min size defined for the main axis.
|
// constraint by the min size defined for the main axis.
|
||||||
|
|
||||||
if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) {
|
if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) {
|
||||||
if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && node->style.minDimensions[dim[mainAxis]] >= 0) {
|
if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) &&
|
||||||
remainingFreeSpace = fmax(0, node->style.minDimensions[dim[mainAxis]] - (availableInnerMainDim - remainingFreeSpace));
|
node->style.minDimensions[dim[mainAxis]] >= 0) {
|
||||||
|
remainingFreeSpace = fmax(0,
|
||||||
|
node->style.minDimensions[dim[mainAxis]] -
|
||||||
|
(availableInnerMainDim - remainingFreeSpace));
|
||||||
} else {
|
} else {
|
||||||
remainingFreeSpace = 0;
|
remainingFreeSpace = 0;
|
||||||
}
|
}
|
||||||
|
@ -1971,15 +1964,10 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
|
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
||||||
for (currentAbsoluteChild = firstAbsoluteChild;
|
for (currentAbsoluteChild = firstAbsoluteChild; currentAbsoluteChild != NULL;
|
||||||
currentAbsoluteChild != NULL;
|
|
||||||
currentAbsoluteChild = currentAbsoluteChild->nextChild) {
|
currentAbsoluteChild = currentAbsoluteChild->nextChild) {
|
||||||
absoluteLayoutChild(
|
absoluteLayoutChild(
|
||||||
node,
|
node, currentAbsoluteChild, availableInnerWidth, widthMeasureMode, direction);
|
||||||
currentAbsoluteChild,
|
|
||||||
availableInnerWidth,
|
|
||||||
widthMeasureMode,
|
|
||||||
direction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||||
|
|
|
@ -135,15 +135,17 @@ WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
|
||||||
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
|
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
|
||||||
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
|
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
|
||||||
|
|
||||||
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index);
|
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node,
|
||||||
|
const CSSNodeRef child,
|
||||||
|
const uint32_t index);
|
||||||
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
|
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
|
||||||
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
|
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
|
||||||
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
|
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
|
||||||
|
|
||||||
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
|
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const CSSDirection parentDirection);
|
const CSSDirection parentDirection);
|
||||||
|
|
||||||
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
||||||
// set.
|
// set.
|
||||||
|
@ -158,19 +160,22 @@ WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions option
|
||||||
|
|
||||||
WIN_EXPORT bool CSSValueIsUndefined(const float value);
|
WIN_EXPORT bool CSSValueIsUndefined(const float value);
|
||||||
|
|
||||||
#define CSS_NODE_PROPERTY(type, name, paramName) \
|
#define CSS_NODE_PROPERTY(type, name, paramName) \
|
||||||
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
|
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
|
||||||
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
|
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
|
||||||
|
|
||||||
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
|
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
|
||||||
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
|
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
|
||||||
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
|
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
|
||||||
|
|
||||||
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
||||||
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName); \
|
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \
|
||||||
|
const CSSEdge edge, \
|
||||||
|
const type paramName); \
|
||||||
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge);
|
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge);
|
||||||
|
|
||||||
#define CSS_NODE_LAYOUT_PROPERTY(type, name) WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
|
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
|
||||||
|
WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
|
||||||
|
|
||||||
CSS_NODE_PROPERTY(void *, Context, context);
|
CSS_NODE_PROPERTY(void *, Context, context);
|
||||||
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
|
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
|
||||||
|
|
Loading…
Reference in New Issue