Reflow comments
Summary: @public Repeated application and alternation of Clang Format rules has lead to unfortunate block comment formatting. Here, we reflow comments Reviewed By: SidharthGuglani Differential Revision: D13677242 fbshipit-source-id: 3f1f5e38693eb15e9705f24fd363fc1618c78974
This commit is contained in:
committed by
Facebook Github Bot
parent
7fa0816d81
commit
71321f763a
@@ -149,8 +149,8 @@ private:
|
|||||||
static constexpr uint32_t BIAS = 0x20000000;
|
static constexpr uint32_t BIAS = 0x20000000;
|
||||||
static constexpr uint32_t PERCENT_BIT = 0x40000000;
|
static constexpr uint32_t PERCENT_BIT = 0x40000000;
|
||||||
|
|
||||||
// these are signaling NaNs with specific bit pattern as payload
|
// these are signaling NaNs with specific bit pattern as payload they will be
|
||||||
// they will be silenced whenever going through an FPU operation on ARM + x86
|
// silenced whenever going through an FPU operation on ARM + x86
|
||||||
static constexpr uint32_t AUTO_BITS = 0x7faaaaaa;
|
static constexpr uint32_t AUTO_BITS = 0x7faaaaaa;
|
||||||
static constexpr uint32_t ZERO_BITS_POINT = 0x7f8f0f0f;
|
static constexpr uint32_t ZERO_BITS_POINT = 0x7f8f0f0f;
|
||||||
static constexpr uint32_t ZERO_BITS_PERCENT = 0x7f80f0f0;
|
static constexpr uint32_t ZERO_BITS_PERCENT = 0x7f80f0f0;
|
||||||
|
26
yoga/Utils.h
26
yoga/Utils.h
@@ -9,31 +9,31 @@
|
|||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "CompactValue.h"
|
#include "CompactValue.h"
|
||||||
|
|
||||||
// This struct is an helper model to hold the data for step 4 of flexbox
|
// This struct is an helper model to hold the data for step 4 of flexbox algo,
|
||||||
// algo, which is collecting the flex items in a line.
|
// which is collecting the flex items in a line.
|
||||||
//
|
//
|
||||||
// - itemsOnLine: Number of items which can fit in a line considering the
|
// - itemsOnLine: Number of items which can fit in a line considering the
|
||||||
// available Inner dimension, the flex items computed flexbasis and their
|
// available Inner dimension, the flex items computed flexbasis and their
|
||||||
// margin. It may be different than the difference between start and end
|
// margin. It may be different than the difference between start and end
|
||||||
// indicates because we skip over absolute-positioned items.
|
// indicates because we skip over absolute-positioned items.
|
||||||
//
|
//
|
||||||
// - sizeConsumedOnCurrentLine: It is accumulation of the dimensions and margin
|
// - 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
|
// of all the children on the current line. This will be used in order to
|
||||||
// set the dimensions of the node if none already exist or to compute the
|
// either set the dimensions of the node if none already exist or to compute
|
||||||
// remaining space left for the flexible children.
|
// the remaining space left for the flexible children.
|
||||||
//
|
//
|
||||||
// - totalFlexGrowFactors: total flex grow factors of flex items which are to be
|
// - totalFlexGrowFactors: total flex grow factors of flex items which are to be
|
||||||
// layed in the current line
|
// layed in the current line
|
||||||
//
|
//
|
||||||
// - totalFlexShrinkFactors: total flex shrink factors of flex items which are
|
// - totalFlexShrinkFactors: total flex shrink factors of flex items which are
|
||||||
// to be layed in the current line
|
// to be layed in the current line
|
||||||
//
|
//
|
||||||
// - endOfLineIndex: Its the end index of the last flex item which was examined
|
// - 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
|
// 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)
|
// positioned or inculding it may have caused to overshoot availableInnerDim)
|
||||||
//
|
//
|
||||||
// - relativeChildren: Maintain a vector of the child nodes that can shrink
|
// - relativeChildren: Maintain a vector of the child nodes that can shrink
|
||||||
// and/or grow.
|
// and/or grow.
|
||||||
|
|
||||||
struct YGCollectFlexItemsRowValues {
|
struct YGCollectFlexItemsRowValues {
|
||||||
uint32_t itemsOnLine;
|
uint32_t itemsOnLine;
|
||||||
|
@@ -25,8 +25,8 @@ struct YGLayout {
|
|||||||
uint32_t computedFlexBasisGeneration = 0;
|
uint32_t computedFlexBasisGeneration = 0;
|
||||||
YGFloatOptional computedFlexBasis = {};
|
YGFloatOptional computedFlexBasis = {};
|
||||||
|
|
||||||
// Instead of recomputing the entire layout every single time, we
|
// Instead of recomputing the entire layout every single time, we cache some
|
||||||
// cache some information to break early when nothing changed
|
// information to break early when nothing changed
|
||||||
uint32_t generationCount = 0;
|
uint32_t generationCount = 0;
|
||||||
YGDirection lastOwnerDirection = (YGDirection) -1;
|
YGDirection lastOwnerDirection = (YGDirection) -1;
|
||||||
|
|
||||||
|
@@ -23,8 +23,8 @@ typedef struct {
|
|||||||
// accepts marker type, a node ref, and marker data (depends on marker type)
|
// accepts marker type, a node ref, and marker data (depends on marker type)
|
||||||
// can return a handle or id that Yoga will pass to endMarker
|
// can return a handle or id that Yoga will pass to endMarker
|
||||||
void* (*startMarker)(YGMarkerType, YGNodeRef, YGMarkerData);
|
void* (*startMarker)(YGMarkerType, YGNodeRef, YGMarkerData);
|
||||||
// accepts marker type, a node ref, marker data, and marker id as returned
|
// accepts marker type, a node ref, marker data, and marker id as returned by
|
||||||
// by startMarker
|
// startMarker
|
||||||
void (*endMarker)(YGMarkerType, YGNodeRef, YGMarkerData, void* id);
|
void (*endMarker)(YGMarkerType, YGNodeRef, YGMarkerData, void* id);
|
||||||
} YGMarkerCallbacks;
|
} YGMarkerCallbacks;
|
||||||
|
|
||||||
|
@@ -206,8 +206,8 @@ void YGNode::setLayoutDimension(float dimension, int index) {
|
|||||||
layout_.dimensions[index] = dimension;
|
layout_.dimensions[index] = dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both left and right are defined, then use left. Otherwise return
|
// If both left and right are defined, then use left. Otherwise return +left or
|
||||||
// +left or -right depending on which is defined.
|
// -right depending on which is defined.
|
||||||
YGFloatOptional YGNode::relativePosition(
|
YGFloatOptional YGNode::relativePosition(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
|
@@ -102,10 +102,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
||||||
// the YogaTree that a YGNode belongs to.
|
// the YogaTree that a YGNode belongs to. This method will return the parent
|
||||||
// This method will return the parent of the YGNode when a YGNode only belongs
|
// of the YGNode when a YGNode only belongs to one YogaTree or nullptr when
|
||||||
// to one YogaTree or nullptr when the YGNode is shared between two or more
|
// the YGNode is shared between two or more YogaTrees.
|
||||||
// YogaTrees.
|
|
||||||
YGNodeRef getOwner() const {
|
YGNodeRef getOwner() const {
|
||||||
return owner_;
|
return owner_;
|
||||||
}
|
}
|
||||||
|
231
yoga/Yoga.cpp
231
yoga/Yoga.cpp
@@ -1322,8 +1322,8 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
child->getResolvedDimension(YGDimensionHeight), ownerHeight),
|
child->getResolvedDimension(YGDimensionHeight), ownerHeight),
|
||||||
paddingAndBorder));
|
paddingAndBorder));
|
||||||
} else {
|
} else {
|
||||||
// Compute the flex basis and hypothetical main size (i.e. the clamped
|
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
|
||||||
// flex basis).
|
// basis).
|
||||||
childWidth = YGUndefined;
|
childWidth = YGUndefined;
|
||||||
childHeight = YGUndefined;
|
childHeight = YGUndefined;
|
||||||
childWidthMeasureMode = YGMeasureModeUndefined;
|
childWidthMeasureMode = YGMeasureModeUndefined;
|
||||||
@@ -1351,8 +1351,8 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The W3C spec doesn't say anything about the 'overflow' property,
|
// The W3C spec doesn't say anything about the 'overflow' property, but all
|
||||||
// but all major browsers appear to implement the following logic.
|
// major browsers appear to implement the following logic.
|
||||||
if ((!isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
|
if ((!isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
|
||||||
node->getStyle().overflow != YGOverflowScroll) {
|
node->getStyle().overflow != YGOverflowScroll) {
|
||||||
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
|
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
|
||||||
@@ -1383,9 +1383,8 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If child has no defined size in the cross axis and is set to stretch,
|
// If child has no defined size in the cross axis and is set to stretch, set
|
||||||
// set the cross
|
// the cross axis to be measured exactly with the available inner width
|
||||||
// axis to be measured exactly with the available inner width
|
|
||||||
|
|
||||||
const bool hasExactWidth =
|
const bool hasExactWidth =
|
||||||
!YGFloatIsUndefined(width) && widthMode == YGMeasureModeExactly;
|
!YGFloatIsUndefined(width) && widthMode == YGMeasureModeExactly;
|
||||||
@@ -1484,9 +1483,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified width, compute the width based
|
// If the child doesn't have a specified width, compute the width based on
|
||||||
// on the left/right
|
// the left/right offsets if they're defined.
|
||||||
// offsets if they're defined.
|
|
||||||
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionRow)) {
|
child->isTrailingPosDefined(YGFlexDirectionRow)) {
|
||||||
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
||||||
@@ -1506,9 +1504,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified height, compute the height
|
// If the child doesn't have a specified height, compute the height based on
|
||||||
// based on the top/bottom
|
// the top/bottom offsets if they're defined.
|
||||||
// offsets if they're defined.
|
|
||||||
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
|
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
|
||||||
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
||||||
@@ -1961,8 +1958,8 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
|
|
||||||
// This function assumes that all the children of node have their
|
// This function assumes that all the children of node have their
|
||||||
// computedFlexBasis properly computed(To do this use
|
// computedFlexBasis properly computed(To do this use
|
||||||
// YGNodeComputeFlexBasisForChildren function).
|
// YGNodeComputeFlexBasisForChildren function). This function calculates
|
||||||
// This function calculates YGCollectFlexItemsRowMeasurement
|
// YGCollectFlexItemsRowMeasurement
|
||||||
static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
||||||
const YGNodeRef& node,
|
const YGNodeRef& node,
|
||||||
const YGDirection ownerDirection,
|
const YGDirection ownerDirection,
|
||||||
@@ -1998,10 +1995,9 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
|||||||
mainAxisownerSize)
|
mainAxisownerSize)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// If this is a multi-line flow and this item pushes us over the
|
// If this is a multi-line flow and this item pushes us over the available
|
||||||
// available size, we've
|
// size, we've hit the end of the current line. Break out of the loop and
|
||||||
// hit the end of the current line. Break out of the loop and lay out
|
// lay out the current line.
|
||||||
// the current line.
|
|
||||||
if (sizeConsumedOnCurrentLineIncludingMinConstraint +
|
if (sizeConsumedOnCurrentLineIncludingMinConstraint +
|
||||||
flexBasisWithMinAndMaxConstraints + childMarginMainAxis >
|
flexBasisWithMinAndMaxConstraints + childMarginMainAxis >
|
||||||
availableInnerMainDim &&
|
availableInnerMainDim &&
|
||||||
@@ -2276,12 +2272,10 @@ static void YGDistributeFreeSpaceFirstPass(
|
|||||||
if (!YGFloatIsUndefined(baseMainSize) &&
|
if (!YGFloatIsUndefined(baseMainSize) &&
|
||||||
!YGFloatIsUndefined(boundMainSize) &&
|
!YGFloatIsUndefined(boundMainSize) &&
|
||||||
baseMainSize != boundMainSize) {
|
baseMainSize != boundMainSize) {
|
||||||
// By excluding this item's size and flex factor from remaining,
|
// By excluding this item's size and flex factor from remaining, this
|
||||||
// this item's
|
// item's min/max constraints should also trigger in the second pass
|
||||||
// min/max constraints should also trigger in the second pass
|
// resulting in the item's size calculation being identical in the
|
||||||
// resulting in the
|
// first and second passes.
|
||||||
// item's size calculation being identical in the first and second
|
|
||||||
// passes.
|
|
||||||
deltaFreeSpace += boundMainSize - childFlexBasis;
|
deltaFreeSpace += boundMainSize - childFlexBasis;
|
||||||
collectedFlexItemsValues.totalFlexShrinkScaledFactors -=
|
collectedFlexItemsValues.totalFlexShrinkScaledFactors -=
|
||||||
flexShrinkScaledFactor;
|
flexShrinkScaledFactor;
|
||||||
@@ -2307,12 +2301,10 @@ static void YGDistributeFreeSpaceFirstPass(
|
|||||||
if (!YGFloatIsUndefined(baseMainSize) &&
|
if (!YGFloatIsUndefined(baseMainSize) &&
|
||||||
!YGFloatIsUndefined(boundMainSize) &&
|
!YGFloatIsUndefined(boundMainSize) &&
|
||||||
baseMainSize != boundMainSize) {
|
baseMainSize != boundMainSize) {
|
||||||
// By excluding this item's size and flex factor from remaining,
|
// By excluding this item's size and flex factor from remaining, this
|
||||||
// this item's
|
// item's min/max constraints should also trigger in the second pass
|
||||||
// min/max constraints should also trigger in the second pass
|
// resulting in the item's size calculation being identical in the
|
||||||
// resulting in the
|
// first and second passes.
|
||||||
// item's size calculation being identical in the first and second
|
|
||||||
// passes.
|
|
||||||
deltaFreeSpace += boundMainSize - childFlexBasis;
|
deltaFreeSpace += boundMainSize - childFlexBasis;
|
||||||
collectedFlexItemsValues.totalFlexGrowFactors -= flexGrowFactor;
|
collectedFlexItemsValues.totalFlexGrowFactors -= flexGrowFactor;
|
||||||
}
|
}
|
||||||
@@ -2324,25 +2316,22 @@ static void YGDistributeFreeSpaceFirstPass(
|
|||||||
|
|
||||||
// Do two passes over the flex items to figure out how to distribute the
|
// Do two passes over the flex items to figure out how to distribute the
|
||||||
// remaining space.
|
// remaining space.
|
||||||
// The first pass finds the items whose min/max constraints trigger,
|
|
||||||
// freezes them at those
|
|
||||||
// sizes, and excludes those sizes from the remaining space. The second
|
|
||||||
// pass sets the size
|
|
||||||
// of each flexible item. It distributes the remaining space amongst the
|
|
||||||
// items whose min/max
|
|
||||||
// constraints didn't trigger in pass 1. For the other items, it sets
|
|
||||||
// their sizes by forcing
|
|
||||||
// their min/max constraints to trigger again.
|
|
||||||
//
|
//
|
||||||
// This two pass approach for resolving min/max constraints deviates from
|
// The first pass finds the items whose min/max constraints trigger, freezes
|
||||||
// the spec. The
|
// them at those sizes, and excludes those sizes from the remaining space.
|
||||||
// spec (https://www.w3.org/TR/CSS-flexbox-1/#resolve-flexible-lengths)
|
//
|
||||||
// describes a process
|
// The second pass sets the size of each flexible item. It distributes the
|
||||||
// that needs to be repeated a variable number of times. The algorithm
|
// remaining space amongst the items whose min/max constraints didn't trigger in
|
||||||
// implemented here
|
// the first pass. For the other items, it sets their sizes by forcing their
|
||||||
// won't handle all cases but it was simpler to implement and it mitigates
|
// min/max constraints to trigger again.
|
||||||
// performance
|
//
|
||||||
// concerns because we know exactly how many passes it'll do.
|
// This two pass approach for resolving min/max constraints deviates from the
|
||||||
|
// spec. The spec
|
||||||
|
// (https://www.w3.org/TR/CSS-flexbox-1/#resolve-flexible-lengths) describes a
|
||||||
|
// process that needs to be repeated a variable number of times. The algorithm
|
||||||
|
// implemented here won't handle all cases but it was simpler to implement and
|
||||||
|
// it mitigates performance concerns because we know exactly how many passes
|
||||||
|
// it'll do.
|
||||||
//
|
//
|
||||||
// At the end of this function the child nodes would have the proper size
|
// At the end of this function the child nodes would have the proper size
|
||||||
// assigned to them.
|
// assigned to them.
|
||||||
@@ -2451,9 +2440,9 @@ static void YGJustifyMainAxis(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to position the elements in the main axis, we have two
|
// In order to position the elements in the main axis, we have two controls.
|
||||||
// controls. The space between the beginning and the first element
|
// The space between the beginning and the first element and the space between
|
||||||
// and the space between each two elements.
|
// each two elements.
|
||||||
float leadingMainDim = 0;
|
float leadingMainDim = 0;
|
||||||
float betweenMainDim = 0;
|
float betweenMainDim = 0;
|
||||||
const YGJustify justifyContent = node->getStyle().justifyContent;
|
const YGJustify justifyContent = node->getStyle().justifyContent;
|
||||||
@@ -2512,8 +2501,8 @@ static void YGJustifyMainAxis(
|
|||||||
child->isLeadingPositionDefined(mainAxis)) {
|
child->isLeadingPositionDefined(mainAxis)) {
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// In case the child is position absolute and has left/top being
|
// In case the child is position absolute and has left/top being
|
||||||
// defined, we override the position to whatever the user said
|
// defined, we override the position to whatever the user said (and
|
||||||
// (and margin/border).
|
// margin/border).
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(mainAxis, availableInnerMainDim)
|
child->getLeadingPosition(mainAxis, availableInnerMainDim)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
@@ -2523,8 +2512,8 @@ static void YGJustifyMainAxis(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Now that we placed the element, we need to update the variables.
|
// Now that we placed the element, we need to update the variables.
|
||||||
// We need to do that only for relative elements. Absolute elements
|
// We need to do that only for relative elements. Absolute elements do not
|
||||||
// do not take part in that phase.
|
// take part in that phase.
|
||||||
if (childStyle.positionType == YGPositionTypeRelative) {
|
if (childStyle.positionType == YGPositionTypeRelative) {
|
||||||
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
||||||
collectedFlexItemsValues.mainDim +=
|
collectedFlexItemsValues.mainDim +=
|
||||||
@@ -2547,9 +2536,8 @@ static void YGJustifyMainAxis(
|
|||||||
bool canSkipFlex =
|
bool canSkipFlex =
|
||||||
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
||||||
if (canSkipFlex) {
|
if (canSkipFlex) {
|
||||||
// If we skipped the flex step, then we can't rely on the
|
// If we skipped the flex step, then we can't rely on the measuredDims
|
||||||
// measuredDims because
|
// because they weren't computed. This means we can't call
|
||||||
// they weren't computed. This means we can't call
|
|
||||||
// YGNodeDimWithMargin.
|
// YGNodeDimWithMargin.
|
||||||
collectedFlexItemsValues.mainDim += betweenMainDim +
|
collectedFlexItemsValues.mainDim += betweenMainDim +
|
||||||
child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap() +
|
child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap() +
|
||||||
@@ -2608,81 +2596,61 @@ static void YGJustifyMainAxis(
|
|||||||
|
|
||||||
//
|
//
|
||||||
// This is the main routine that implements a subset of the flexbox layout
|
// This is the main routine that implements a subset of the flexbox layout
|
||||||
// algorithm
|
// algorithm described in the W3C CSS documentation:
|
||||||
// described in the W3C YG documentation: https://www.w3.org/TR/CSS3-flexbox/.
|
// https://www.w3.org/TR/CSS3-flexbox/.
|
||||||
//
|
//
|
||||||
// Limitations of this algorithm, compared to the full standard:
|
// Limitations of this algorithm, compared to the full standard:
|
||||||
// * Display property is always assumed to be 'flex' except for Text nodes,
|
// * Display property is always assumed to be 'flex' except for Text nodes,
|
||||||
// which
|
// which are assumed to be 'inline-flex'.
|
||||||
// are assumed to be 'inline-flex'.
|
|
||||||
// * The 'zIndex' property (or any form of z ordering) is not supported. Nodes
|
// * The 'zIndex' property (or any form of z ordering) is not supported. Nodes
|
||||||
// are
|
// are stacked in document order.
|
||||||
// stacked in document order.
|
|
||||||
// * The 'order' property is not supported. The order of flex items is always
|
// * The 'order' property is not supported. The order of flex items is always
|
||||||
// defined
|
// defined by document order.
|
||||||
// by document order.
|
|
||||||
// * The 'visibility' property is always assumed to be 'visible'. Values of
|
// * The 'visibility' property is always assumed to be 'visible'. Values of
|
||||||
// 'collapse'
|
// 'collapse' and 'hidden' are not supported.
|
||||||
// and 'hidden' are not supported.
|
|
||||||
// * There is no support for forced breaks.
|
// * There is no support for forced breaks.
|
||||||
// * It does not support vertical inline directions (top-to-bottom or
|
// * It does not support vertical inline directions (top-to-bottom or
|
||||||
// bottom-to-top text).
|
// bottom-to-top text).
|
||||||
//
|
//
|
||||||
// Deviations from standard:
|
// Deviations from standard:
|
||||||
// * Section 4.5 of the spec indicates that all flex items have a default
|
// * Section 4.5 of the spec indicates that all flex items have a default
|
||||||
// minimum
|
// minimum main size. For text blocks, for example, this is the width of the
|
||||||
// main size. For text blocks, for example, this is the width of the widest
|
// widest word. Calculating the minimum width is expensive, so we forego it
|
||||||
// word.
|
// and assume a default minimum main size of 0.
|
||||||
// Calculating the minimum width is expensive, so we forego it and assume a
|
|
||||||
// default
|
|
||||||
// minimum main size of 0.
|
|
||||||
// * Min/Max sizes in the main axis are not honored when resolving flexible
|
// * Min/Max sizes in the main axis are not honored when resolving flexible
|
||||||
// lengths.
|
// lengths.
|
||||||
// * The spec indicates that the default value for 'flexDirection' is 'row',
|
// * The spec indicates that the default value for 'flexDirection' is 'row',
|
||||||
// but
|
// but the algorithm below assumes a default of 'column'.
|
||||||
// the algorithm below assumes a default of 'column'.
|
|
||||||
//
|
//
|
||||||
// Input parameters:
|
// Input parameters:
|
||||||
// - node: current node to be sized and layed out
|
// - node: current node to be sized and layed out
|
||||||
// - availableWidth & availableHeight: available size to be used for sizing
|
// - availableWidth & availableHeight: available size to be used for sizing
|
||||||
// the node
|
// the node or YGUndefined if the size is not available; interpretation
|
||||||
// or YGUndefined if the size is not available; interpretation depends on
|
// depends on layout flags
|
||||||
// layout
|
|
||||||
// flags
|
|
||||||
// - ownerDirection: the inline (text) direction within the owner
|
// - ownerDirection: the inline (text) direction within the owner
|
||||||
// (left-to-right or
|
// (left-to-right or right-to-left)
|
||||||
// right-to-left)
|
|
||||||
// - widthMeasureMode: indicates the sizing rules for the width (see below
|
// - widthMeasureMode: indicates the sizing rules for the width (see below
|
||||||
// for explanation)
|
// for explanation)
|
||||||
// - heightMeasureMode: indicates the sizing rules for the height (see below
|
// - heightMeasureMode: indicates the sizing rules for the height (see below
|
||||||
// for explanation)
|
// for explanation)
|
||||||
// - performLayout: specifies whether the caller is interested in just the
|
// - performLayout: specifies whether the caller is interested in just the
|
||||||
// dimensions
|
// dimensions of the node or it requires the entire node and its subtree to
|
||||||
// of the node or it requires the entire node and its subtree to be layed
|
// be layed out (with final positions)
|
||||||
// out
|
|
||||||
// (with final positions)
|
|
||||||
//
|
//
|
||||||
// Details:
|
// Details:
|
||||||
// This routine is called recursively to lay out subtrees of flexbox
|
// This routine is called recursively to lay out subtrees of flexbox
|
||||||
// elements. It uses the
|
// elements. It uses the information in node.style, which is treated as a
|
||||||
// information in node.style, which is treated as a read-only input. It is
|
// read-only input. It is responsible for setting the layout.direction and
|
||||||
// responsible for
|
// layout.measuredDimensions fields for the input node as well as the
|
||||||
// setting the layout.direction and layout.measuredDimensions fields for the
|
// layout.position and layout.lineIndex fields for its child nodes. The
|
||||||
// input node as well
|
|
||||||
// as the layout.position and layout.lineIndex fields for its child nodes.
|
|
||||||
// The
|
|
||||||
// layout.measuredDimensions field includes any border or padding for the
|
// layout.measuredDimensions field includes any border or padding for the
|
||||||
// node but does
|
// node but does not include margins.
|
||||||
// not include margins.
|
|
||||||
//
|
//
|
||||||
// The spec describes four different layout modes: "fill available", "max
|
// The spec describes four different layout modes: "fill available", "max
|
||||||
// content", "min
|
// content", "min content", and "fit content". Of these, we don't use "min
|
||||||
// content",
|
// content" because we don't support default minimum main sizes (see above
|
||||||
// and "fit content". Of these, we don't use "min content" because we don't
|
// for details). Each of our measure modes maps to a layout mode from the
|
||||||
// support default
|
// spec (https://www.w3.org/TR/CSS3-sizing/#terms):
|
||||||
// minimum main sizes (see above for details). Each of our measure modes maps
|
|
||||||
// to a layout mode
|
|
||||||
// from the spec (https://www.w3.org/TR/CSS3-sizing/#terms):
|
|
||||||
// - YGMeasureModeUndefined: max content
|
// - YGMeasureModeUndefined: max content
|
||||||
// - YGMeasureModeExactly: fill available
|
// - YGMeasureModeExactly: fill available
|
||||||
// - YGMeasureModeAtMost: fit content
|
// - YGMeasureModeAtMost: fit content
|
||||||
@@ -2924,9 +2892,9 @@ static void YGNodelayoutImpl(
|
|||||||
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
||||||
|
|
||||||
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
|
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
|
||||||
// Calculate the remaining available space that needs to be allocated.
|
// Calculate the remaining available space that needs to be allocated. If
|
||||||
// If the main dimension size isn't known, it is computed based on
|
// the main dimension size isn't known, it is computed based on the line
|
||||||
// the line length, so there's no more space left to distribute.
|
// length, so there's no more space left to distribute.
|
||||||
|
|
||||||
bool sizeBasedOnContent = false;
|
bool sizeBasedOnContent = false;
|
||||||
// If we don't measure with exact main dimension we want to ensure we don't
|
// If we don't measure with exact main dimension we want to ensure we don't
|
||||||
@@ -2998,11 +2966,9 @@ static void YGNodelayoutImpl(
|
|||||||
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
|
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
|
||||||
|
|
||||||
// At this point, all the children have their dimensions set in the main
|
// At this point, all the children have their dimensions set in the main
|
||||||
// axis.
|
// axis. Their dimensions are also set in the cross axis with the exception
|
||||||
// Their dimensions are also set in the cross axis with the exception of
|
// of items that are aligned "stretch". We need to compute these stretch
|
||||||
// items
|
// values and set the final positions.
|
||||||
// that are aligned "stretch". We need to compute these stretch values and
|
|
||||||
// set the final positions.
|
|
||||||
|
|
||||||
YGJustifyMainAxis(
|
YGJustifyMainAxis(
|
||||||
node,
|
node,
|
||||||
@@ -3058,8 +3024,8 @@ static void YGNodelayoutImpl(
|
|||||||
}
|
}
|
||||||
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
|
||||||
// If the child is absolutely positioned and has a
|
// If the child is absolutely positioned and has a
|
||||||
// top/left/bottom/right set, override
|
// top/left/bottom/right set, override all the previously computed
|
||||||
// all the previously computed positions to set it correctly.
|
// positions to set it correctly.
|
||||||
const bool isChildLeadingPosDefined =
|
const bool isChildLeadingPosDefined =
|
||||||
child->isLeadingPositionDefined(crossAxis);
|
child->isLeadingPositionDefined(crossAxis);
|
||||||
if (isChildLeadingPosDefined) {
|
if (isChildLeadingPosDefined) {
|
||||||
@@ -3090,9 +3056,8 @@ static void YGNodelayoutImpl(
|
|||||||
const YGAlign alignItem = YGNodeAlignItem(node, child);
|
const YGAlign alignItem = YGNodeAlignItem(node, child);
|
||||||
|
|
||||||
// If the child uses align stretch, we need to lay it out one more
|
// If the child uses align stretch, we need to lay it out one more
|
||||||
// time, this time
|
// time, this time forcing the cross-axis size to be the computed
|
||||||
// forcing the cross-axis size to be the computed cross size for the
|
// cross size for the current line.
|
||||||
// current line.
|
|
||||||
if (alignItem == YGAlignStretch &&
|
if (alignItem == YGAlignStretch &&
|
||||||
child->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
child->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
||||||
child->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
child->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
||||||
@@ -3713,8 +3678,8 @@ bool YGNodeCanUseCachedMeasurement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is a wrapper around the YGNodelayoutImpl function. It determines
|
// This is a wrapper around the YGNodelayoutImpl function. It determines whether
|
||||||
// whether the layout request is redundant and can be skipped.
|
// the layout request is redundant and can be skipped.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// Input parameters are the same as YGNodelayoutImpl (see above)
|
// Input parameters are the same as YGNodelayoutImpl (see above)
|
||||||
@@ -3753,16 +3718,12 @@ bool YGLayoutNodeInternal(
|
|||||||
|
|
||||||
// Determine whether the results are already cached. We maintain a separate
|
// Determine whether the results are already cached. We maintain a separate
|
||||||
// cache for layouts and measurements. A layout operation modifies the
|
// cache for layouts and measurements. A layout operation modifies the
|
||||||
// positions
|
// positions and dimensions for nodes in the subtree. The algorithm assumes
|
||||||
// and dimensions for nodes in the subtree. The algorithm assumes that each
|
// that each node gets layed out a maximum of one time per tree layout, but
|
||||||
// node
|
// multiple measurements may be required to resolve all of the flex
|
||||||
// gets layed out a maximum of one time per tree layout, but multiple
|
// dimensions. We handle nodes with measure functions specially here because
|
||||||
// measurements
|
// they are the most expensive to measure, so it's worth avoiding redundant
|
||||||
// may be required to resolve all of the flex dimensions.
|
// measurements if at all possible.
|
||||||
// We handle nodes with measure functions specially here because they are the
|
|
||||||
// most
|
|
||||||
// expensive to measure, so it's worth avoiding redundant measurements if at
|
|
||||||
// all possible.
|
|
||||||
if (node->getMeasure() != nullptr) {
|
if (node->getMeasure() != nullptr) {
|
||||||
const float marginAxisRow =
|
const float marginAxisRow =
|
||||||
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
||||||
@@ -4058,10 +4019,8 @@ void YGNodeCalculateLayout(
|
|||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const YGDirection ownerDirection) {
|
const YGDirection ownerDirection) {
|
||||||
// Increment the generation count. This will force the recursive routine to
|
// Increment the generation count. This will force the recursive routine to
|
||||||
// visit
|
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||||
// all dirty nodes at least once. Subsequent visits will be skipped if the
|
// the input parameters don't change.
|
||||||
// input
|
|
||||||
// parameters don't change.
|
|
||||||
gCurrentGenerationCount++;
|
gCurrentGenerationCount++;
|
||||||
node->resolveDimension();
|
node->resolveDimension();
|
||||||
float width = YGUndefined;
|
float width = YGUndefined;
|
||||||
|
42
yoga/Yoga.h
42
yoga/Yoga.h
@@ -104,16 +104,16 @@ WIN_EXPORT void YGNodeCalculateLayout(
|
|||||||
|
|
||||||
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
||||||
// set.
|
// set.
|
||||||
// YG knows when to mark all other nodes as dirty but because nodes with
|
//
|
||||||
// measure functions
|
// Yoga knows when to mark all other nodes as dirty but because nodes with
|
||||||
// depends on information not known to YG they must perform this dirty
|
// measure functions depend on information not known to Yoga they must perform
|
||||||
// marking manually.
|
// this dirty marking manually.
|
||||||
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
|
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
|
||||||
|
|
||||||
// This function marks the current node and all its descendants as dirty. This
|
// Marks the current node and all its descendants as dirty.
|
||||||
// function is added to test yoga benchmarks. This function is not expected to
|
//
|
||||||
// be used in production as calling `YGCalculateLayout` will cause the
|
// Intended to be used for Uoga benchmarks. Don't use in production, as calling
|
||||||
// recalculation of each and every node.
|
// `YGCalculateLayout` will cause the recalculation of each and every node.
|
||||||
WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node);
|
WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node);
|
||||||
|
|
||||||
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
|
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
|
||||||
@@ -317,20 +317,20 @@ WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(
|
|||||||
const float maxHeight);
|
const float maxHeight);
|
||||||
WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeRef node);
|
WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeRef node);
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification Aspect
|
||||||
// Aspect ratio control the size of the undefined dimension of a node.
|
// ratio control the size of the undefined dimension of a node. Aspect ratio is
|
||||||
// Aspect ratio is encoded as a floating point value width/height. e.g. A value
|
// encoded as a floating point value width/height. e.g. A value of 2 leads to a
|
||||||
// of 2 leads to a node with a width twice the size of its height while a value
|
// node with a width twice the size of its height while a value of 0.5 gives the
|
||||||
// of 0.5 gives the opposite effect.
|
// opposite effect.
|
||||||
//
|
//
|
||||||
// - On a node with a set width/height aspect ratio control the size of the
|
// - On a node with a set width/height aspect ratio control the size of the
|
||||||
// unset dimension
|
// unset dimension
|
||||||
// - On a node with a set flex basis aspect ratio controls the size of the node
|
// - On a node with a set flex basis aspect ratio controls the size of the node
|
||||||
// in the cross axis if unset
|
// in the cross axis if unset
|
||||||
// - On a node with a measure function aspect ratio works as though the measure
|
// - On a node with a measure function aspect ratio works as though the measure
|
||||||
// function measures the flex basis
|
// function measures the flex basis
|
||||||
// - On a node with flex grow/shrink aspect ratio controls the size of the node
|
// - On a node with flex grow/shrink aspect ratio controls the size of the node
|
||||||
// in the cross axis if unset
|
// in the cross axis if unset
|
||||||
// - Aspect ratio takes min/max dimensions into account
|
// - Aspect ratio takes min/max dimensions into account
|
||||||
WIN_EXPORT void YGNodeStyleSetAspectRatio(
|
WIN_EXPORT void YGNodeStyleSetAspectRatio(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
@@ -377,8 +377,8 @@ WIN_EXPORT void YGAssertWithConfig(
|
|||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
const bool condition,
|
const bool condition,
|
||||||
const char* message);
|
const char* message);
|
||||||
// Set this to number of pixels in 1 point to round calculation results
|
// Set this to number of pixels in 1 point to round calculation results If you
|
||||||
// If you want to avoid rounding - set PointScaleFactor to 0
|
// want to avoid rounding - set PointScaleFactor to 0
|
||||||
WIN_EXPORT void YGConfigSetPointScaleFactor(
|
WIN_EXPORT void YGConfigSetPointScaleFactor(
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
const float pixelsInPoint);
|
const float pixelsInPoint);
|
||||||
@@ -409,8 +409,8 @@ WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(
|
|||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
const YGExperimentalFeature feature);
|
const YGExperimentalFeature feature);
|
||||||
|
|
||||||
// Using the web defaults is the prefered configuration for new projects.
|
// Using the web defaults is the prefered configuration for new projects. Usage
|
||||||
// Usage of non web defaults should be considered as legacy.
|
// of non web defaults should be considered as legacy.
|
||||||
WIN_EXPORT void YGConfigSetUseWebDefaults(
|
WIN_EXPORT void YGConfigSetUseWebDefaults(
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
const bool enabled);
|
const bool enabled);
|
||||||
|
Reference in New Issue
Block a user