More constness

Summary:
@public

Some `YGNode*` passed as `const YGNode*`, some const refs to sub-objects introduced.
This helps selecting the desired methods in more places, i.e. `const` overloads of accessors on `YGStyle`.

Reviewed By: SidharthGuglani

Differential Revision: D15078963

fbshipit-source-id: 5013721d6edcc68f42f4504f5c331da647a294bd
This commit is contained in:
David Aurelio
2019-04-29 09:18:57 -07:00
committed by Facebook Github Bot
parent 98fda9c587
commit cc02a20c9e

View File

@@ -972,7 +972,7 @@ static const std::array<YGDimension, 4> dim = {
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}}; {YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
static inline float YGNodePaddingAndBorderForAxis( static inline float YGNodePaddingAndBorderForAxis(
const YGNodeRef node, const YGNodeConstRef node,
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) { const float widthSize) {
return (node->getLeadingPaddingAndBorder(axis, widthSize) + return (node->getLeadingPaddingAndBorder(axis, widthSize) +
@@ -1089,7 +1089,7 @@ static inline bool YGNodeIsLayoutDimDefined(
} }
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax( static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
const YGNodeRef node, const YGNodeConstRef node,
const YGFlexDirection axis, const YGFlexDirection axis,
const YGFloatOptional value, const YGFloatOptional value,
const float axisSize) { const float axisSize) {
@@ -1146,7 +1146,7 @@ static void YGNodeSetChildTrailingPosition(
} }
static void YGConstrainMaxSizeForMode( static void YGConstrainMaxSizeForMode(
const YGNodeRef node, const YGNodeConstRef node,
const enum YGFlexDirection axis, const enum YGFlexDirection axis,
const float ownerAxisSize, const float ownerAxisSize,
const float ownerWidth, const float ownerWidth,
@@ -1758,7 +1758,7 @@ static void YGZeroOutLayoutRecursivly(
} }
static float YGNodeCalculateAvailableInnerDim( static float YGNodeCalculateAvailableInnerDim(
const YGNodeRef node, const YGNodeConstRef node,
YGFlexDirection axis, YGFlexDirection axis,
float availableDim, float availableDim,
float ownerDim) { float ownerDim) {
@@ -2747,25 +2747,19 @@ static void YGNodelayoutImpl(
const float marginAxisColumn = const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap(); node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
const auto& minDimensions = node->getStyle().minDimensions();
const auto& maxDimensions = node->getStyle().maxDimensions();
const float minInnerWidth = const float minInnerWidth =
YGResolveValue( YGResolveValue(minDimensions[YGDimensionWidth], ownerWidth).unwrap() -
node->getStyle().minDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow; paddingAndBorderAxisRow;
const float maxInnerWidth = const float maxInnerWidth =
YGResolveValue( YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap() -
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow; paddingAndBorderAxisRow;
const float minInnerHeight = const float minInnerHeight =
YGResolveValue( YGResolveValue(minDimensions[YGDimensionHeight], ownerHeight).unwrap() -
node->getStyle().minDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn; paddingAndBorderAxisColumn;
const float maxInnerHeight = const float maxInnerHeight =
YGResolveValue( YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight).unwrap() -
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn; paddingAndBorderAxisColumn;
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight; const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
@@ -4002,6 +3996,7 @@ void YGNodeCalculateLayoutWithContext(
node->resolveDimension(); node->resolveDimension();
float width = YGUndefined; float width = YGUndefined;
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
const auto& maxDimensions = node->getStyle().maxDimensions();
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, ownerWidth)) { if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, ownerWidth)) {
width = width =
(YGResolveValue( (YGResolveValue(
@@ -4009,13 +4004,10 @@ void YGNodeCalculateLayoutWithContext(
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)) node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
.unwrap(); .unwrap();
widthMeasureMode = YGMeasureModeExactly; widthMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue( } else if (!YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
node->getStyle().maxDimensions()[YGDimensionWidth],
ownerWidth)
.isUndefined()) { .isUndefined()) {
width = YGResolveValue( width =
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth) YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap();
.unwrap();
widthMeasureMode = YGMeasureModeAtMost; widthMeasureMode = YGMeasureModeAtMost;
} else { } else {
width = ownerWidth; width = ownerWidth;
@@ -4032,14 +4024,10 @@ void YGNodeCalculateLayoutWithContext(
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)) node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
.unwrap(); .unwrap();
heightMeasureMode = YGMeasureModeExactly; heightMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue( } else if (!YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
node->getStyle().maxDimensions()[YGDimensionHeight],
ownerHeight)
.isUndefined()) { .isUndefined()) {
height = height =
YGResolveValue( YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight).unwrap();
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
.unwrap();
heightMeasureMode = YGMeasureModeAtMost; heightMeasureMode = YGMeasureModeAtMost;
} else { } else {
height = ownerHeight; height = ownerHeight;