New file for layout methods related to absolute children (#1495)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1495 X-link: https://github.com/facebook/react-native/pull/41794 This is a copy of D51369722 to make it so that it preserves the file history CalculateLayout.cpp is massive and approaching 3k lines. I added a few large functions dealing with layout of absolute nodes and was thinking it would be nice if that logic was just in its own file so it was more isolated and easier to reason about. So I made AbsoluteLayout.cpp and AbsoluteLayout.h to house this logic. In order for this to work I had to expose calculateLayoutInternal in CalculateLayout.h as layoutAbsoluteChild calls it. This is unideal and I would like to find a better way... I also make LayoutUtils.h to house misc small helper methods as they are called in AbsoluteLayout.cpp and CalculateLayout.cpp Reviewed By: NickGerleman Differential Revision: D51824115 fbshipit-source-id: 9b27449e3c1516492c01e6167a6b2c4568a33807
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7893c4bd85
commit
dde0fda9f5
@@ -404,6 +404,33 @@ float Node::baseline(float width, float height) const {
|
||||
return baselineFunc_(this, width, height);
|
||||
}
|
||||
|
||||
float Node::dimensionWithMargin(
|
||||
const FlexDirection axis,
|
||||
const float widthSize) {
|
||||
return getLayout().measuredDimension(dimension(axis)) +
|
||||
getMarginForAxis(axis, widthSize);
|
||||
}
|
||||
|
||||
bool Node::isLayoutDimensionDefined(const FlexDirection axis) {
|
||||
const float value = getLayout().measuredDimension(dimension(axis));
|
||||
return yoga::isDefined(value) && value >= 0.0f;
|
||||
}
|
||||
|
||||
bool Node::styleDefinesDimension(
|
||||
const FlexDirection axis,
|
||||
const float ownerSize) {
|
||||
bool isDefined = yoga::isDefined(getResolvedDimension(dimension(axis)).value);
|
||||
|
||||
auto resolvedDimension = getResolvedDimension(dimension(axis));
|
||||
return !(
|
||||
resolvedDimension.unit == YGUnitAuto ||
|
||||
resolvedDimension.unit == YGUnitUndefined ||
|
||||
(resolvedDimension.unit == YGUnitPoint && isDefined &&
|
||||
resolvedDimension.value < 0.0f) ||
|
||||
(resolvedDimension.unit == YGUnitPercent && isDefined &&
|
||||
(resolvedDimension.value < 0.0f || yoga::isUndefined(ownerSize))));
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
|
||||
|
Reference in New Issue
Block a user