Remove usage of Dimension arrays and YGDimension as index (#1402)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1402 X-link: https://github.com/facebook/react-native/pull/39567 This change hides away most usages of YGDimension as an index. We do this for a couple reasons: 1. Right now the style interface may return a full array of resolved edge or dimension values, as a CompactValue. As we abstract away from CompactValue, and move towards ValuePool, this will no longer be the internal interface, and cheap to return. We instead change the interface to return a single value at once, which lets us resolve values lazily. 2. As we move internal usage to scoped enums, enums are not implicitly convertible to intergers (broadly a good thing). Hiding the enum as index prevents the need for callers to cast or convert to underlying. Instead of making a new version of `IdxRef` for this, I converted to a more traditional setter. I will be making similar changes later for other styles, when I hide CompactValue from the public interface. To review I would recommend filtering to changes in `xplat`, or viewing this in a single one of the OSS PRs exported. Everything apart from the below 20 files is a mirror. {F1096792573} Changelog: [Internal] Reviewed By: javache Differential Revision: D49362819 fbshipit-source-id: 30d730d78e62f36597d43f477120f65694e51ea3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
81754d8cb2
commit
83705c2942
@@ -203,33 +203,6 @@ INDEX_ACCESSOR_TEST(
|
|||||||
CompactValue::of<YGUnitPoint>(-7777.77f),
|
CompactValue::of<YGUnitPoint>(-7777.77f),
|
||||||
CompactValue::ofUndefined())
|
CompactValue::ofUndefined())
|
||||||
|
|
||||||
INDEX_ACCESSOR_TEST(
|
|
||||||
dimensions,
|
|
||||||
CompactValue::ofAuto(),
|
|
||||||
YGDimensionWidth,
|
|
||||||
CompactValue::ofUndefined(),
|
|
||||||
CompactValue::ofAuto(),
|
|
||||||
CompactValue::of<YGUnitPoint>(7777.77f),
|
|
||||||
CompactValue::of<YGUnitPercent>(-100.0f))
|
|
||||||
|
|
||||||
INDEX_ACCESSOR_TEST(
|
|
||||||
minDimensions,
|
|
||||||
CompactValue::ofUndefined(),
|
|
||||||
YGDimensionHeight,
|
|
||||||
CompactValue::ofAuto(),
|
|
||||||
CompactValue::ofUndefined(),
|
|
||||||
CompactValue::of<YGUnitPoint>(7777.77f),
|
|
||||||
CompactValue::of<YGUnitPercent>(-100.0f))
|
|
||||||
|
|
||||||
INDEX_ACCESSOR_TEST(
|
|
||||||
maxDimensions,
|
|
||||||
CompactValue::ofUndefined(),
|
|
||||||
YGDimensionHeight,
|
|
||||||
CompactValue::ofAuto(),
|
|
||||||
CompactValue::ofUndefined(),
|
|
||||||
CompactValue::of<YGUnitPoint>(7777.77f),
|
|
||||||
CompactValue::of<YGUnitPercent>(-100.0f))
|
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
aspectRatio,
|
aspectRatio,
|
||||||
FloatOptional{},
|
FloatOptional{},
|
||||||
|
@@ -419,6 +419,15 @@ void updateIndexedStyleProp(
|
|||||||
[idx, prop](Style& s, CompactValue x) { (s.*prop)()[idx] = x; });
|
[idx, prop](Style& s, CompactValue x) { (s.*prop)()[idx] = x; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <auto GetterT, auto SetterT, typename IdxT>
|
||||||
|
void updateIndexedStyleProp(YGNodeRef node, IdxT idx, CompactValue value) {
|
||||||
|
updateStyle(
|
||||||
|
resolveRef(node),
|
||||||
|
value,
|
||||||
|
[idx](Style& s, CompactValue x) { return (s.*GetterT)(idx) != x; },
|
||||||
|
[idx](Style& s, CompactValue x) { (s.*SetterT)(idx, x); });
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// MSVC has trouble inferring the return type of pointer to member functions
|
// MSVC has trouble inferring the return type of pointer to member functions
|
||||||
@@ -664,98 +673,98 @@ void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
|||||||
|
|
||||||
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionWidth, CompactValue::ofAuto());
|
node, YGDimensionWidth, CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().dimensions()[YGDimensionWidth];
|
return resolveRef(node)->getStyle().dimension(YGDimensionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
updateIndexedStyleProp<&Style::dimension, &Style::setDimension>(
|
||||||
node, &Style::dimensions, YGDimensionHeight, CompactValue::ofAuto());
|
node, YGDimensionHeight, CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().dimensions()[YGDimensionHeight];
|
return resolveRef(node)->getStyle().dimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(minWidth);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(minWidth);
|
||||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
updateIndexedStyleProp<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, &Style::minDimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(minWidth);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(minWidth);
|
||||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
updateIndexedStyleProp<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, &Style::minDimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().minDimensions()[YGDimensionWidth];
|
return resolveRef(node)->getStyle().minDimension(YGDimensionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(minHeight);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(minHeight);
|
||||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
updateIndexedStyleProp<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, &Style::minDimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetMinHeightPercent(
|
void YGNodeStyleSetMinHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float minHeight) {
|
const float minHeight) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(minHeight);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(minHeight);
|
||||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
updateIndexedStyleProp<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, &Style::minDimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().minDimensions()[YGDimensionHeight];
|
return resolveRef(node)->getStyle().minDimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
|
||||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
updateIndexedStyleProp<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, &Style::maxDimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
|
||||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
updateIndexedStyleProp<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, &Style::maxDimensions, YGDimensionWidth, value);
|
node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().maxDimensions()[YGDimensionWidth];
|
return resolveRef(node)->getStyle().maxDimension(YGDimensionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
|
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
|
||||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
updateIndexedStyleProp<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, &Style::maxDimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
void YGNodeStyleSetMaxHeightPercent(
|
void YGNodeStyleSetMaxHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float maxHeight) {
|
const float maxHeight) {
|
||||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
|
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
|
||||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
updateIndexedStyleProp<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, &Style::maxDimensions, YGDimensionHeight, value);
|
node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().maxDimensions()[YGDimensionHeight];
|
return resolveRef(node)->getStyle().maxDimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -808,11 +817,11 @@ float YGNodeLayoutGetBottom(const YGNodeConstRef node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetWidth(const YGNodeConstRef node) {
|
float YGNodeLayoutGetWidth(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().dimensions[YGDimensionWidth];
|
return resolveRef(node)->getLayout().dimension(YGDimensionWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeLayoutGetHeight(const YGNodeConstRef node) {
|
float YGNodeLayoutGetHeight(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getLayout().dimensions[YGDimensionHeight];
|
return resolveRef(node)->getLayout().dimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
YGDirection YGNodeLayoutGetDirection(const YGNodeConstRef node) {
|
YGDirection YGNodeLayoutGetDirection(const YGNodeConstRef node) {
|
||||||
|
@@ -19,8 +19,8 @@ float calculateBaseline(const yoga::Node* node) {
|
|||||||
Event::publish<Event::NodeBaselineStart>(node);
|
Event::publish<Event::NodeBaselineStart>(node);
|
||||||
|
|
||||||
const float baseline = node->baseline(
|
const float baseline = node->baseline(
|
||||||
node->getLayout().measuredDimensions[YGDimensionWidth],
|
node->getLayout().measuredDimension(YGDimensionWidth),
|
||||||
node->getLayout().measuredDimensions[YGDimensionHeight]);
|
node->getLayout().measuredDimension(YGDimensionHeight));
|
||||||
|
|
||||||
Event::publish<Event::NodeBaselineEnd>(node);
|
Event::publish<Event::NodeBaselineEnd>(node);
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ float calculateBaseline(const yoga::Node* node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (baselineChild == nullptr) {
|
if (baselineChild == nullptr) {
|
||||||
return node->getLayout().measuredDimensions[YGDimensionHeight];
|
return node->getLayout().measuredDimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float baseline = calculateBaseline(baselineChild);
|
const float baseline = calculateBaseline(baselineChild);
|
||||||
|
@@ -35,14 +35,14 @@ inline FloatOptional boundAxisWithinMinAndMax(
|
|||||||
|
|
||||||
if (isColumn(axis)) {
|
if (isColumn(axis)) {
|
||||||
min = yoga::resolveValue(
|
min = yoga::resolveValue(
|
||||||
node->getStyle().minDimensions()[YGDimensionHeight], axisSize);
|
node->getStyle().minDimension(YGDimensionHeight), axisSize);
|
||||||
max = yoga::resolveValue(
|
max = yoga::resolveValue(
|
||||||
node->getStyle().maxDimensions()[YGDimensionHeight], axisSize);
|
node->getStyle().maxDimension(YGDimensionHeight), axisSize);
|
||||||
} else if (isRow(axis)) {
|
} else if (isRow(axis)) {
|
||||||
min = yoga::resolveValue(
|
min = yoga::resolveValue(
|
||||||
node->getStyle().minDimensions()[YGDimensionWidth], axisSize);
|
node->getStyle().minDimension(YGDimensionWidth), axisSize);
|
||||||
max = yoga::resolveValue(
|
max = yoga::resolveValue(
|
||||||
node->getStyle().maxDimensions()[YGDimensionWidth], axisSize);
|
node->getStyle().maxDimension(YGDimensionWidth), axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max >= FloatOptional{0} && value > max) {
|
if (max >= FloatOptional{0} && value > max) {
|
||||||
|
@@ -53,7 +53,7 @@ static inline float dimensionWithMargin(
|
|||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const FlexDirection axis,
|
const FlexDirection axis,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return node->getLayout().measuredDimensions[dimension(axis)] +
|
return node->getLayout().measuredDimension(dimension(axis)) +
|
||||||
(node->getLeadingMargin(axis, widthSize) +
|
(node->getLeadingMargin(axis, widthSize) +
|
||||||
node->getTrailingMargin(axis, widthSize))
|
node->getTrailingMargin(axis, widthSize))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -79,7 +79,7 @@ static inline bool styleDefinesDimension(
|
|||||||
static inline bool isLayoutDimensionDefined(
|
static inline bool isLayoutDimensionDefined(
|
||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
const FlexDirection axis) {
|
const FlexDirection axis) {
|
||||||
const float value = node->getLayout().measuredDimensions[dimension(axis)];
|
const float value = node->getLayout().measuredDimension(dimension(axis));
|
||||||
return !yoga::isUndefined(value) && value >= 0.0f;
|
return !yoga::isUndefined(value) && value >= 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,9 +87,9 @@ static void setChildTrailingPosition(
|
|||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
yoga::Node* const child,
|
yoga::Node* const child,
|
||||||
const FlexDirection axis) {
|
const FlexDirection axis) {
|
||||||
const float size = child->getLayout().measuredDimensions[dimension(axis)];
|
const float size = child->getLayout().measuredDimension(dimension(axis));
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(axis)] - size -
|
node->getLayout().measuredDimension(dimension(axis)) - size -
|
||||||
child->getLayout().position[leadingEdge(axis)],
|
child->getLayout().position[leadingEdge(axis)],
|
||||||
trailingEdge(axis));
|
trailingEdge(axis));
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ static void constrainMaxSizeForMode(
|
|||||||
float* size) {
|
float* size) {
|
||||||
const FloatOptional maxSize =
|
const FloatOptional maxSize =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
node->getStyle().maxDimensions()[dimension(axis)], ownerAxisSize) +
|
node->getStyle().maxDimension(dimension(axis)), ownerAxisSize) +
|
||||||
FloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
FloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
||||||
switch (*mode) {
|
switch (*mode) {
|
||||||
case MeasureMode::Exactly:
|
case MeasureMode::Exactly:
|
||||||
@@ -169,7 +169,7 @@ static void computeFlexBasisForChild(
|
|||||||
|
|
||||||
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth),
|
child->getResolvedDimension(YGDimensionWidth), ownerWidth),
|
||||||
paddingAndBorder));
|
paddingAndBorder));
|
||||||
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
||||||
// The height is definite, so use that as the flex basis.
|
// The height is definite, so use that as the flex basis.
|
||||||
@@ -177,7 +177,7 @@ static void computeFlexBasisForChild(
|
|||||||
paddingAndBorderForAxis(child, FlexDirection::Column, ownerWidth));
|
paddingAndBorderForAxis(child, FlexDirection::Column, ownerWidth));
|
||||||
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
|
child->getResolvedDimension(YGDimensionHeight), ownerHeight),
|
||||||
paddingAndBorder));
|
paddingAndBorder));
|
||||||
} else {
|
} else {
|
||||||
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
|
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
|
||||||
@@ -195,7 +195,7 @@ static void computeFlexBasisForChild(
|
|||||||
if (isRowStyleDimDefined) {
|
if (isRowStyleDimDefined) {
|
||||||
childWidth =
|
childWidth =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
|
child->getResolvedDimension(YGDimensionWidth), ownerWidth)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
childWidthMeasureMode = MeasureMode::Exactly;
|
childWidthMeasureMode = MeasureMode::Exactly;
|
||||||
@@ -203,7 +203,7 @@ static void computeFlexBasisForChild(
|
|||||||
if (isColumnStyleDimDefined) {
|
if (isColumnStyleDimDefined) {
|
||||||
childHeight =
|
childHeight =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
|
child->getResolvedDimension(YGDimensionHeight), ownerHeight)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
childHeightMeasureMode = MeasureMode::Exactly;
|
childHeightMeasureMode = MeasureMode::Exactly;
|
||||||
@@ -309,7 +309,7 @@ static void computeFlexBasisForChild(
|
|||||||
generationCount);
|
generationCount);
|
||||||
|
|
||||||
child->setLayoutComputedFlexBasis(FloatOptional(yoga::maxOrDefined(
|
child->setLayoutComputedFlexBasis(FloatOptional(yoga::maxOrDefined(
|
||||||
child->getLayout().measuredDimensions[dimension(mainAxis)],
|
child->getLayout().measuredDimension(dimension(mainAxis)),
|
||||||
paddingAndBorderForAxis(child, mainAxis, ownerWidth))));
|
paddingAndBorderForAxis(child, mainAxis, ownerWidth))));
|
||||||
}
|
}
|
||||||
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
||||||
@@ -340,16 +340,16 @@ static void layoutAbsoluteChild(
|
|||||||
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
||||||
|
|
||||||
if (styleDefinesDimension(child, FlexDirection::Row, width)) {
|
if (styleDefinesDimension(child, FlexDirection::Row, width)) {
|
||||||
childWidth = yoga::resolveValue(
|
childWidth =
|
||||||
child->getResolvedDimensions()[YGDimensionWidth], width)
|
yoga::resolveValue(child->getResolvedDimension(YGDimensionWidth), width)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified width, compute the width based on
|
// If the child doesn't have a specified width, compute the width based on
|
||||||
// the left/right offsets if they're defined.
|
// the left/right offsets if they're defined.
|
||||||
if (child->isLeadingPositionDefined(FlexDirection::Row) &&
|
if (child->isLeadingPositionDefined(FlexDirection::Row) &&
|
||||||
child->isTrailingPosDefined(FlexDirection::Row)) {
|
child->isTrailingPosDefined(FlexDirection::Row)) {
|
||||||
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
childWidth = node->getLayout().measuredDimension(YGDimensionWidth) -
|
||||||
(node->getLeadingBorder(FlexDirection::Row) +
|
(node->getLeadingBorder(FlexDirection::Row) +
|
||||||
node->getTrailingBorder(FlexDirection::Row)) -
|
node->getTrailingBorder(FlexDirection::Row)) -
|
||||||
(child->getLeadingPosition(FlexDirection::Row, width) +
|
(child->getLeadingPosition(FlexDirection::Row, width) +
|
||||||
@@ -362,7 +362,7 @@ static void layoutAbsoluteChild(
|
|||||||
|
|
||||||
if (styleDefinesDimension(child, FlexDirection::Column, height)) {
|
if (styleDefinesDimension(child, FlexDirection::Column, height)) {
|
||||||
childHeight = yoga::resolveValue(
|
childHeight = yoga::resolveValue(
|
||||||
child->getResolvedDimensions()[YGDimensionHeight], height)
|
child->getResolvedDimension(YGDimensionHeight), height)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
} else {
|
} else {
|
||||||
@@ -370,7 +370,7 @@ static void layoutAbsoluteChild(
|
|||||||
// the top/bottom offsets if they're defined.
|
// the top/bottom offsets if they're defined.
|
||||||
if (child->isLeadingPositionDefined(FlexDirection::Column) &&
|
if (child->isLeadingPositionDefined(FlexDirection::Column) &&
|
||||||
child->isTrailingPosDefined(FlexDirection::Column)) {
|
child->isTrailingPosDefined(FlexDirection::Column)) {
|
||||||
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
childHeight = node->getLayout().measuredDimension(YGDimensionHeight) -
|
||||||
(node->getLeadingBorder(FlexDirection::Column) +
|
(node->getLeadingBorder(FlexDirection::Column) +
|
||||||
node->getTrailingBorder(FlexDirection::Column)) -
|
node->getTrailingBorder(FlexDirection::Column)) -
|
||||||
(child->getLeadingPosition(FlexDirection::Column, height) +
|
(child->getLeadingPosition(FlexDirection::Column, height) +
|
||||||
@@ -431,9 +431,9 @@ static void layoutAbsoluteChild(
|
|||||||
layoutMarkerData,
|
layoutMarkerData,
|
||||||
depth,
|
depth,
|
||||||
generationCount);
|
generationCount);
|
||||||
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
childWidth = child->getLayout().measuredDimension(YGDimensionWidth) +
|
||||||
child->getMarginForAxis(FlexDirection::Row, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Row, width).unwrap();
|
||||||
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
childHeight = child->getLayout().measuredDimension(YGDimensionHeight) +
|
||||||
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
child->getMarginForAxis(FlexDirection::Column, width).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,8 +455,8 @@ static void layoutAbsoluteChild(
|
|||||||
if (child->isTrailingPosDefined(mainAxis) &&
|
if (child->isTrailingPosDefined(mainAxis) &&
|
||||||
!child->isLeadingPositionDefined(mainAxis)) {
|
!child->isLeadingPositionDefined(mainAxis)) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(mainAxis)] -
|
node->getLayout().measuredDimension(dimension(mainAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(mainAxis)] -
|
child->getLayout().measuredDimension(dimension(mainAxis)) -
|
||||||
node->getTrailingBorder(mainAxis) -
|
node->getTrailingBorder(mainAxis) -
|
||||||
child->getTrailingMargin(mainAxis, isMainAxisRow ? width : height)
|
child->getTrailingMargin(mainAxis, isMainAxisRow ? width : height)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
@@ -467,16 +467,16 @@ static void layoutAbsoluteChild(
|
|||||||
!child->isLeadingPositionDefined(mainAxis) &&
|
!child->isLeadingPositionDefined(mainAxis) &&
|
||||||
node->getStyle().justifyContent() == Justify::Center) {
|
node->getStyle().justifyContent() == Justify::Center) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(mainAxis)] -
|
(node->getLayout().measuredDimension(dimension(mainAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(mainAxis)]) /
|
child->getLayout().measuredDimension(dimension(mainAxis))) /
|
||||||
2.0f,
|
2.0f,
|
||||||
leadingEdge(mainAxis));
|
leadingEdge(mainAxis));
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(mainAxis) &&
|
!child->isLeadingPositionDefined(mainAxis) &&
|
||||||
node->getStyle().justifyContent() == Justify::FlexEnd) {
|
node->getStyle().justifyContent() == Justify::FlexEnd) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(mainAxis)] -
|
(node->getLayout().measuredDimension(dimension(mainAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(mainAxis)]),
|
child->getLayout().measuredDimension(dimension(mainAxis))),
|
||||||
leadingEdge(mainAxis));
|
leadingEdge(mainAxis));
|
||||||
} else if (
|
} else if (
|
||||||
node->getConfig()->isExperimentalFeatureEnabled(
|
node->getConfig()->isExperimentalFeatureEnabled(
|
||||||
@@ -485,13 +485,13 @@ static void layoutAbsoluteChild(
|
|||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(
|
child->getLeadingPosition(
|
||||||
mainAxis,
|
mainAxis,
|
||||||
node->getLayout().measuredDimensions[dimension(mainAxis)])
|
node->getLayout().measuredDimension(dimension(mainAxis)))
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
node->getLeadingBorder(mainAxis) +
|
node->getLeadingBorder(mainAxis) +
|
||||||
child
|
child
|
||||||
->getLeadingMargin(
|
->getLeadingMargin(
|
||||||
mainAxis,
|
mainAxis,
|
||||||
node->getLayout().measuredDimensions[dimension(mainAxis)])
|
node->getLayout().measuredDimension(dimension(mainAxis)))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
leadingEdge(mainAxis));
|
leadingEdge(mainAxis));
|
||||||
}
|
}
|
||||||
@@ -499,8 +499,8 @@ static void layoutAbsoluteChild(
|
|||||||
if (child->isTrailingPosDefined(crossAxis) &&
|
if (child->isTrailingPosDefined(crossAxis) &&
|
||||||
!child->isLeadingPositionDefined(crossAxis)) {
|
!child->isLeadingPositionDefined(crossAxis)) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
node->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)] -
|
child->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
node->getTrailingBorder(crossAxis) -
|
node->getTrailingBorder(crossAxis) -
|
||||||
child->getTrailingMargin(crossAxis, isMainAxisRow ? height : width)
|
child->getTrailingMargin(crossAxis, isMainAxisRow ? height : width)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
@@ -513,8 +513,8 @@ static void layoutAbsoluteChild(
|
|||||||
!child->isLeadingPositionDefined(crossAxis) &&
|
!child->isLeadingPositionDefined(crossAxis) &&
|
||||||
resolveChildAlignment(node, child) == Align::Center) {
|
resolveChildAlignment(node, child) == Align::Center) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
(node->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)]) /
|
child->getLayout().measuredDimension(dimension(crossAxis))) /
|
||||||
2.0f,
|
2.0f,
|
||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
} else if (
|
} else if (
|
||||||
@@ -522,8 +522,8 @@ static void layoutAbsoluteChild(
|
|||||||
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
|
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
|
||||||
(node->getStyle().flexWrap() == Wrap::WrapReverse))) {
|
(node->getStyle().flexWrap() == Wrap::WrapReverse))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
(node->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)]),
|
child->getLayout().measuredDimension(dimension(crossAxis))),
|
||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
} else if (
|
} else if (
|
||||||
node->getConfig()->isExperimentalFeatureEnabled(
|
node->getConfig()->isExperimentalFeatureEnabled(
|
||||||
@@ -532,13 +532,13 @@ static void layoutAbsoluteChild(
|
|||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(
|
child->getLeadingPosition(
|
||||||
crossAxis,
|
crossAxis,
|
||||||
node->getLayout().measuredDimensions[dimension(crossAxis)])
|
node->getLayout().measuredDimension(dimension(crossAxis)))
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
node->getLeadingBorder(crossAxis) +
|
node->getLeadingBorder(crossAxis) +
|
||||||
child
|
child
|
||||||
->getLeadingMargin(
|
->getLeadingMargin(
|
||||||
crossAxis,
|
crossAxis,
|
||||||
node->getLayout().measuredDimensions[dimension(crossAxis)])
|
node->getLayout().measuredDimension(dimension(crossAxis)))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
}
|
}
|
||||||
@@ -746,14 +746,14 @@ static float calculateAvailableInnerDimension(
|
|||||||
if (!yoga::isUndefined(availableInnerDim)) {
|
if (!yoga::isUndefined(availableInnerDim)) {
|
||||||
// We want to make sure our available height does not violate min and max
|
// We want to make sure our available height does not violate min and max
|
||||||
// constraints
|
// constraints
|
||||||
const FloatOptional minDimensionOptional = yoga::resolveValue(
|
const FloatOptional minDimensionOptional =
|
||||||
node->getStyle().minDimensions()[dimension], ownerDim);
|
yoga::resolveValue(node->getStyle().minDimension(dimension), ownerDim);
|
||||||
const float minInnerDim = minDimensionOptional.isUndefined()
|
const float minInnerDim = minDimensionOptional.isUndefined()
|
||||||
? 0.0f
|
? 0.0f
|
||||||
: minDimensionOptional.unwrap() - paddingAndBorder;
|
: minDimensionOptional.unwrap() - paddingAndBorder;
|
||||||
|
|
||||||
const FloatOptional maxDimensionOptional = yoga::resolveValue(
|
const FloatOptional maxDimensionOptional =
|
||||||
node->getStyle().maxDimensions()[dimension], ownerDim);
|
yoga::resolveValue(node->getStyle().maxDimension(dimension), ownerDim);
|
||||||
|
|
||||||
const float maxInnerDim = maxDimensionOptional.isUndefined()
|
const float maxInnerDim = maxDimensionOptional.isUndefined()
|
||||||
? FLT_MAX
|
? FLT_MAX
|
||||||
@@ -1220,9 +1220,9 @@ static void justifyMainAxis(
|
|||||||
// remainingFreeSpace is 0 when min main dimension is not given
|
// remainingFreeSpace is 0 when min main dimension is not given
|
||||||
if (measureModeMainDim == MeasureMode::AtMost &&
|
if (measureModeMainDim == MeasureMode::AtMost &&
|
||||||
flexLine.layout.remainingFreeSpace > 0) {
|
flexLine.layout.remainingFreeSpace > 0) {
|
||||||
if (!style.minDimensions()[dimension(mainAxis)].isUndefined() &&
|
if (!style.minDimension(dimension(mainAxis)).isUndefined() &&
|
||||||
!yoga::resolveValue(
|
!yoga::resolveValue(
|
||||||
style.minDimensions()[dimension(mainAxis)], mainAxisownerSize)
|
style.minDimension(dimension(mainAxis)), mainAxisownerSize)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
// This condition makes sure that if the size of main dimension(after
|
// This condition makes sure that if the size of main dimension(after
|
||||||
// considering child nodes main dim, leading and trailing padding etc)
|
// considering child nodes main dim, leading and trailing padding etc)
|
||||||
@@ -1233,7 +1233,7 @@ static void justifyMainAxis(
|
|||||||
// can be laid out, it will exclude space consumed by padding and border.
|
// can be laid out, it will exclude space consumed by padding and border.
|
||||||
const float minAvailableMainDim =
|
const float minAvailableMainDim =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
style.minDimensions()[dimension(mainAxis)], mainAxisownerSize)
|
style.minDimension(dimension(mainAxis)), mainAxisownerSize)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
|
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
|
||||||
const float occupiedSpaceByChildNodes =
|
const float occupiedSpaceByChildNodes =
|
||||||
@@ -1373,7 +1373,7 @@ static void justifyMainAxis(
|
|||||||
FlexDirection::Column, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimension(YGDimensionHeight) +
|
||||||
child
|
child
|
||||||
->getMarginForAxis(
|
->getMarginForAxis(
|
||||||
FlexDirection::Column, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
@@ -1723,22 +1723,21 @@ static void calculateLayoutImpl(
|
|||||||
// If we don't measure with exact main dimension we want to ensure we don't
|
// If we don't measure with exact main dimension we want to ensure we don't
|
||||||
// violate min and max
|
// violate min and max
|
||||||
if (measureModeMainDim != MeasureMode::Exactly) {
|
if (measureModeMainDim != MeasureMode::Exactly) {
|
||||||
const auto& minDimensions = node->getStyle().minDimensions();
|
const auto& style = node->getStyle();
|
||||||
const auto& maxDimensions = node->getStyle().maxDimensions();
|
|
||||||
const float minInnerWidth =
|
const float minInnerWidth =
|
||||||
yoga::resolveValue(minDimensions[YGDimensionWidth], ownerWidth)
|
yoga::resolveValue(style.minDimension(YGDimensionWidth), ownerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float maxInnerWidth =
|
const float maxInnerWidth =
|
||||||
yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
yoga::resolveValue(style.maxDimension(YGDimensionWidth), ownerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float minInnerHeight =
|
const float minInnerHeight =
|
||||||
yoga::resolveValue(minDimensions[YGDimensionHeight], ownerHeight)
|
yoga::resolveValue(style.minDimension(YGDimensionHeight), ownerHeight)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
const float maxInnerHeight =
|
const float maxInnerHeight =
|
||||||
yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
yoga::resolveValue(style.maxDimension(YGDimensionHeight), ownerHeight)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
|
|
||||||
@@ -1911,7 +1910,7 @@ static void calculateLayoutImpl(
|
|||||||
if (!styleDefinesDimension(
|
if (!styleDefinesDimension(
|
||||||
child, crossAxis, availableInnerCrossDim)) {
|
child, crossAxis, availableInnerCrossDim)) {
|
||||||
float childMainSize =
|
float childMainSize =
|
||||||
child->getLayout().measuredDimensions[dimension(mainAxis)];
|
child->getLayout().measuredDimension(dimension(mainAxis));
|
||||||
const auto& childStyle = child->getStyle();
|
const auto& childStyle = child->getStyle();
|
||||||
float childCrossSize = !childStyle.aspectRatio().isUndefined()
|
float childCrossSize = !childStyle.aspectRatio().isUndefined()
|
||||||
? child->getMarginForAxis(crossAxis, availableInnerWidth)
|
? child->getMarginForAxis(crossAxis, availableInnerWidth)
|
||||||
@@ -2079,7 +2078,7 @@ static void calculateLayoutImpl(
|
|||||||
if (isLayoutDimensionDefined(child, crossAxis)) {
|
if (isLayoutDimensionDefined(child, crossAxis)) {
|
||||||
lineHeight = yoga::maxOrDefined(
|
lineHeight = yoga::maxOrDefined(
|
||||||
lineHeight,
|
lineHeight,
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)] +
|
child->getLayout().measuredDimension(dimension(crossAxis)) +
|
||||||
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
||||||
.unwrap());
|
.unwrap());
|
||||||
}
|
}
|
||||||
@@ -2090,7 +2089,7 @@ static void calculateLayoutImpl(
|
|||||||
FlexDirection::Column, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimension(YGDimensionHeight) +
|
||||||
child
|
child
|
||||||
->getMarginForAxis(
|
->getMarginForAxis(
|
||||||
FlexDirection::Column, availableInnerWidth)
|
FlexDirection::Column, availableInnerWidth)
|
||||||
@@ -2130,14 +2129,14 @@ static void calculateLayoutImpl(
|
|||||||
currentLead + lineHeight -
|
currentLead + lineHeight -
|
||||||
child->getTrailingMargin(crossAxis, availableInnerWidth)
|
child->getTrailingMargin(crossAxis, availableInnerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
child->getLayout()
|
child->getLayout().measuredDimension(
|
||||||
.measuredDimensions[dimension(crossAxis)],
|
dimension(crossAxis)),
|
||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Align::Center: {
|
case Align::Center: {
|
||||||
float childHeight =
|
float childHeight =
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)];
|
child->getLayout().measuredDimension(dimension(crossAxis));
|
||||||
|
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead + (lineHeight - childHeight) / 2,
|
currentLead + (lineHeight - childHeight) / 2,
|
||||||
@@ -2156,27 +2155,27 @@ static void calculateLayoutImpl(
|
|||||||
if (!styleDefinesDimension(
|
if (!styleDefinesDimension(
|
||||||
child, crossAxis, availableInnerCrossDim)) {
|
child, crossAxis, availableInnerCrossDim)) {
|
||||||
const float childWidth = isMainAxisRow
|
const float childWidth = isMainAxisRow
|
||||||
? (child->getLayout()
|
? (child->getLayout().measuredDimension(
|
||||||
.measuredDimensions[YGDimensionWidth] +
|
YGDimensionWidth) +
|
||||||
child->getMarginForAxis(mainAxis, availableInnerWidth)
|
child->getMarginForAxis(mainAxis, availableInnerWidth)
|
||||||
.unwrap())
|
.unwrap())
|
||||||
: lineHeight;
|
: lineHeight;
|
||||||
|
|
||||||
const float childHeight = !isMainAxisRow
|
const float childHeight = !isMainAxisRow
|
||||||
? (child->getLayout()
|
? (child->getLayout().measuredDimension(
|
||||||
.measuredDimensions[YGDimensionHeight] +
|
YGDimensionHeight) +
|
||||||
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
child->getMarginForAxis(crossAxis, availableInnerWidth)
|
||||||
.unwrap())
|
.unwrap())
|
||||||
: lineHeight;
|
: lineHeight;
|
||||||
|
|
||||||
if (!(yoga::inexactEquals(
|
if (!(yoga::inexactEquals(
|
||||||
childWidth,
|
childWidth,
|
||||||
child->getLayout()
|
child->getLayout().measuredDimension(
|
||||||
.measuredDimensions[YGDimensionWidth]) &&
|
YGDimensionWidth)) &&
|
||||||
yoga::inexactEquals(
|
yoga::inexactEquals(
|
||||||
childHeight,
|
childHeight,
|
||||||
child->getLayout()
|
child->getLayout().measuredDimension(
|
||||||
.measuredDimensions[YGDimensionHeight]))) {
|
YGDimensionHeight)))) {
|
||||||
calculateLayoutInternal(
|
calculateLayoutInternal(
|
||||||
child,
|
child,
|
||||||
childWidth,
|
childWidth,
|
||||||
@@ -2307,9 +2306,9 @@ static void calculateLayoutImpl(
|
|||||||
const auto child = node->getChild(i);
|
const auto child = node->getChild(i);
|
||||||
if (child->getStyle().positionType() != PositionType::Absolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
node->getLayout().measuredDimension(dimension(crossAxis)) -
|
||||||
child->getLayout().position[leadingEdge(crossAxis)] -
|
child->getLayout().position[leadingEdge(crossAxis)] -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)],
|
child->getLayout().measuredDimension(dimension(crossAxis)),
|
||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2330,11 +2329,11 @@ static void calculateLayoutImpl(
|
|||||||
node,
|
node,
|
||||||
child,
|
child,
|
||||||
absolutePercentageAgainstPaddingEdge
|
absolutePercentageAgainstPaddingEdge
|
||||||
? node->getLayout().measuredDimensions[YGDimensionWidth]
|
? node->getLayout().measuredDimension(YGDimensionWidth)
|
||||||
: availableInnerWidth,
|
: availableInnerWidth,
|
||||||
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
||||||
absolutePercentageAgainstPaddingEdge
|
absolutePercentageAgainstPaddingEdge
|
||||||
? node->getLayout().measuredDimensions[YGDimensionHeight]
|
? node->getLayout().measuredDimension(YGDimensionHeight)
|
||||||
: availableInnerHeight,
|
: availableInnerHeight,
|
||||||
direction,
|
direction,
|
||||||
layoutMarkerData,
|
layoutMarkerData,
|
||||||
@@ -2516,9 +2515,10 @@ bool calculateLayoutInternal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!needToVisitNode && cachedResults != nullptr) {
|
if (!needToVisitNode && cachedResults != nullptr) {
|
||||||
layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth;
|
layout->setMeasuredDimension(
|
||||||
layout->measuredDimensions[YGDimensionHeight] =
|
YGDimensionWidth, cachedResults->computedWidth);
|
||||||
cachedResults->computedHeight;
|
layout->setMeasuredDimension(
|
||||||
|
YGDimensionHeight, cachedResults->computedHeight);
|
||||||
|
|
||||||
(performLayout ? layoutMarkerData.cachedLayouts
|
(performLayout ? layoutMarkerData.cachedLayouts
|
||||||
: layoutMarkerData.cachedMeasures) += 1;
|
: layoutMarkerData.cachedMeasures) += 1;
|
||||||
@@ -2594,8 +2594,8 @@ bool calculateLayoutInternal(
|
|||||||
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
layout->measuredDimensions[YGDimensionWidth],
|
layout->measuredDimension(YGDimensionWidth),
|
||||||
layout->measuredDimensions[YGDimensionHeight],
|
layout->measuredDimension(YGDimensionHeight),
|
||||||
LayoutPassReasonToString(reason));
|
LayoutPassReasonToString(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2630,18 +2630,18 @@ bool calculateLayoutInternal(
|
|||||||
newCacheEntry->widthMeasureMode = widthMeasureMode;
|
newCacheEntry->widthMeasureMode = widthMeasureMode;
|
||||||
newCacheEntry->heightMeasureMode = heightMeasureMode;
|
newCacheEntry->heightMeasureMode = heightMeasureMode;
|
||||||
newCacheEntry->computedWidth =
|
newCacheEntry->computedWidth =
|
||||||
layout->measuredDimensions[YGDimensionWidth];
|
layout->measuredDimension(YGDimensionWidth);
|
||||||
newCacheEntry->computedHeight =
|
newCacheEntry->computedHeight =
|
||||||
layout->measuredDimensions[YGDimensionHeight];
|
layout->measuredDimension(YGDimensionHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
node->setLayoutDimension(
|
node->setLayoutDimension(
|
||||||
node->getLayout().measuredDimensions[YGDimensionWidth],
|
node->getLayout().measuredDimension(YGDimensionWidth),
|
||||||
YGDimensionWidth);
|
YGDimensionWidth);
|
||||||
node->setLayoutDimension(
|
node->setLayoutDimension(
|
||||||
node->getLayout().measuredDimensions[YGDimensionHeight],
|
node->getLayout().measuredDimension(YGDimensionHeight),
|
||||||
YGDimensionHeight);
|
YGDimensionHeight);
|
||||||
|
|
||||||
node->setHasNewLayout(true);
|
node->setHasNewLayout(true);
|
||||||
@@ -2679,7 +2679,7 @@ void calculateLayout(
|
|||||||
node->resolveDimension();
|
node->resolveDimension();
|
||||||
float width = YGUndefined;
|
float width = YGUndefined;
|
||||||
MeasureMode widthMeasureMode = MeasureMode::Undefined;
|
MeasureMode widthMeasureMode = MeasureMode::Undefined;
|
||||||
const auto& maxDimensions = node->getStyle().maxDimensions();
|
const auto& style = node->getStyle();
|
||||||
if (styleDefinesDimension(node, FlexDirection::Row, ownerWidth)) {
|
if (styleDefinesDimension(node, FlexDirection::Row, ownerWidth)) {
|
||||||
width = (yoga::resolveValue(
|
width = (yoga::resolveValue(
|
||||||
node->getResolvedDimension(dimension(FlexDirection::Row)),
|
node->getResolvedDimension(dimension(FlexDirection::Row)),
|
||||||
@@ -2687,9 +2687,10 @@ void calculateLayout(
|
|||||||
node->getMarginForAxis(FlexDirection::Row, ownerWidth))
|
node->getMarginForAxis(FlexDirection::Row, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = MeasureMode::Exactly;
|
widthMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
} else if (!yoga::resolveValue(
|
||||||
|
style.maxDimension(YGDimensionWidth), ownerWidth)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
width = yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
width = yoga::resolveValue(style.maxDimension(YGDimensionWidth), ownerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = MeasureMode::AtMost;
|
widthMeasureMode = MeasureMode::AtMost;
|
||||||
} else {
|
} else {
|
||||||
@@ -2707,10 +2708,12 @@ void calculateLayout(
|
|||||||
node->getMarginForAxis(FlexDirection::Column, ownerWidth))
|
node->getMarginForAxis(FlexDirection::Column, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = MeasureMode::Exactly;
|
heightMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
} else if (!yoga::resolveValue(
|
||||||
|
style.maxDimension(YGDimensionHeight), ownerHeight)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
height = yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
height =
|
||||||
.unwrap();
|
yoga::resolveValue(style.maxDimension(YGDimensionHeight), ownerHeight)
|
||||||
|
.unwrap();
|
||||||
heightMeasureMode = MeasureMode::AtMost;
|
heightMeasureMode = MeasureMode::AtMost;
|
||||||
} else {
|
} else {
|
||||||
height = ownerHeight;
|
height = ownerHeight;
|
||||||
|
@@ -71,8 +71,8 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
const double nodeLeft = node->getLayout().position[YGEdgeLeft];
|
const double nodeLeft = node->getLayout().position[YGEdgeLeft];
|
||||||
const double nodeTop = node->getLayout().position[YGEdgeTop];
|
const double nodeTop = node->getLayout().position[YGEdgeTop];
|
||||||
|
|
||||||
const double nodeWidth = node->getLayout().dimensions[YGDimensionWidth];
|
const double nodeWidth = node->getLayout().dimension(YGDimensionWidth);
|
||||||
const double nodeHeight = node->getLayout().dimensions[YGDimensionHeight];
|
const double nodeHeight = node->getLayout().dimension(YGDimensionHeight);
|
||||||
|
|
||||||
const double absoluteNodeLeft = absoluteLeft + nodeLeft;
|
const double absoluteNodeLeft = absoluteLeft + nodeLeft;
|
||||||
const double absoluteNodeTop = absoluteTop + nodeTop;
|
const double absoluteNodeTop = absoluteTop + nodeTop;
|
||||||
|
@@ -127,9 +127,9 @@ void nodeToString(
|
|||||||
if ((options & PrintOptions::Layout) == PrintOptions::Layout) {
|
if ((options & PrintOptions::Layout) == PrintOptions::Layout) {
|
||||||
appendFormattedString(str, "layout=\"");
|
appendFormattedString(str, "layout=\"");
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "width: %g; ", node->getLayout().dimensions[YGDimensionWidth]);
|
str, "width: %g; ", node->getLayout().dimension(YGDimensionWidth));
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "height: %g; ", node->getLayout().dimensions[YGDimensionHeight]);
|
str, "height: %g; ", node->getLayout().dimension(YGDimensionHeight));
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "top: %g; ", node->getLayout().position[YGEdgeTop]);
|
str, "top: %g; ", node->getLayout().position[YGEdgeTop]);
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
@@ -193,16 +193,16 @@ void nodeToString(
|
|||||||
appendNumberIfNotUndefined(str, "row-gap", style.gap()[YGGutterRow]);
|
appendNumberIfNotUndefined(str, "row-gap", style.gap()[YGGutterRow]);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendNumberIfNotAuto(str, "width", style.dimensions()[YGDimensionWidth]);
|
appendNumberIfNotAuto(str, "width", style.dimension(YGDimensionWidth));
|
||||||
appendNumberIfNotAuto(str, "height", style.dimensions()[YGDimensionHeight]);
|
appendNumberIfNotAuto(str, "height", style.dimension(YGDimensionHeight));
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "max-width", style.maxDimensions()[YGDimensionWidth]);
|
str, "max-width", style.maxDimension(YGDimensionWidth));
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "max-height", style.maxDimensions()[YGDimensionHeight]);
|
str, "max-height", style.maxDimension(YGDimensionHeight));
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "min-width", style.minDimensions()[YGDimensionWidth]);
|
str, "min-width", style.minDimension(YGDimensionWidth));
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "min-height", style.minDimensions()[YGDimensionHeight]);
|
str, "min-height", style.minDimension(YGDimensionHeight));
|
||||||
|
|
||||||
if (style.positionType() != yoga::Node{}.getStyle().positionType()) {
|
if (style.positionType() != yoga::Node{}.getStyle().positionType()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
|
@@ -14,7 +14,7 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
bool LayoutResults::operator==(LayoutResults layout) const {
|
bool LayoutResults::operator==(LayoutResults layout) const {
|
||||||
bool isEqual = yoga::inexactEquals(position, layout.position) &&
|
bool isEqual = yoga::inexactEquals(position, layout.position) &&
|
||||||
yoga::inexactEquals(dimensions, layout.dimensions) &&
|
yoga::inexactEquals(dimensions_, layout.dimensions_) &&
|
||||||
yoga::inexactEquals(margin, layout.margin) &&
|
yoga::inexactEquals(margin, layout.margin) &&
|
||||||
yoga::inexactEquals(border, layout.border) &&
|
yoga::inexactEquals(border, layout.border) &&
|
||||||
yoga::inexactEquals(padding, layout.padding) &&
|
yoga::inexactEquals(padding, layout.padding) &&
|
||||||
@@ -30,15 +30,15 @@ bool LayoutResults::operator==(LayoutResults layout) const {
|
|||||||
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!yoga::isUndefined(measuredDimensions[0]) ||
|
if (!yoga::isUndefined(measuredDimensions_[0]) ||
|
||||||
!yoga::isUndefined(layout.measuredDimensions[0])) {
|
!yoga::isUndefined(layout.measuredDimensions_[0])) {
|
||||||
isEqual =
|
isEqual =
|
||||||
isEqual && (measuredDimensions[0] == layout.measuredDimensions[0]);
|
isEqual && (measuredDimensions_[0] == layout.measuredDimensions_[0]);
|
||||||
}
|
}
|
||||||
if (!yoga::isUndefined(measuredDimensions[1]) ||
|
if (!yoga::isUndefined(measuredDimensions_[1]) ||
|
||||||
!yoga::isUndefined(layout.measuredDimensions[1])) {
|
!yoga::isUndefined(layout.measuredDimensions_[1])) {
|
||||||
isEqual =
|
isEqual =
|
||||||
isEqual && (measuredDimensions[1] == layout.measuredDimensions[1]);
|
isEqual && (measuredDimensions_[1] == layout.measuredDimensions_[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isEqual;
|
return isEqual;
|
||||||
|
@@ -22,7 +22,6 @@ struct LayoutResults {
|
|||||||
static constexpr int32_t MaxCachedMeasurements = 8;
|
static constexpr int32_t MaxCachedMeasurements = 8;
|
||||||
|
|
||||||
std::array<float, 4> position = {};
|
std::array<float, 4> position = {};
|
||||||
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}};
|
|
||||||
std::array<float, 4> margin = {};
|
std::array<float, 4> margin = {};
|
||||||
std::array<float, 4> border = {};
|
std::array<float, 4> border = {};
|
||||||
std::array<float, 4> padding = {};
|
std::array<float, 4> padding = {};
|
||||||
@@ -31,6 +30,9 @@ struct LayoutResults {
|
|||||||
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
||||||
bool hadOverflow_ : 1 = false;
|
bool hadOverflow_ : 1 = false;
|
||||||
|
|
||||||
|
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
|
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t computedFlexBasisGeneration = 0;
|
uint32_t computedFlexBasisGeneration = 0;
|
||||||
FloatOptional computedFlexBasis = {};
|
FloatOptional computedFlexBasis = {};
|
||||||
@@ -42,7 +44,6 @@ struct LayoutResults {
|
|||||||
|
|
||||||
uint32_t nextCachedMeasurementsIndex = 0;
|
uint32_t nextCachedMeasurementsIndex = 0;
|
||||||
std::array<CachedMeasurement, MaxCachedMeasurements> cachedMeasurements = {};
|
std::array<CachedMeasurement, MaxCachedMeasurements> cachedMeasurements = {};
|
||||||
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
|
|
||||||
|
|
||||||
CachedMeasurement cachedLayout{};
|
CachedMeasurement cachedLayout{};
|
||||||
|
|
||||||
@@ -57,10 +58,27 @@ struct LayoutResults {
|
|||||||
bool hadOverflow() const {
|
bool hadOverflow() const {
|
||||||
return hadOverflow_;
|
return hadOverflow_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHadOverflow(bool hadOverflow) {
|
void setHadOverflow(bool hadOverflow) {
|
||||||
hadOverflow_ = hadOverflow;
|
hadOverflow_ = hadOverflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float dimension(YGDimension axis) const {
|
||||||
|
return dimensions_[axis];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDimension(YGDimension axis, float dimension) {
|
||||||
|
dimensions_[axis] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
float measuredDimension(YGDimension axis) const {
|
||||||
|
return measuredDimensions_[axis];
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMeasuredDimension(YGDimension axis, float dimension) {
|
||||||
|
measuredDimensions_[axis] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(LayoutResults layout) const;
|
bool operator==(LayoutResults layout) const;
|
||||||
bool operator!=(LayoutResults layout) const {
|
bool operator!=(LayoutResults layout) const {
|
||||||
return !(*this == layout);
|
return !(*this == layout);
|
||||||
|
@@ -340,8 +340,7 @@ void Node::setLayoutComputedFlexBasisGeneration(
|
|||||||
void Node::setLayoutMeasuredDimension(
|
void Node::setLayoutMeasuredDimension(
|
||||||
float measuredDimension,
|
float measuredDimension,
|
||||||
YGDimension dimension) {
|
YGDimension dimension) {
|
||||||
layout_.measuredDimensions[static_cast<size_t>(dimension)] =
|
layout_.setMeasuredDimension(dimension, measuredDimension);
|
||||||
measuredDimension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutHadOverflow(bool hadOverflow) {
|
void Node::setLayoutHadOverflow(bool hadOverflow) {
|
||||||
@@ -349,7 +348,7 @@ void Node::setLayoutHadOverflow(bool hadOverflow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutDimension(float dimensionValue, YGDimension dimension) {
|
void Node::setLayoutDimension(float dimensionValue, YGDimension dimension) {
|
||||||
layout_.dimensions[static_cast<size_t>(dimension)] = dimensionValue;
|
layout_.setDimension(dimension, dimensionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both left and right are defined, then use left. Otherwise return +left or
|
// If both left and right are defined, then use left. Otherwise return +left or
|
||||||
@@ -437,12 +436,11 @@ void Node::resolveDimension() {
|
|||||||
using namespace yoga;
|
using namespace yoga;
|
||||||
const Style& style = getStyle();
|
const Style& style = getStyle();
|
||||||
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
|
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
|
||||||
if (!style.maxDimensions()[dim].isUndefined() &&
|
if (!style.maxDimension(dim).isUndefined() &&
|
||||||
yoga::inexactEquals(
|
yoga::inexactEquals(style.maxDimension(dim), style.minDimension(dim))) {
|
||||||
style.maxDimensions()[dim], style.minDimensions()[dim])) {
|
resolvedDimensions_[dim] = style.maxDimension(dim);
|
||||||
resolvedDimensions_[dim] = style.maxDimensions()[dim];
|
|
||||||
} else {
|
} else {
|
||||||
resolvedDimensions_[dim] = style.dimensions()[dim];
|
resolvedDimensions_[dim] = style.dimension(dim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/CompactValue.h>
|
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
@@ -61,6 +60,10 @@ inline bool inexactEquals(const double a, const double b) {
|
|||||||
return yoga::isUndefined(a) && yoga::isUndefined(b);
|
return yoga::isUndefined(a) && yoga::isUndefined(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool inexactEquals(const FloatOptional a, const FloatOptional b) {
|
||||||
|
return inexactEquals(a.unwrap(), b.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
inline bool inexactEquals(const YGValue& a, const YGValue& b) {
|
inline bool inexactEquals(const YGValue& a, const YGValue& b) {
|
||||||
if (a.unit != b.unit) {
|
if (a.unit != b.unit) {
|
||||||
return false;
|
return false;
|
||||||
@@ -74,10 +77,6 @@ inline bool inexactEquals(const YGValue& a, const YGValue& b) {
|
|||||||
return fabs(a.value - b.value) < 0.0001f;
|
return fabs(a.value - b.value) < 0.0001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool inexactEquals(CompactValue a, CompactValue b) {
|
|
||||||
return inexactEquals((YGValue)a, (YGValue)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <std::size_t Size, typename ElementT>
|
template <std::size_t Size, typename ElementT>
|
||||||
bool inexactEquals(
|
bool inexactEquals(
|
||||||
const std::array<ElementT, Size>& val1,
|
const std::array<ElementT, Size>& val1,
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include <yoga/YGValue.h>
|
#include <yoga/YGValue.h>
|
||||||
|
|
||||||
#include <yoga/bits/BitCast.h>
|
#include <yoga/bits/BitCast.h>
|
||||||
|
#include <yoga/numeric/Comparison.h>
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::numeric_limits<float>::is_iec559,
|
std::numeric_limits<float>::is_iec559,
|
||||||
@@ -176,4 +177,8 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept {
|
|||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool inexactEquals(CompactValue a, CompactValue b) {
|
||||||
|
return inexactEquals((YGValue)a, (YGValue)b);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <yoga/numeric/Comparison.h>
|
|
||||||
#include <yoga/style/Style.h>
|
|
||||||
|
|
||||||
namespace facebook::yoga {
|
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
|
||||||
bool operator==(const Style& lhs, const Style& rhs) {
|
|
||||||
bool areNonFloatValuesEqual = lhs.direction() == rhs.direction() &&
|
|
||||||
lhs.flexDirection() == rhs.flexDirection() &&
|
|
||||||
lhs.justifyContent() == rhs.justifyContent() &&
|
|
||||||
lhs.alignContent() == rhs.alignContent() &&
|
|
||||||
lhs.alignItems() == rhs.alignItems() &&
|
|
||||||
lhs.alignSelf() == rhs.alignSelf() &&
|
|
||||||
lhs.positionType() == rhs.positionType() &&
|
|
||||||
lhs.flexWrap() == rhs.flexWrap() && lhs.overflow() == rhs.overflow() &&
|
|
||||||
lhs.display() == rhs.display() &&
|
|
||||||
yoga::inexactEquals(lhs.flexBasis(), rhs.flexBasis()) &&
|
|
||||||
lhs.margin() == rhs.margin() && lhs.position() == rhs.position() &&
|
|
||||||
lhs.padding() == rhs.padding() && lhs.border() == rhs.border() &&
|
|
||||||
lhs.gap() == rhs.gap() && lhs.dimensions() == rhs.dimensions() &&
|
|
||||||
lhs.minDimensions() == rhs.minDimensions() &&
|
|
||||||
lhs.maxDimensions() == rhs.maxDimensions();
|
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
|
||||||
lhs.flex().isUndefined() == rhs.flex().isUndefined();
|
|
||||||
if (areNonFloatValuesEqual && !lhs.flex().isUndefined() &&
|
|
||||||
!rhs.flex().isUndefined()) {
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex() == rhs.flex();
|
|
||||||
}
|
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
|
||||||
lhs.flexGrow().isUndefined() == rhs.flexGrow().isUndefined();
|
|
||||||
if (areNonFloatValuesEqual && !lhs.flexGrow().isUndefined()) {
|
|
||||||
areNonFloatValuesEqual =
|
|
||||||
areNonFloatValuesEqual && lhs.flexGrow() == rhs.flexGrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
|
||||||
lhs.flexShrink().isUndefined() == rhs.flexShrink().isUndefined();
|
|
||||||
if (areNonFloatValuesEqual && !rhs.flexShrink().isUndefined()) {
|
|
||||||
areNonFloatValuesEqual =
|
|
||||||
areNonFloatValuesEqual && lhs.flexShrink() == rhs.flexShrink();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(lhs.aspectRatio().isUndefined() && rhs.aspectRatio().isUndefined())) {
|
|
||||||
areNonFloatValuesEqual =
|
|
||||||
areNonFloatValuesEqual && lhs.aspectRatio() == rhs.aspectRatio();
|
|
||||||
}
|
|
||||||
|
|
||||||
return areNonFloatValuesEqual;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
|
@@ -280,25 +280,25 @@ class YG_EXPORT Style {
|
|||||||
return {*this};
|
return {*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dimensions& dimensions() const {
|
CompactValue dimension(YGDimension axis) const {
|
||||||
return dimensions_;
|
return dimensions_[axis];
|
||||||
}
|
}
|
||||||
IdxRef<YGDimension, &Style::dimensions_> dimensions() {
|
void setDimension(YGDimension axis, CompactValue value) {
|
||||||
return {*this};
|
dimensions_[axis] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dimensions& minDimensions() const {
|
CompactValue minDimension(YGDimension axis) const {
|
||||||
return minDimensions_;
|
return minDimensions_[axis];
|
||||||
}
|
}
|
||||||
IdxRef<YGDimension, &Style::minDimensions_> minDimensions() {
|
void setMinDimension(YGDimension axis, CompactValue value) {
|
||||||
return {*this};
|
minDimensions_[axis] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dimensions& maxDimensions() const {
|
CompactValue maxDimension(YGDimension axis) const {
|
||||||
return maxDimensions_;
|
return maxDimensions_[axis];
|
||||||
}
|
}
|
||||||
IdxRef<YGDimension, &Style::maxDimensions_> maxDimensions() {
|
void setMaxDimension(YGDimension axis, CompactValue value) {
|
||||||
return {*this};
|
maxDimensions_[axis] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
@@ -308,10 +308,26 @@ class YG_EXPORT Style {
|
|||||||
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() {
|
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() {
|
||||||
return {*this};
|
return {*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const Style& other) const {
|
||||||
|
return flags == other.flags && inexactEquals(flex_, other.flex_) &&
|
||||||
|
inexactEquals(flexGrow_, other.flexGrow_) &&
|
||||||
|
inexactEquals(flexShrink_, other.flexShrink_) &&
|
||||||
|
inexactEquals(flexBasis_, other.flexBasis_) &&
|
||||||
|
inexactEquals(margin_, other.margin_) &&
|
||||||
|
inexactEquals(position_, other.position_) &&
|
||||||
|
inexactEquals(padding_, other.padding_) &&
|
||||||
|
inexactEquals(border_, other.border_) &&
|
||||||
|
inexactEquals(gap_, other.gap_) &&
|
||||||
|
inexactEquals(dimensions_, other.dimensions_) &&
|
||||||
|
inexactEquals(minDimensions_, other.minDimensions_) &&
|
||||||
|
inexactEquals(maxDimensions_, other.maxDimensions_) &&
|
||||||
|
inexactEquals(aspectRatio_, other.aspectRatio_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Style& other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
YG_EXPORT bool operator==(const Style& lhs, const Style& rhs);
|
|
||||||
YG_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) {
|
|
||||||
return !(lhs == rhs);
|
|
||||||
}
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
Reference in New Issue
Block a user