2017-12-19 11:18:00 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "YGNode.h"
|
|
|
|
#include <iostream>
|
2018-01-10 04:30:27 -08:00
|
|
|
#include "Utils.h"
|
2017-12-19 11:18:00 -08:00
|
|
|
|
|
|
|
void* YGNode::getContext() const {
|
|
|
|
return context_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGPrintFunc YGNode::getPrintFunc() const {
|
|
|
|
return print_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool YGNode::getHasNewLayout() const {
|
|
|
|
return hasNewLayout_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeType YGNode::getNodeType() const {
|
|
|
|
return nodeType_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGMeasureFunc YGNode::getMeasure() const {
|
|
|
|
return measure_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGBaselineFunc YGNode::getBaseline() const {
|
|
|
|
return baseline_;
|
|
|
|
}
|
|
|
|
|
2018-01-10 09:45:08 -08:00
|
|
|
YGDirtiedFunc YGNode::getDirtied() const {
|
|
|
|
return dirtied_;
|
|
|
|
}
|
|
|
|
|
2017-12-22 06:43:32 -08:00
|
|
|
YGStyle& YGNode::getStyle() {
|
2017-12-19 11:18:00 -08:00
|
|
|
return style_;
|
|
|
|
}
|
|
|
|
|
2017-12-22 06:43:32 -08:00
|
|
|
YGLayout& YGNode::getLayout() {
|
2017-12-19 11:18:00 -08:00
|
|
|
return layout_;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t YGNode::getLineIndex() const {
|
|
|
|
return lineIndex_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeRef YGNode::getParent() const {
|
|
|
|
return parent_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGVector YGNode::getChildren() const {
|
|
|
|
return children_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeRef YGNode::getChild(uint32_t index) const {
|
|
|
|
return children_.at(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeRef YGNode::getNextChild() const {
|
|
|
|
return nextChild_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGConfigRef YGNode::getConfig() const {
|
|
|
|
return config_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool YGNode::isDirty() const {
|
|
|
|
return isDirty_;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGValue YGNode::getResolvedDimension(int index) {
|
|
|
|
return resolvedDimensions_[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::array<YGValue, 2> YGNode::getResolvedDimensions() const {
|
|
|
|
return resolvedDimensions_;
|
|
|
|
}
|
2018-01-11 04:47:35 -08:00
|
|
|
|
|
|
|
float YGNode::getLeadingPosition(
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float axisSize) {
|
|
|
|
if (YGFlexDirectionIsRow(axis)) {
|
|
|
|
const YGValue* leadingPosition =
|
|
|
|
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined);
|
|
|
|
if (leadingPosition->unit != YGUnitUndefined) {
|
|
|
|
return YGResolveValue(*leadingPosition, axisSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const YGValue* leadingPosition =
|
|
|
|
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined);
|
|
|
|
|
|
|
|
return leadingPosition->unit == YGUnitUndefined
|
|
|
|
? 0.0f
|
|
|
|
: YGResolveValue(*leadingPosition, axisSize);
|
|
|
|
}
|
|
|
|
|
2018-01-11 04:47:38 -08:00
|
|
|
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
|
|
|
return (YGFlexDirectionIsRow(axis) &&
|
|
|
|
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
|
|
|
->unit != YGUnitUndefined) ||
|
|
|
|
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined)
|
|
|
|
->unit != YGUnitUndefined;
|
|
|
|
}
|
|
|
|
|
2017-12-19 11:18:00 -08:00
|
|
|
// Setters
|
|
|
|
|
|
|
|
void YGNode::setContext(void* context) {
|
|
|
|
context_ = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setPrintFunc(YGPrintFunc printFunc) {
|
|
|
|
print_ = printFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setHasNewLayout(bool hasNewLayout) {
|
|
|
|
hasNewLayout_ = hasNewLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setNodeType(YGNodeType nodeType) {
|
|
|
|
nodeType_ = nodeType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setStyleFlexDirection(YGFlexDirection direction) {
|
|
|
|
style_.flexDirection = direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setStyleAlignContent(YGAlign alignContent) {
|
|
|
|
style_.alignContent = alignContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
|
|
|
if (measureFunc == nullptr) {
|
|
|
|
measure_ = nullptr;
|
|
|
|
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
|
|
|
// places in Litho
|
|
|
|
nodeType_ = YGNodeTypeDefault;
|
|
|
|
} else {
|
|
|
|
YGAssertWithNode(
|
|
|
|
this,
|
|
|
|
children_.size() == 0,
|
|
|
|
"Cannot set measure function: Nodes with measure functions cannot have children.");
|
|
|
|
measure_ = measureFunc;
|
|
|
|
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
|
|
|
// places in Litho
|
|
|
|
setNodeType(YGNodeTypeText);
|
|
|
|
}
|
|
|
|
|
|
|
|
measure_ = measureFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setBaseLineFunc(YGBaselineFunc baseLineFunc) {
|
|
|
|
baseline_ = baseLineFunc;
|
|
|
|
}
|
|
|
|
|
2018-01-10 09:45:08 -08:00
|
|
|
void YGNode::setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
|
|
|
dirtied_ = dirtiedFunc;
|
|
|
|
}
|
|
|
|
|
2017-12-19 11:18:00 -08:00
|
|
|
void YGNode::setStyle(YGStyle style) {
|
|
|
|
style_ = style;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayout(YGLayout layout) {
|
|
|
|
layout_ = layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLineIndex(uint32_t lineIndex) {
|
|
|
|
lineIndex_ = lineIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setParent(YGNodeRef parent) {
|
|
|
|
parent_ = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setChildren(YGVector children) {
|
|
|
|
children_ = children;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setNextChild(YGNodeRef nextChild) {
|
|
|
|
nextChild_ = nextChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::replaceChild(YGNodeRef child, uint32_t index) {
|
|
|
|
children_[index] = child;
|
|
|
|
}
|
|
|
|
|
2018-01-08 02:48:32 -08:00
|
|
|
void YGNode::replaceChild(YGNodeRef oldChild, YGNodeRef newChild) {
|
|
|
|
std::replace(children_.begin(), children_.end(), oldChild, newChild);
|
|
|
|
}
|
|
|
|
|
2017-12-19 11:18:00 -08:00
|
|
|
void YGNode::insertChild(YGNodeRef child, uint32_t index) {
|
|
|
|
children_.insert(children_.begin() + index, child);
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setConfig(YGConfigRef config) {
|
|
|
|
config_ = config;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setDirty(bool isDirty) {
|
2018-01-10 09:45:08 -08:00
|
|
|
if (isDirty == isDirty_) {
|
|
|
|
return;
|
|
|
|
}
|
2017-12-19 11:18:00 -08:00
|
|
|
isDirty_ = isDirty;
|
2018-01-10 09:45:08 -08:00
|
|
|
if (isDirty && dirtied_) {
|
|
|
|
dirtied_(this);
|
|
|
|
}
|
2017-12-19 11:18:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool YGNode::removeChild(YGNodeRef child) {
|
|
|
|
std::vector<YGNodeRef>::iterator p =
|
|
|
|
std::find(children_.begin(), children_.end(), child);
|
|
|
|
if (p != children_.end()) {
|
|
|
|
children_.erase(p);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::removeChild(uint32_t index) {
|
|
|
|
children_.erase(children_.begin() + index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutDirection(YGDirection direction) {
|
|
|
|
layout_.direction = direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutMargin(float margin, int index) {
|
|
|
|
layout_.margin[index] = margin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutBorder(float border, int index) {
|
|
|
|
layout_.border[index] = border;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutPadding(float padding, int index) {
|
|
|
|
layout_.padding[index] = padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutLastParentDirection(YGDirection direction) {
|
|
|
|
layout_.lastParentDirection = direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutComputedFlexBasis(float computedFlexBasis) {
|
|
|
|
layout_.computedFlexBasis = computedFlexBasis;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutPosition(float position, int index) {
|
|
|
|
layout_.position[index] = position;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutComputedFlexBasisGeneration(
|
|
|
|
uint32_t computedFlexBasisGeneration) {
|
|
|
|
layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutMeasuredDimension(float measuredDimension, int index) {
|
|
|
|
layout_.measuredDimensions[index] = measuredDimension;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutHadOverflow(bool hadOverflow) {
|
|
|
|
layout_.hadOverflow = hadOverflow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::setLayoutDimension(float dimension, int index) {
|
|
|
|
layout_.dimensions[index] = dimension;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNode::YGNode()
|
|
|
|
: context_(nullptr),
|
|
|
|
print_(nullptr),
|
|
|
|
hasNewLayout_(true),
|
|
|
|
nodeType_(YGNodeTypeDefault),
|
|
|
|
measure_(nullptr),
|
|
|
|
baseline_(nullptr),
|
2018-01-10 09:45:08 -08:00
|
|
|
dirtied_(nullptr),
|
2017-12-19 11:18:00 -08:00
|
|
|
style_(gYGNodeStyleDefaults),
|
|
|
|
layout_(gYGNodeLayoutDefaults),
|
|
|
|
lineIndex_(0),
|
|
|
|
parent_(nullptr),
|
|
|
|
children_(YGVector()),
|
|
|
|
nextChild_(nullptr),
|
|
|
|
config_(nullptr),
|
|
|
|
isDirty_(false),
|
|
|
|
resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
|
|
|
|
|
|
|
|
YGNode::YGNode(const YGNode& node)
|
2017-12-22 06:43:32 -08:00
|
|
|
: context_(node.context_),
|
|
|
|
print_(node.print_),
|
|
|
|
hasNewLayout_(node.hasNewLayout_),
|
|
|
|
nodeType_(node.nodeType_),
|
|
|
|
measure_(node.measure_),
|
|
|
|
baseline_(node.baseline_),
|
2018-01-10 09:45:08 -08:00
|
|
|
dirtied_(node.dirtied_),
|
2017-12-22 06:43:32 -08:00
|
|
|
style_(node.style_),
|
|
|
|
layout_(node.layout_),
|
|
|
|
lineIndex_(node.lineIndex_),
|
|
|
|
parent_(node.parent_),
|
|
|
|
children_(node.children_),
|
|
|
|
nextChild_(node.nextChild_),
|
|
|
|
config_(node.config_),
|
|
|
|
isDirty_(node.isDirty_),
|
|
|
|
resolvedDimensions_(node.resolvedDimensions_) {}
|
2017-12-19 11:18:00 -08:00
|
|
|
|
|
|
|
YGNode::YGNode(const YGConfigRef newConfig) : YGNode() {
|
|
|
|
config_ = newConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNode::YGNode(
|
|
|
|
void* context,
|
|
|
|
YGPrintFunc print,
|
|
|
|
bool hasNewLayout,
|
|
|
|
YGNodeType nodeType,
|
|
|
|
YGMeasureFunc measure,
|
|
|
|
YGBaselineFunc baseline,
|
2018-01-10 09:45:08 -08:00
|
|
|
YGDirtiedFunc dirtied,
|
2017-12-19 11:18:00 -08:00
|
|
|
YGStyle style,
|
|
|
|
YGLayout layout,
|
|
|
|
uint32_t lineIndex,
|
|
|
|
YGNodeRef parent,
|
|
|
|
YGVector children,
|
|
|
|
YGNodeRef nextChild,
|
|
|
|
YGConfigRef config,
|
|
|
|
bool isDirty,
|
|
|
|
std::array<YGValue, 2> resolvedDimensions)
|
|
|
|
: context_(context),
|
|
|
|
print_(print),
|
|
|
|
hasNewLayout_(hasNewLayout),
|
|
|
|
nodeType_(nodeType),
|
|
|
|
measure_(measure),
|
|
|
|
baseline_(baseline),
|
2018-01-10 09:45:08 -08:00
|
|
|
dirtied_(dirtied),
|
2017-12-19 11:18:00 -08:00
|
|
|
style_(style),
|
|
|
|
layout_(layout),
|
|
|
|
lineIndex_(lineIndex),
|
|
|
|
parent_(parent),
|
|
|
|
children_(children),
|
|
|
|
nextChild_(nextChild),
|
|
|
|
config_(config),
|
|
|
|
isDirty_(isDirty),
|
|
|
|
resolvedDimensions_(resolvedDimensions) {}
|
|
|
|
|
|
|
|
YGNode& YGNode::operator=(const YGNode& node) {
|
|
|
|
if (&node == this) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto child : children_) {
|
|
|
|
delete child;
|
|
|
|
}
|
|
|
|
|
|
|
|
context_ = node.getContext();
|
|
|
|
print_ = node.getPrintFunc();
|
|
|
|
hasNewLayout_ = node.getHasNewLayout();
|
|
|
|
nodeType_ = node.getNodeType();
|
|
|
|
measure_ = node.getMeasure();
|
|
|
|
baseline_ = node.getBaseline();
|
2018-01-10 09:45:08 -08:00
|
|
|
dirtied_ = node.getDirtied();
|
2017-12-22 06:43:32 -08:00
|
|
|
style_ = node.style_;
|
|
|
|
layout_ = node.layout_;
|
2017-12-19 11:18:00 -08:00
|
|
|
lineIndex_ = node.getLineIndex();
|
|
|
|
parent_ = node.getParent();
|
|
|
|
children_ = node.getChildren();
|
|
|
|
nextChild_ = node.getNextChild();
|
|
|
|
config_ = node.getConfig();
|
|
|
|
isDirty_ = node.isDirty();
|
|
|
|
resolvedDimensions_ = node.getResolvedDimensions();
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
|
|
|
|
if (YGFlexDirectionIsRow(axis) &&
|
2017-12-22 06:43:32 -08:00
|
|
|
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
|
|
|
return style_.margin[YGEdgeStart];
|
2017-12-19 11:18:00 -08:00
|
|
|
} else {
|
2017-12-22 06:43:32 -08:00
|
|
|
return style_.margin[leading[axis]];
|
2017-12-19 11:18:00 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const {
|
|
|
|
if (YGFlexDirectionIsRow(axis) &&
|
2017-12-22 06:43:32 -08:00
|
|
|
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
|
|
|
return style_.margin[YGEdgeEnd];
|
2017-12-19 11:18:00 -08:00
|
|
|
} else {
|
2017-12-22 06:43:32 -08:00
|
|
|
return style_.margin[trailing[axis]];
|
2017-12-19 11:18:00 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
YGValue YGNode::resolveFlexBasisPtr() const {
|
2017-12-22 06:43:32 -08:00
|
|
|
YGValue flexBasis = style_.flexBasis;
|
2017-12-19 11:18:00 -08:00
|
|
|
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
|
|
|
return flexBasis;
|
|
|
|
}
|
2017-12-22 06:43:32 -08:00
|
|
|
if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) {
|
2017-12-19 11:18:00 -08:00
|
|
|
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
|
|
|
}
|
|
|
|
return YGValueAuto;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::resolveDimension() {
|
|
|
|
for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) {
|
|
|
|
if (getStyle().maxDimensions[dim].unit != YGUnitUndefined &&
|
|
|
|
YGValueEqual(
|
2017-12-22 06:43:32 -08:00
|
|
|
getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
|
|
|
|
resolvedDimensions_[dim] = style_.maxDimensions[dim];
|
2017-12-19 11:18:00 -08:00
|
|
|
} else {
|
2017-12-22 06:43:32 -08:00
|
|
|
resolvedDimensions_[dim] = style_.dimensions[dim];
|
2017-12-19 11:18:00 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNode::clearChildren() {
|
|
|
|
children_.clear();
|
|
|
|
children_.shrink_to_fit();
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNode::~YGNode() {
|
|
|
|
// All the member variables are deallocated externally, so no need to
|
|
|
|
// deallocate here
|
|
|
|
}
|
|
|
|
|
2018-01-08 02:48:35 -08:00
|
|
|
// Other Methods
|
|
|
|
|
2018-01-08 02:48:32 -08:00
|
|
|
void YGNode::cloneChildrenIfNeeded() {
|
|
|
|
// YGNodeRemoveChild in yoga.cpp has a forked variant of this algorithm
|
|
|
|
// optimized for deletions.
|
|
|
|
|
2018-01-09 04:21:58 -08:00
|
|
|
const uint32_t childCount = static_cast<uint32_t>(children_.size());
|
2018-01-08 02:48:32 -08:00
|
|
|
if (childCount == 0) {
|
|
|
|
// This is an empty set. Nothing to clone.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const YGNodeRef firstChild = children_.front();
|
|
|
|
if (firstChild->getParent() == this) {
|
|
|
|
// If the first child has this node as its parent, we assume that it is
|
|
|
|
// already unique. We can do this because if we have it has a child, that
|
|
|
|
// means that its parent was at some point cloned which made that subtree
|
|
|
|
// immutable. We also assume that all its sibling are cloned as well.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const YGNodeClonedFunc cloneNodeCallback = config_->cloneNodeCallback;
|
|
|
|
for (uint32_t i = 0; i < childCount; ++i) {
|
|
|
|
const YGNodeRef oldChild = children_[i];
|
|
|
|
const YGNodeRef newChild = YGNodeClone(oldChild);
|
|
|
|
replaceChild(newChild, i);
|
|
|
|
newChild->setParent(this);
|
|
|
|
if (cloneNodeCallback) {
|
|
|
|
cloneNodeCallback(oldChild, newChild, this, i);
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 11:18:00 -08:00
|
|
|
}
|
2018-01-08 02:48:35 -08:00
|
|
|
|
|
|
|
void YGNode::markDirtyAndPropogate() {
|
|
|
|
if (!isDirty_) {
|
2018-01-10 09:45:08 -08:00
|
|
|
setDirty(true);
|
2018-01-08 02:48:35 -08:00
|
|
|
setLayoutComputedFlexBasis(YGUndefined);
|
|
|
|
if (parent_) {
|
|
|
|
parent_->markDirtyAndPropogate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-08 02:48:37 -08:00
|
|
|
|
|
|
|
float YGNode::resolveFlexGrow() {
|
|
|
|
// Root nodes flexGrow should always be 0
|
|
|
|
if (parent_ == nullptr) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
if (!YGFloatIsUndefined(style_.flexGrow)) {
|
|
|
|
return style_.flexGrow;
|
|
|
|
}
|
|
|
|
if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) {
|
|
|
|
return style_.flex;
|
|
|
|
}
|
|
|
|
return kDefaultFlexGrow;
|
|
|
|
}
|
2018-01-08 02:48:39 -08:00
|
|
|
|
|
|
|
float YGNode::resolveFlexShrink() {
|
|
|
|
if (parent_ == nullptr) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
if (!YGFloatIsUndefined(style_.flexShrink)) {
|
|
|
|
return style_.flexShrink;
|
|
|
|
}
|
|
|
|
if (!config_->useWebDefaults && !YGFloatIsUndefined(style_.flex) &&
|
|
|
|
style_.flex < 0.0f) {
|
|
|
|
return -style_.flex;
|
|
|
|
}
|
|
|
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
|
|
|
}
|