From 829e6636739a376207ede597984395122726b567 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 28 Sep 2026 03:15:53 -0700 Subject: [PATCH] Kitchen sink changes Summary: Disclaimer: Brought by vibing with Gemini. ## Changelog: [Internal] - Typos X-link: https://github.com/react/yoga/pull/2030 Reviewed By: javache Differential Revision: D122122336 Pulled By: cipolleschi --- .../ReactCommon/yoga/yoga/YGConfig.h | 2 +- .../ReactCommon/yoga/yoga/YGMacros.h | 4 +- .../yoga/yoga/algorithm/AbsoluteLayout.cpp | 2 +- .../yoga/yoga/algorithm/CalculateLayout.cpp | 6 +-- .../yoga/yoga/algorithm/FlexLine.h | 4 +- .../yoga/yoga/algorithm/PixelGrid.cpp | 37 ++++++++++--------- .../ReactCommon/yoga/yoga/node/Node.cpp | 2 +- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h index 12f6e204ada4..215eab6da513 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h +++ b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h @@ -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. diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGMacros.h b/packages/react-native/ReactCommon/yoga/yoga/YGMacros.h index ab9b2627a452..d7ee31b65223 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGMacros.h +++ b/packages/react-native/ReactCommon/yoga/yoga/YGMacros.h @@ -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 diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp index a7d15773fc64..8b0873a5c8a2 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp @@ -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 = diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 168447bdd748..e8998c0693c2 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -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, diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/FlexLine.h b/packages/react-native/ReactCommon/yoga/yoga/algorithm/FlexLine.h index 3f2ef2f17b2e..89983ab95d07 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/FlexLine.h +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/FlexLine.h @@ -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, diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp index 5c5a3b7ffbaf..754a10b3a1e7 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp @@ -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 <= @@ -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); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp index 692d33d9c4a1..161c1900ecdf 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp @@ -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;