Use CSS terminology for sizing rules (#1460)

Summary:
X-link: https://github.com/facebook/react-native/pull/41390

Pull Request resolved: https://github.com/facebook/yoga/pull/1460

Yoga passes `MeasureMode`/`YGMeasureMode` to express constraints in how a box should be measured, given definite or indefinite available space.

This is modeled after Android [MeasureSpec](https://developer.android.com/reference/android/view/View.MeasureSpec), with a table above `calculateLayoutImpl()` explaining the CSS terms they map to. This can be confusing when flipping between the spec, and code.

This switches internal usages to the CSS terms, but leaves around `YGMeasureMode` since it is the public API passed to measure functions.

Reviewed By: joevilches

Differential Revision: D51068417

fbshipit-source-id: 0a76266a4e7e0cc39996164607229c3c41de2818
This commit is contained in:
Nick Gerleman
2023-11-25 20:41:22 -08:00
committed by Facebook GitHub Bot
parent aca02406ef
commit a121483e81
9 changed files with 351 additions and 268 deletions

View File

@@ -11,7 +11,7 @@
#include <yoga/Yoga.h>
#include <yoga/enums/MeasureMode.h>
#include <yoga/algorithm/SizingMode.h>
#include <yoga/numeric/Comparison.h>
namespace facebook::yoga {
@@ -19,15 +19,15 @@ namespace facebook::yoga {
struct CachedMeasurement {
float availableWidth{-1};
float availableHeight{-1};
MeasureMode widthMeasureMode{MeasureMode::Undefined};
MeasureMode heightMeasureMode{MeasureMode::Undefined};
SizingMode widthSizingMode{SizingMode::MaxContent};
SizingMode heightSizingMode{SizingMode::MaxContent};
float computedWidth{-1};
float computedHeight{-1};
bool operator==(CachedMeasurement measurement) const {
bool isEqual = widthMeasureMode == measurement.widthMeasureMode &&
heightMeasureMode == measurement.heightMeasureMode;
bool isEqual = widthSizingMode == measurement.widthSizingMode &&
heightSizingMode == measurement.heightSizingMode;
if (!yoga::isUndefined(availableWidth) ||
!yoga::isUndefined(measurement.availableWidth)) {