Remove static-behaves-like-relative errata (#1556)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1556 X-link: https://github.com/facebook/react-native/pull/42315 Since we aim to ship static to all users of yoga (not just XPR), we need to remove the errata that is gating most of the features. This should be a non breaking change. To ensure that, I added a new errata which, if on, will use the inner size of the containing node as the containing block. This is how it has been for a while and resolving this is risky and time consuming so for the time being we will stick with that. Reviewed By: NickGerleman Differential Revision: D52706161 fbshipit-source-id: 30a93f29cb0d97b20b2947eaa21f36cdc78c4961
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f69a1a43e5
commit
06c26d7d46
@@ -462,7 +462,9 @@ void layoutAbsoluteDescendants(
|
||||
uint32_t currentDepth,
|
||||
uint32_t generationCount,
|
||||
float currentNodeMainOffsetFromContainingBlock,
|
||||
float currentNodeCrossOffsetFromContainingBlock) {
|
||||
float currentNodeCrossOffsetFromContainingBlock,
|
||||
float containingNodeAvailableInnerWidth,
|
||||
float containingNodeAvailableInnerHeight) {
|
||||
const FlexDirection mainAxis = resolveDirection(
|
||||
currentNode->getStyle().flexDirection(), currentNodeDirection);
|
||||
const FlexDirection crossAxis =
|
||||
@@ -471,14 +473,23 @@ void layoutAbsoluteDescendants(
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
continue;
|
||||
} else if (child->getStyle().positionType() == PositionType::Absolute) {
|
||||
const bool absoluteErrata =
|
||||
currentNode->hasErrata(Errata::AbsolutePercentAgainstInnerSize);
|
||||
const float containingBlockWidth = absoluteErrata
|
||||
? containingNodeAvailableInnerWidth
|
||||
: containingNode->getLayout().measuredDimension(Dimension::Width) -
|
||||
containingNode->getBorderForAxis(FlexDirection::Row);
|
||||
const float containingBlockHeight = absoluteErrata
|
||||
? containingNodeAvailableInnerHeight
|
||||
: containingNode->getLayout().measuredDimension(Dimension::Height) -
|
||||
containingNode->getBorderForAxis(FlexDirection::Column);
|
||||
|
||||
layoutAbsoluteChild(
|
||||
containingNode,
|
||||
currentNode,
|
||||
child,
|
||||
containingNode->getLayout().measuredDimension(Dimension::Width) -
|
||||
containingNode->getBorderForAxis(FlexDirection::Row),
|
||||
containingNode->getLayout().measuredDimension(Dimension::Height) -
|
||||
containingNode->getBorderForAxis(FlexDirection::Column),
|
||||
containingBlockWidth,
|
||||
containingBlockHeight,
|
||||
widthSizingMode,
|
||||
currentNodeDirection,
|
||||
layoutMarkerData,
|
||||
@@ -534,7 +545,9 @@ void layoutAbsoluteDescendants(
|
||||
currentDepth + 1,
|
||||
generationCount,
|
||||
childMainOffsetFromContainingBlock,
|
||||
childCrossOffsetFromContainingBlock);
|
||||
childCrossOffsetFromContainingBlock,
|
||||
containingNodeAvailableInnerWidth,
|
||||
containingNodeAvailableInnerHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,8 @@ void layoutAbsoluteDescendants(
|
||||
uint32_t currentDepth,
|
||||
uint32_t generationCount,
|
||||
float currentNodeMainOffsetFromContainingBlock,
|
||||
float currentNodeCrossOffsetFromContainingBlock);
|
||||
float currentNodeCrossOffsetFromContainingBlock,
|
||||
float containingNodeAvailableInnerWidth,
|
||||
float containingNodeAvailableInnerHeight);
|
||||
|
||||
} // namespace facebook::yoga
|
||||
|
@@ -2026,41 +2026,22 @@ static void calculateLayoutImpl(
|
||||
|
||||
if (performLayout) {
|
||||
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
||||
if (!node->hasErrata(Errata::PositionStaticBehavesLikeRelative)) {
|
||||
// Let the containing block layout its absolute descendants. By definition
|
||||
// the containing block will not be static unless we are at the root.
|
||||
if (node->getStyle().positionType() != PositionType::Static ||
|
||||
node->alwaysFormsContainingBlock() || depth == 1) {
|
||||
layoutAbsoluteDescendants(
|
||||
node,
|
||||
node,
|
||||
isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
|
||||
direction,
|
||||
layoutMarkerData,
|
||||
depth,
|
||||
generationCount,
|
||||
0.0f,
|
||||
0.0f);
|
||||
}
|
||||
} else {
|
||||
for (auto child : node->getChildren()) {
|
||||
if (child->getStyle().display() == Display::None ||
|
||||
child->getStyle().positionType() != PositionType::Absolute) {
|
||||
continue;
|
||||
}
|
||||
|
||||
layoutAbsoluteChild(
|
||||
node,
|
||||
node,
|
||||
child,
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
|
||||
direction,
|
||||
layoutMarkerData,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
// Let the containing block layout its absolute descendants. By definition
|
||||
// the containing block will not be static unless we are at the root.
|
||||
if (node->getStyle().positionType() != PositionType::Static ||
|
||||
node->alwaysFormsContainingBlock() || depth == 1) {
|
||||
layoutAbsoluteDescendants(
|
||||
node,
|
||||
node,
|
||||
isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
|
||||
direction,
|
||||
layoutMarkerData,
|
||||
depth,
|
||||
generationCount,
|
||||
0.0f,
|
||||
0.0f,
|
||||
availableInnerWidth,
|
||||
availableInnerHeight);
|
||||
}
|
||||
|
||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||
@@ -2074,8 +2055,7 @@ static void calculateLayoutImpl(
|
||||
// cannot guarantee that their positions are set when their parents are
|
||||
// done with layout.
|
||||
if (child->getStyle().display() == Display::None ||
|
||||
(!node->hasErrata(Errata::PositionStaticBehavesLikeRelative) &&
|
||||
child->getStyle().positionType() == PositionType::Absolute)) {
|
||||
child->getStyle().positionType() == PositionType::Absolute) {
|
||||
continue;
|
||||
}
|
||||
if (needsMainTrailingPos) {
|
||||
|
Reference in New Issue
Block a user