Browse files

Moved out logic to calculate size consumed on a line into seperate fu…


Reviewed By: emilsjolander

Differential Revision: D6797640

fbshipit-source-id: ad9757e7d603c0ce57f452b1e5c404037605bed9
  • Loading branch information...
priteshrnandgaonkar authored and facebook-github-bot committed Feb 5, 2018
1 parent 8235a49 commit 34b7ec82b5d22efbdaa8b74b930d3c4da87414ec
Showing with 187 additions and 109 deletions.
  1. +35 −0 ReactCommon/yoga/yoga/Utils.h
  2. +4 −0 ReactCommon/yoga/yoga/YGNode.cpp
  3. +1 −0 ReactCommon/yoga/yoga/YGNode.h
  4. +147 −109 ReactCommon/yoga/yoga/Yoga.cpp
@@ -11,6 +11,41 @@
#include "YGNode.h"
#include "Yoga-internal.h"
// This struct is an helper model to hold the data for step 4 of flexbox
// algo, which is collecting the flex items in a line.
// - itemsOnLine: Number of items which can fit in a line considering the
// available Inner dimension, the flex items computed flexbasis and their
// margin. It may be different than the difference between start and end
// indicates because we skip over absolute-positioned items.
// - sizeConsumedOnCurrentLine: It is accumulation of the dimensions and margin
// of all the children on the current line. This will be used in order to either
// set the dimensions of the node if none already exist or to compute the
// remaining space left for the flexible children.
// - totalFlexGrowFactors: total flex grow factors of flex items which are to be
// layed in the current line
// - totalFlexShrinkFactors: total flex shrink factors of flex items which are
// to be layed in the current line
// - endOfLineIndex: Its the end index of the last flex item which was examined
// and it may or may not be part of the current line(as it may be absolutely
// positioned or inculding it may have caused to overshoot availableInnerDim)
// - relativeChildren: Maintain a vector of the child nodes that can shrink
// and/or grow.
struct YGCollectFlexItemsRowValues {
uint32_t itemsOnLine;
float sizeConsumedOnCurrentLine;
float totalFlexGrowFactors;
float totalFlexShrinkScaledFactors;
float endOfLineIndex;
std::vector<YGNodeRef> relativeChildren;
bool YGValueEqual(const YGValue a, const YGValue b);
YGFlexDirection YGFlexDirectionCross(
@@ -59,6 +59,10 @@ YGVector YGNode::getChildren() const {
return children_;
uint32_t YGNode::getChildrenCount() const {
return static_cast<uint32_t>(children_.size());
YGNodeRef YGNode::getChild(uint32_t index) const {
@@ -72,6 +72,7 @@ struct YGNode {
uint32_t getLineIndex() const;
YGNodeRef getParent() const;
YGVector getChildren() const;
uint32_t getChildrenCount() const;
YGNodeRef getChild(uint32_t index) const;
YGNodeRef getNextChild() const;
YGConfigRef getConfig() const;
Oops, something went wrong.

0 comments on commit 34b7ec8

Please sign in to comment.