Moved YGNodeIsFlex as a method on YGNode
Summary: Moved YGNodeIsFlex as a method on YGNode Reviewed By: emilsjolander Differential Revision: D6711536 fbshipit-source-id: e60be7da55e3e8d254eb253c141d219a37a76087
This commit is contained in:
committed by
Facebook Github Bot
parent
a9dd527748
commit
5806f1728c
@@ -590,3 +590,9 @@ float YGNode::resolveFlexShrink() {
|
|||||||
}
|
}
|
||||||
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool YGNode::isNodeFlexible() {
|
||||||
|
return (
|
||||||
|
(style_.positionType == YGPositionTypeRelative) &&
|
||||||
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
|
}
|
||||||
|
@@ -111,7 +111,11 @@ struct YGNode {
|
|||||||
void setLayoutMeasuredDimension(float measuredDimension, int index);
|
void setLayoutMeasuredDimension(float measuredDimension, int index);
|
||||||
void setLayoutHadOverflow(bool hadOverflow);
|
void setLayoutHadOverflow(bool hadOverflow);
|
||||||
void setLayoutDimension(float dimension, int index);
|
void setLayoutDimension(float dimension, int index);
|
||||||
|
void setLayoutDirection(YGDirection direction);
|
||||||
|
void setLayoutMargin(float margin, int index);
|
||||||
|
void setLayoutBorder(float border, int index);
|
||||||
|
void setLayoutPadding(float padding, int index);
|
||||||
|
void setLayoutPosition(float position, int index);
|
||||||
void setPosition(
|
void setPosition(
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const float mainSize,
|
const float mainSize,
|
||||||
@@ -131,15 +135,10 @@ struct YGNode {
|
|||||||
/// Removes the first occurrence of child
|
/// Removes the first occurrence of child
|
||||||
bool removeChild(YGNodeRef child);
|
bool removeChild(YGNodeRef child);
|
||||||
void removeChild(uint32_t index);
|
void removeChild(uint32_t index);
|
||||||
void setLayoutDirection(YGDirection direction);
|
|
||||||
void setLayoutMargin(float margin, int index);
|
|
||||||
void setLayoutBorder(float border, int index);
|
|
||||||
void setLayoutPadding(float padding, int index);
|
|
||||||
void setLayoutPosition(float position, int index);
|
|
||||||
|
|
||||||
// Other methods
|
|
||||||
void cloneChildrenIfNeeded();
|
void cloneChildrenIfNeeded();
|
||||||
void markDirtyAndPropogate();
|
void markDirtyAndPropogate();
|
||||||
float resolveFlexGrow();
|
float resolveFlexGrow();
|
||||||
float resolveFlexShrink();
|
float resolveFlexShrink();
|
||||||
|
bool isNodeFlexible();
|
||||||
};
|
};
|
||||||
|
@@ -915,12 +915,6 @@ static float YGBaseline(const YGNodeRef node) {
|
|||||||
return baseline + baselineChild->getLayout().position[YGEdgeTop];
|
return baseline + baselineChild->getLayout().position[YGEdgeTop];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool YGNodeIsFlex(const YGNodeRef node) {
|
|
||||||
return (
|
|
||||||
node->getStyle().positionType == YGPositionTypeRelative &&
|
|
||||||
(node->resolveFlexGrow() != 0 || node->resolveFlexShrink() != 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
||||||
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
|
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1611,7 +1605,7 @@ static void YGNodeComputeFlexBasisForChildren(
|
|||||||
if (measureModeMainDim == YGMeasureModeExactly) {
|
if (measureModeMainDim == YGMeasureModeExactly) {
|
||||||
for (auto child : children) {
|
for (auto child : children) {
|
||||||
if (singleFlexChild != nullptr) {
|
if (singleFlexChild != nullptr) {
|
||||||
if (YGNodeIsFlex(child)) {
|
if (child->isNodeFlexible()) {
|
||||||
// There is already a flexible child, abort
|
// There is already a flexible child, abort
|
||||||
singleFlexChild = nullptr;
|
singleFlexChild = nullptr;
|
||||||
break;
|
break;
|
||||||
@@ -2033,7 +2027,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
sizeConsumedOnCurrentLine += flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
|
sizeConsumedOnCurrentLine += flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
|
||||||
itemsOnLine++;
|
itemsOnLine++;
|
||||||
|
|
||||||
if (YGNodeIsFlex(child)) {
|
if (child->isNodeFlexible()) {
|
||||||
totalFlexGrowFactors += child->resolveFlexGrow();
|
totalFlexGrowFactors += child->resolveFlexGrow();
|
||||||
|
|
||||||
// Unlike the grow factor, the shrink factor is scaled relative to the child dimension.
|
// Unlike the grow factor, the shrink factor is scaled relative to the child dimension.
|
||||||
|
Reference in New Issue
Block a user