diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index 67d991a4a2c60f..13571a9d62fbc8 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -9,82 +9,6 @@ #include #include "Utils.h" -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_; -} - -YGDirtiedFunc YGNode::getDirtied() const { - return dirtied_; -} - -YGStyle& YGNode::getStyle() { - return style_; -} - -YGLayout& YGNode::getLayout() { - return layout_; -} - -uint32_t YGNode::getLineIndex() const { - return lineIndex_; -} - -YGNodeRef YGNode::getOwner() const { - return owner_; -} - -YGNodeRef YGNode::getParent() const { - return getOwner(); -} - -YGVector YGNode::getChildren() const { - return children_; -} - -uint32_t YGNode::getChildrenCount() const { - return static_cast(children_.size()); -} - -YGNodeRef YGNode::getChild(uint32_t index) const { - return children_.at(index); -} - -YGConfigRef YGNode::getConfig() const { - return config_; -} - -bool YGNode::isDirty() const { - return isDirty_; -} - -YGValue YGNode::getResolvedDimension(int index) { - return resolvedDimensions_[index]; -} - -std::array YGNode::getResolvedDimensions() const { - return resolvedDimensions_; -} - YGFloatOptional YGNode::getLeadingPosition( const YGFlexDirection& axis, const float& axisSize) const { @@ -173,29 +97,7 @@ YGFloatOptional YGNode::getMarginForAxis( // 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) { @@ -217,34 +119,6 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) { measure_ = measureFunc; } -void YGNode::setBaseLineFunc(YGBaselineFunc baseLineFunc) { - baseline_ = baseLineFunc; -} - -void YGNode::setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { - dirtied_ = dirtiedFunc; -} - -void YGNode::setStyle(const YGStyle& style) { - style_ = style; -} - -void YGNode::setLayout(const YGLayout& layout) { - layout_ = layout; -} - -void YGNode::setLineIndex(uint32_t lineIndex) { - lineIndex_ = lineIndex; -} - -void YGNode::setOwner(YGNodeRef owner) { - owner_ = owner; -} - -void YGNode::setChildren(const YGVector& children) { - children_ = children; -} - void YGNode::replaceChild(YGNodeRef child, uint32_t index) { children_[index] = child; } @@ -257,10 +131,6 @@ 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) { if (isDirty == isDirty_) { return; diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index e4d50dcf8c454f..ab302e06727ece 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -58,33 +58,97 @@ struct YGNode { std::array resolvedDimensions); // Getters - void* getContext() const; - YGPrintFunc getPrintFunc() const; - bool getHasNewLayout() const; - YGNodeType getNodeType() const; - YGMeasureFunc getMeasure() const; - YGBaselineFunc getBaseline() const; - YGDirtiedFunc getDirtied() const; + void* getContext() const { + return context_; + } + + YGPrintFunc getPrintFunc() const { + return print_; + } + + bool getHasNewLayout() const { + return hasNewLayout_; + } + + YGNodeType getNodeType() const { + return nodeType_; + } + + YGMeasureFunc getMeasure() const { + return measure_; + } + + YGBaselineFunc getBaseline() const { + return baseline_; + } + + YGDirtiedFunc getDirtied() const { + return dirtied_; + } + // For Performance reasons passing as reference. - YGStyle& getStyle(); + YGStyle& getStyle() { + return style_; + } + + const YGStyle& getStyle() const { + return style_; + } + // For Performance reasons passing as reference. - YGLayout& getLayout(); - uint32_t getLineIndex() const; + YGLayout& getLayout() { + return layout_; + } + + const YGLayout& getLayout() const { + return layout_; + } + + uint32_t getLineIndex() const { + return lineIndex_; + } + // returns the YGNodeRef that owns this YGNode. An owner is used to identify // the YogaTree that a YGNode belongs to. // This method will return the parent of the YGNode when a YGNode only belongs // to one YogaTree or nullptr when the YGNode is shared between two or more // YogaTrees. - YGNodeRef getOwner() const; + YGNodeRef getOwner() const { + return owner_; + } + // Deprecated, use getOwner() instead. - YGNodeRef getParent() const; - YGVector getChildren() const; - uint32_t getChildrenCount() const; - YGNodeRef getChild(uint32_t index) const; - YGConfigRef getConfig() const; - bool isDirty() const; - std::array getResolvedDimensions() const; - YGValue getResolvedDimension(int index); + YGNodeRef getParent() const { + return getOwner(); + } + + YGVector getChildren() const { + return children_; + } + + uint32_t getChildrenCount() const { + return static_cast(children_.size()); + } + + YGNodeRef getChild(uint32_t index) const { + return children_.at(index); + } + + YGConfigRef getConfig() const { + return config_; + } + + bool isDirty() const { + return isDirty_; + } + + std::array getResolvedDimensions() const { + return resolvedDimensions_; + } + + YGValue getResolvedDimension(int index) const { + return resolvedDimensions_[index]; + } // Methods related to positions, margin, padding and border YGFloatOptional getLeadingPosition(const YGFlexDirection& axis, @@ -119,21 +183,66 @@ struct YGNode { const float& widthSize) const; // Setters - void setContext(void* context); - void setPrintFunc(YGPrintFunc printFunc); - void setHasNewLayout(bool hasNewLayout); - void setNodeType(YGNodeType nodeTye); + void setContext(void* context) { + context_ = context; + } + + void setPrintFunc(YGPrintFunc printFunc) { + print_ = printFunc; + } + + void setHasNewLayout(bool hasNewLayout) { + hasNewLayout_ = hasNewLayout; + } + + void setNodeType(YGNodeType nodeType) { + nodeType_ = nodeType; + } + + void setStyleFlexDirection(YGFlexDirection direction) { + style_.flexDirection = direction; + } + + void setStyleAlignContent(YGAlign alignContent) { + style_.alignContent = alignContent; + } + void setMeasureFunc(YGMeasureFunc measureFunc); - void setBaseLineFunc(YGBaselineFunc baseLineFunc); - void setDirtiedFunc(YGDirtiedFunc dirtiedFunc); - void setStyle(const YGStyle& style); - void setStyleFlexDirection(YGFlexDirection direction); - void setStyleAlignContent(YGAlign alignContent); - void setLayout(const YGLayout& layout); - void setLineIndex(uint32_t lineIndex); - void setOwner(YGNodeRef owner); - void setChildren(const YGVector& children); - void setConfig(YGConfigRef config); + + void setBaseLineFunc(YGBaselineFunc baseLineFunc) { + baseline_ = baseLineFunc; + } + + void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { + dirtied_ = dirtiedFunc; + } + + void setStyle(const YGStyle& style) { + style_ = style; + } + + void setLayout(const YGLayout& layout) { + layout_ = layout; + } + + void setLineIndex(uint32_t lineIndex) { + lineIndex_ = lineIndex; + } + + void setOwner(YGNodeRef owner) { + owner_ = owner; + } + + void setChildren(const YGVector& children) { + children_ = children; + } + + // TODO: rvalue override for setChildren + + void setConfig(YGConfigRef config) { + config_ = config; + } + void setDirty(bool isDirty); void setLayoutLastOwnerDirection(YGDirection direction); void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);