Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/yoga/yoga/YGConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ YG_EXPORT bool YGConfigGetUseWebDefaults(YGConfigConstRef config);

/**
* Yoga will by default round final layout positions and dimensions to the
* nearst point. `pointScaleFactor` controls the density of the grid used for
* nearest point. `pointScaleFactor` controls the density of the grid used for
* layout rounding (e.g. to round to the closest display pixel).
*
* May be set to 0.0f to avoid rounding the layout results.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/YGMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

#ifdef NS_ENUM
// Cannot use NSInteger as NSInteger has a different size than int (which is the
// default type of a enum). Therefor when linking the Yoga C library into obj-c
// the header is a mismatch for the Yoga ABI.
// default type of an enum). Therefore when linking the Yoga C library into
// obj-c the header is a mismatch for the Yoga ABI.
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
#define YG_ENUM_END(name)
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ bool layoutAbsoluteDescendants(
// which are positioned relative to the current containing block instead
// of their parent. "child" may not be dirty, or have new constraints, so
// absolute positioning may be the first time during this layout pass that
// we need to mutate these descendents. Make sure the path of
// we need to mutate these descendants. Make sure the path of
// nodes to them is mutable before positioning.
child->cloneChildrenIfNeeded();
const Direction childDirection =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,9 +1263,9 @@ static float distributeFreeSpaceSecondPass(
return deltaFreeSpace;
}

// It distributes the free space to the flexible items.For those flexible items
// whose min and max constraints are triggered, those flex item's clamped size
// is removed from the remaingfreespace.
// It distributes the free space to the flexible items. For those flexible items
// whose min and max constraints are triggered, that flex item's clamped size
// is removed from the remainingFreeSpace.
static void distributeFreeSpaceFirstPass(
yoga::Node* const node,
FlexLine& flexLine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ struct FlexLine {
};

// Calculates where a line starting at a given index should break, returning
// information about the collective children on the liune.
// information about the collective children on the line.
//
// 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 the
// computeFlexBasisForChildren function).
FlexLine calculateFlexLine(
yoga::Node* node,
Expand Down
37 changes: 19 additions & 18 deletions packages/react-native/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ float roundValueToPixelGrid(
const bool forceCeil,
const bool forceFloor) {
double scaledValue = value * pointScaleFactor;
// We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
// - fractial`.
double fractial = fmod(scaledValue, 1.0);
if (fractial < 0) {
// We want to calculate `fractional` such that `floor(scaledValue) =
// scaledValue
// - fractional`.
double fractional = fmod(scaledValue, 1.0);
if (fractional < 0) {
// This branch is for handling negative numbers for `value`.
//
// Regarding `floor` and `ceil`. Note that for a number x, `floor(x) <= x <=
Expand All @@ -31,29 +32,29 @@ float roundValueToPixelGrid(
//
// Regarding `fmodf`. For fractional negative numbers, `fmodf` returns a
// negative number. For example, `fmodf(-2.2) = -0.2`. However, we want
// `fractial` to be the number such that subtracting it from `value` will
// `fractional` to be the number such that subtracting it from `value` will
// give us `floor(value)`. In the case of negative numbers, adding 1 to
// `fmodf(value)` gives us this. Let's continue the example from above:
// - fractial = fmodf(-2.2) = -0.2
// - Add 1 to the fraction: fractial2 = fractial + 1 = -0.2 + 1 = 0.8
// - Finding the `floor`: -2.2 - fractial2 = -2.2 - 0.8 = -3
++fractial;
// - fractional = fmodf(-2.2) = -0.2
// - Add 1 to the fraction: fractional2 = fractional + 1 = -0.2 + 1 = 0.8
// - Finding the `floor`: -2.2 - fractional2 = -2.2 - 0.8 = -3
++fractional;
}
if (yoga::inexactEquals(fractial, 0)) {
if (yoga::inexactEquals(fractional, 0)) {
// First we check if the value is already rounded
scaledValue = scaledValue - fractial;
} else if (yoga::inexactEquals(fractial, 1.0)) {
scaledValue = scaledValue - fractial + 1.0;
scaledValue = scaledValue - fractional;
} else if (yoga::inexactEquals(fractional, 1.0)) {
scaledValue = scaledValue - fractional + 1.0;
} else if (forceCeil) {
// Next we check if we need to use forced rounding
scaledValue = scaledValue - fractial + 1.0;
scaledValue = scaledValue - fractional + 1.0;
} else if (forceFloor) {
scaledValue = scaledValue - fractial;
scaledValue = scaledValue - fractional;
} else {
// Finally we just round the value
scaledValue = scaledValue - fractial +
(!std::isnan(fractial) &&
(fractial > 0.5 || yoga::inexactEquals(fractial, 0.5))
scaledValue = scaledValue - fractional +
(!std::isnan(fractional) &&
(fractional > 0.5 || yoga::inexactEquals(fractional, 0.5))
? 1.0
: 0.0);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void Node::setPosition(
const Direction direction,
const float ownerWidth,
const float ownerHeight) {
/* Root nodes should be always layouted as LTR, so we don't return negative
/* Root nodes should always be laid out as LTR, so we don't return negative
* values. */
const Direction directionRespectingRoot =
owner_ != nullptr ? direction : Direction::LTR;
Expand Down
Loading