Skip to content

Commit

Permalink
C++ style enums 7/N: MeasureMode (#39452)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39452

X-link: facebook/yoga#1389

This converts usages of YGMeasureMode to MeasureMode

Reviewed By: rozele

Differential Revision: D49271165

fbshipit-source-id: 273c9ed0a61c3965e469548d29d37e4566c974dc
  • Loading branch information
NickGerleman authored and pull[bot] committed Dec 13, 2023
1 parent e5a7551 commit 4475374
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 179 deletions.
8 changes: 4 additions & 4 deletions packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,13 +905,13 @@ bool YGNodeCanUseCachedMeasurement(
float marginColumn,
YGConfigRef config) {
return yoga::canUseCachedMeasurement(
widthMode,
scopedEnum(widthMode),
availableWidth,
heightMode,
scopedEnum(heightMode),
availableHeight,
lastWidthMode,
scopedEnum(lastWidthMode),
lastAvailableWidth,
lastHeightMode,
scopedEnum(lastHeightMode),
lastAvailableHeight,
lastComputedWidth,
lastComputedHeight,
Expand Down
30 changes: 14 additions & 16 deletions packages/react-native/ReactCommon/yoga/yoga/algorithm/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,50 @@
* LICENSE file in the root directory of this source tree.
*/

#include <yoga/Yoga.h>

#include <yoga/algorithm/Cache.h>
#include <yoga/algorithm/PixelGrid.h>
#include <yoga/numeric/Comparison.h>

namespace facebook::yoga {

static inline bool sizeIsExactAndMatchesOldMeasuredSize(
YGMeasureMode sizeMode,
MeasureMode sizeMode,
float size,
float lastComputedSize) {
return sizeMode == YGMeasureModeExactly &&
return sizeMode == MeasureMode::Exactly &&
yoga::inexactEquals(size, lastComputedSize);
}

static inline bool oldSizeIsUnspecifiedAndStillFits(
YGMeasureMode sizeMode,
MeasureMode sizeMode,
float size,
YGMeasureMode lastSizeMode,
MeasureMode lastSizeMode,
float lastComputedSize) {
return sizeMode == YGMeasureModeAtMost &&
lastSizeMode == YGMeasureModeUndefined &&
return sizeMode == MeasureMode::AtMost &&
lastSizeMode == MeasureMode::Undefined &&
(size >= lastComputedSize || yoga::inexactEquals(size, lastComputedSize));
}

static inline bool newMeasureSizeIsStricterAndStillValid(
YGMeasureMode sizeMode,
MeasureMode sizeMode,
float size,
YGMeasureMode lastSizeMode,
MeasureMode lastSizeMode,
float lastSize,
float lastComputedSize) {
return lastSizeMode == YGMeasureModeAtMost &&
sizeMode == YGMeasureModeAtMost && !std::isnan(lastSize) &&
return lastSizeMode == MeasureMode::AtMost &&
sizeMode == MeasureMode::AtMost && !std::isnan(lastSize) &&
!std::isnan(size) && !std::isnan(lastComputedSize) && lastSize > size &&
(lastComputedSize <= size || yoga::inexactEquals(size, lastComputedSize));
}

bool canUseCachedMeasurement(
const YGMeasureMode widthMode,
const MeasureMode widthMode,
const float availableWidth,
const YGMeasureMode heightMode,
const MeasureMode heightMode,
const float availableHeight,
const YGMeasureMode lastWidthMode,
const MeasureMode lastWidthMode,
const float lastAvailableWidth,
const YGMeasureMode lastHeightMode,
const MeasureMode lastHeightMode,
const float lastAvailableHeight,
const float lastComputedWidth,
const float lastComputedHeight,
Expand Down
10 changes: 5 additions & 5 deletions packages/react-native/ReactCommon/yoga/yoga/algorithm/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

#pragma once

#include <yoga/Yoga.h>
#include <yoga/config/Config.h>
#include <yoga/enums/MeasureMode.h>

namespace facebook::yoga {

bool canUseCachedMeasurement(
YGMeasureMode widthMode,
MeasureMode widthMode,
float availableWidth,
YGMeasureMode heightMode,
MeasureMode heightMode,
float availableHeight,
YGMeasureMode lastWidthMode,
MeasureMode lastWidthMode,
float lastAvailableWidth,
YGMeasureMode lastHeightMode,
MeasureMode lastHeightMode,
float lastAvailableHeight,
float lastComputedWidth,
float lastComputedHeight,
Expand Down
Loading

0 comments on commit 4475374

Please sign in to comment.