Reverted commit D4147298
Reviewed By: gkassabli Differential Revision: D4147298 fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d
This commit is contained in:
parent
1e57d1156f
commit
653e8d9b9a
|
@ -259,8 +259,7 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) {
|
void CSSNodeSetMeasureFunc(const CSSNodeRef node, CSSMeasureFunc measureFunc) {
|
||||||
CSS_ASSERT(CSSNodeChildCount(node) == 0,
|
CSS_ASSERT(CSSNodeChildCount(node) == 0, "Cannot set measure function: Nodes with measure functions cannot have children.");
|
||||||
"Cannot set measure function: Nodes with measure functions cannot have children.");
|
|
||||||
node->measure = measureFunc;
|
node->measure = measureFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +269,7 @@ CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) {
|
||||||
|
|
||||||
void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index) {
|
void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index) {
|
||||||
CSS_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first.");
|
CSS_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first.");
|
||||||
CSS_ASSERT(node->measure == NULL,
|
CSS_ASSERT(node->measure == NULL, "Cannot add child: Nodes with measure functions cannot have children.");
|
||||||
"Cannot add child: Nodes with measure functions cannot have children.");
|
|
||||||
CSSNodeListInsert(&node->children, child, index);
|
CSSNodeListInsert(&node->children, child, index);
|
||||||
child->parent = node;
|
child->parent = node;
|
||||||
_CSSNodeMarkDirty(node);
|
_CSSNodeMarkDirty(node);
|
||||||
|
@ -1369,26 +1367,6 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight;
|
const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight;
|
||||||
const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;
|
const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;
|
||||||
|
|
||||||
// If there is only one child with flexGrow + flexShrink it means we can set the
|
|
||||||
// computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly
|
|
||||||
// match the remaining space
|
|
||||||
CSSNodeRef singleFlexChild = NULL;
|
|
||||||
if ((isMainAxisRow && widthMeasureMode != CSSMeasureModeUndefined) ||
|
|
||||||
(!isMainAxisRow && heightMeasureMode != CSSMeasureModeUndefined)) {
|
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
|
||||||
const CSSNodeRef child = CSSNodeGetChild(node, i);
|
|
||||||
if (singleFlexChild) {
|
|
||||||
if (isFlex(child)) {
|
|
||||||
// There is already a flexible child, abort.
|
|
||||||
singleFlexChild = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (CSSNodeStyleGetFlexGrow(child) > 0 && CSSNodeStyleGetFlexShrink(child) > 0) {
|
|
||||||
singleFlexChild = child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
|
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
const CSSNodeRef child = CSSNodeListGet(node->children, i);
|
const CSSNodeRef child = CSSNodeListGet(node->children, i);
|
||||||
|
@ -1413,17 +1391,13 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||||
currentAbsoluteChild = child;
|
currentAbsoluteChild = child;
|
||||||
child->nextChild = NULL;
|
child->nextChild = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (child == singleFlexChild) {
|
computeChildFlexBasis(node,
|
||||||
child->layout.computedFlexBasis = 0;
|
child,
|
||||||
} else {
|
availableInnerWidth,
|
||||||
computeChildFlexBasis(node,
|
widthMeasureMode,
|
||||||
child,
|
availableInnerHeight,
|
||||||
availableInnerWidth,
|
heightMeasureMode,
|
||||||
widthMeasureMode,
|
direction);
|
||||||
availableInnerHeight,
|
|
||||||
heightMeasureMode,
|
|
||||||
direction);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2159,17 +2133,17 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
|
bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
|
||||||
const float width,
|
const float width,
|
||||||
const CSSMeasureMode heightMode,
|
const CSSMeasureMode heightMode,
|
||||||
const float height,
|
const float height,
|
||||||
const CSSMeasureMode lastWidthMode,
|
const CSSMeasureMode lastWidthMode,
|
||||||
const float lastWidth,
|
const float lastWidth,
|
||||||
const CSSMeasureMode lastHeightMode,
|
const CSSMeasureMode lastHeightMode,
|
||||||
const float lastHeight,
|
const float lastHeight,
|
||||||
const float lastComputedWidth,
|
const float lastComputedWidth,
|
||||||
const float lastComputedHeight,
|
const float lastComputedHeight,
|
||||||
const float marginRow,
|
const float marginRow,
|
||||||
const float marginColumn) {
|
const float marginColumn) {
|
||||||
if (lastComputedHeight < 0 || lastComputedWidth < 0) {
|
if (lastComputedHeight < 0 || lastComputedWidth < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2187,16 +2161,19 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
|
||||||
newMeasureSizeIsStricterAndStillValid(
|
newMeasureSizeIsStricterAndStillValid(
|
||||||
widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth);
|
widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth);
|
||||||
|
|
||||||
const bool heightIsCompatible =
|
const bool heightIsCompatible = hasSameHeightSpec ||
|
||||||
hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode,
|
newSizeIsExactAndMatchesOldMeasuredSize(heightMode,
|
||||||
|
height - marginColumn,
|
||||||
|
lastComputedHeight) ||
|
||||||
|
oldSizeIsUnspecifiedAndStillFits(heightMode,
|
||||||
height - marginColumn,
|
height - marginColumn,
|
||||||
|
lastHeightMode,
|
||||||
lastComputedHeight) ||
|
lastComputedHeight) ||
|
||||||
oldSizeIsUnspecifiedAndStillFits(heightMode,
|
newMeasureSizeIsStricterAndStillValid(heightMode,
|
||||||
height - marginColumn,
|
height - marginColumn,
|
||||||
lastHeightMode,
|
lastHeightMode,
|
||||||
lastComputedHeight) ||
|
lastHeight,
|
||||||
newMeasureSizeIsStricterAndStillValid(
|
lastComputedHeight);
|
||||||
heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight);
|
|
||||||
|
|
||||||
return widthIsCompatible && heightIsCompatible;
|
return widthIsCompatible && heightIsCompatible;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue