Files
yoga/yoga/node/LayoutResults.cpp
Andrew Coates e4fe14ab3e Add config version, and invalidate layout on config change (#1674)
Summary:
X-link: https://github.com/facebook/react-native/pull/45259

This is a continuation of the previous PR: https://github.com/facebook/react-native/pull/45047

I made the change more generic for allowing any kind of config change to invalidate layout.

Changelog: [Internal]

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

Reviewed By: rozele

Differential Revision: D59286992

Pulled By: NickGerleman

fbshipit-source-id: f46f35b03d5d9a743b798844ee3e1a02c271ccde
2024-07-03 12:46:18 -07:00

49 lines
1.6 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <cmath>
#include <yoga/node/LayoutResults.h>
#include <yoga/numeric/Comparison.h>
namespace facebook::yoga {
bool LayoutResults::operator==(LayoutResults layout) const {
bool isEqual = yoga::inexactEquals(position_, layout.position_) &&
yoga::inexactEquals(dimensions_, layout.dimensions_) &&
yoga::inexactEquals(margin_, layout.margin_) &&
yoga::inexactEquals(border_, layout.border_) &&
yoga::inexactEquals(padding_, layout.padding_) &&
direction() == layout.direction() &&
hadOverflow() == layout.hadOverflow() &&
lastOwnerDirection == layout.lastOwnerDirection &&
configVersion == layout.configVersion &&
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
cachedLayout == layout.cachedLayout &&
computedFlexBasis == layout.computedFlexBasis;
for (uint32_t i = 0; i < LayoutResults::MaxCachedMeasurements && isEqual;
++i) {
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
}
if (!yoga::isUndefined(measuredDimensions_[0]) ||
!yoga::isUndefined(layout.measuredDimensions_[0])) {
isEqual =
isEqual && (measuredDimensions_[0] == layout.measuredDimensions_[0]);
}
if (!yoga::isUndefined(measuredDimensions_[1]) ||
!yoga::isUndefined(layout.measuredDimensions_[1])) {
isEqual =
isEqual && (measuredDimensions_[1] == layout.measuredDimensions_[1]);
}
return isEqual;
}
} // namespace facebook::yoga