diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.cpp b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.cpp index 687ee314402e75..5bf85f4a1b82df 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.cpp @@ -59,10 +59,22 @@ void YGConfig::setErrata(YGErrata errata) { errata_ = errata; } +void YGConfig::addErrata(YGErrata errata) { + errata_ |= errata; +} + +void YGConfig::removeErrata(YGErrata errata) { + errata_ &= (~errata); +} + YGErrata YGConfig::getErrata() const { return errata_; } +bool YGConfig::hasErrata(YGErrata errata) const { + return (errata_ & errata) != YGErrataNone; +} + void YGConfig::setPointScaleFactor(float pointScaleFactor) { pointScaleFactor_ = pointScaleFactor; } diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h index 5f82e3f22910e2..d7c7f49fde979f 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h +++ b/packages/react-native/ReactCommon/yoga/yoga/YGConfig.h @@ -67,7 +67,10 @@ struct YOGA_EXPORT YGConfig { facebook::yoga::ExperimentalFeatureSet getEnabledExperiments() const; void setErrata(YGErrata errata); + void addErrata(YGErrata errata); + void removeErrata(YGErrata errata); YGErrata getErrata() const; + bool hasErrata(YGErrata errata) const; void setPointScaleFactor(float pointScaleFactor); float getPointScaleFactor() const; diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGNode.h b/packages/react-native/ReactCommon/yoga/yoga/YGNode.h index 6f9cab38e5b9c3..e3c202f2b9f684 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGNode.h +++ b/packages/react-native/ReactCommon/yoga/yoga/YGNode.h @@ -118,6 +118,8 @@ struct YOGA_EXPORT YGNode { float baseline(float width, float height, void* layoutContext); + bool hasErrata(YGErrata errata) const { return config_->hasErrata(errata); } + YGDirtiedFunc getDirtied() const { return dirtied_; } // For Performance reasons passing as reference. diff --git a/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp b/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp index bf30d41cdb7dfe..1eccddbd0f99a8 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp @@ -2984,7 +2984,7 @@ static void YGNodelayoutImpl( availableInnerMainDim = maxInnerMainDim; } else { bool useLegacyStretchBehaviour = - node->getConfig()->getErrata() & YGErrataStretchFlexBasis; + node->hasErrata(YGErrataStretchFlexBasis); if (!useLegacyStretchBehaviour && ((!YGFloatIsUndefined( @@ -4313,16 +4313,16 @@ YOGA_EXPORT void YGConfigSetUseWebDefaults( YOGA_EXPORT bool YGConfigGetUseLegacyStretchBehaviour( const YGConfigRef config) { - return config->getErrata() & YGErrataStretchFlexBasis; + return config->hasErrata(YGErrataStretchFlexBasis); } YOGA_EXPORT void YGConfigSetUseLegacyStretchBehaviour( const YGConfigRef config, const bool useLegacyStretchBehaviour) { if (useLegacyStretchBehaviour) { - config->setErrata(config->getErrata() | YGErrataStretchFlexBasis); + config->addErrata(YGErrataStretchFlexBasis); } else { - config->setErrata(config->getErrata() & ~YGErrataStretchFlexBasis); + config->removeErrata(YGErrataStretchFlexBasis); } }