Fixed issue with first line element gap handling. (#1408)
Summary: If the first element of a line is not contributing (e.g. position absolute), an additional gap will be added to the line, because the first gap element of the line is never identified (wrong start index). Fix: raise the index of the first line element until we find an element that is contributing to the line. Pull Request resolved: https://github.com/facebook/yoga/pull/1408 Reviewed By: yungsters Differential Revision: D49722065 Pulled By: NickGerleman fbshipit-source-id: 1068cb0b11ae4b04ec8d063e70540cce06181d5a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b03a821884
commit
07cabca526
@@ -28,6 +28,7 @@ FlexLine calculateFlexLine(
|
||||
float totalFlexGrowFactors = 0.0f;
|
||||
float totalFlexShrinkScaledFactors = 0.0f;
|
||||
size_t endOfLineIndex = startOfLineIndex;
|
||||
size_t firstElementInLineIndex = startOfLineIndex;
|
||||
|
||||
float sizeConsumedIncludingMinConstraint = 0;
|
||||
const FlexDirection mainAxis = resolveDirection(
|
||||
@@ -40,10 +41,15 @@ FlexLine calculateFlexLine(
|
||||
auto child = node->getChild(endOfLineIndex);
|
||||
if (child->getStyle().display() == Display::None ||
|
||||
child->getStyle().positionType() == PositionType::Absolute) {
|
||||
if (firstElementInLineIndex == endOfLineIndex) {
|
||||
// We haven't found the first contributing element in the line yet.
|
||||
firstElementInLineIndex++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool isFirstElementInLine = (endOfLineIndex - startOfLineIndex) == 0;
|
||||
const bool isFirstElementInLine =
|
||||
(endOfLineIndex - firstElementInLineIndex) == 0;
|
||||
|
||||
child->setLineIndex(lineCount);
|
||||
const float childMarginMainAxis =
|
||||
|
Reference in New Issue
Block a user