Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1402 X-link: https://github.com/facebook/react-native/pull/39567 This change hides away most usages of YGDimension as an index. We do this for a couple reasons: 1. Right now the style interface may return a full array of resolved edge or dimension values, as a CompactValue. As we abstract away from CompactValue, and move towards ValuePool, this will no longer be the internal interface, and cheap to return. We instead change the interface to return a single value at once, which lets us resolve values lazily. 2. As we move internal usage to scoped enums, enums are not implicitly convertible to intergers (broadly a good thing). Hiding the enum as index prevents the need for callers to cast or convert to underlying. Instead of making a new version of `IdxRef` for this, I converted to a more traditional setter. I will be making similar changes later for other styles, when I hide CompactValue from the public interface. To review I would recommend filtering to changes in `xplat`, or viewing this in a single one of the OSS PRs exported. Everything apart from the below 20 files is a mirror. {F1096792573} Changelog: [Internal] Reviewed By: javache Differential Revision: D49362819 fbshipit-source-id: 30d730d78e62f36597d43f477120f65694e51ea3
48 lines
1.6 KiB
C++
48 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 &&
|
|
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
|