Remove the use of legacy flag and log the diff if its used
Summary: Check if the layout tree is different if we do not use legacy flags. If they are different then report to the client Reviewed By: emilsjolander Differential Revision: D6856812 fbshipit-source-id: e4724d80702cc75c1894e348e137b24e663573d2
This commit is contained in:
committed by
Facebook Github Bot
parent
66045bd13d
commit
63be3ff84c
@@ -44,7 +44,7 @@ bool YGValueArrayEqual(
|
||||
return areEqual;
|
||||
}
|
||||
|
||||
typedef struct YGCachedMeasurement {
|
||||
struct YGCachedMeasurement {
|
||||
float availableWidth;
|
||||
float availableHeight;
|
||||
YGMeasureMode widthMeasureMode;
|
||||
@@ -52,7 +52,35 @@ typedef struct YGCachedMeasurement {
|
||||
|
||||
float computedWidth;
|
||||
float computedHeight;
|
||||
} YGCachedMeasurement;
|
||||
|
||||
bool operator==(YGCachedMeasurement measurement) const {
|
||||
bool isEqual = widthMeasureMode == measurement.widthMeasureMode &&
|
||||
heightMeasureMode == measurement.heightMeasureMode;
|
||||
|
||||
if (!std::isnan(availableWidth) ||
|
||||
!std::isnan(measurement.availableWidth)) {
|
||||
isEqual = isEqual && availableWidth == measurement.availableWidth;
|
||||
}
|
||||
if (!std::isnan(availableHeight) ||
|
||||
!std::isnan(measurement.availableHeight)) {
|
||||
isEqual = isEqual && availableHeight == measurement.availableHeight;
|
||||
}
|
||||
if (!std::isnan(computedWidth) || !std::isnan(measurement.computedWidth)) {
|
||||
isEqual = isEqual && computedWidth == measurement.computedWidth;
|
||||
}
|
||||
if (!std::isnan(
|
||||
computedHeight || !std::isnan(measurement.computedHeight))) {
|
||||
isEqual = isEqual && computedHeight == measurement.computedHeight;
|
||||
}
|
||||
|
||||
return availableWidth == measurement.availableWidth &&
|
||||
availableHeight == measurement.availableHeight &&
|
||||
widthMeasureMode == measurement.widthMeasureMode &&
|
||||
heightMeasureMode == measurement.heightMeasureMode &&
|
||||
computedWidth == measurement.computedWidth &&
|
||||
computedHeight == measurement.computedHeight;
|
||||
}
|
||||
};
|
||||
|
||||
// This value was chosen based on empiracle data. Even the most complicated
|
||||
// layouts should not require more than 16 entries to fit within the cache.
|
||||
@@ -80,6 +108,44 @@ struct YGLayout {
|
||||
std::array<float, 2> measuredDimensions;
|
||||
|
||||
YGCachedMeasurement cachedLayout;
|
||||
bool didUseLegacyFlag;
|
||||
bool doesLegacyStretchFlagAffectsLayout;
|
||||
|
||||
bool operator==(YGLayout layout) const {
|
||||
bool isEqual = position == layout.position &&
|
||||
dimensions == layout.dimensions && margin == layout.margin &&
|
||||
border == layout.border && padding == layout.padding &&
|
||||
direction == layout.direction && hadOverflow == layout.hadOverflow &&
|
||||
lastParentDirection == layout.lastParentDirection &&
|
||||
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
|
||||
cachedLayout == layout.cachedLayout;
|
||||
|
||||
for (uint32_t i = 0; i < YG_MAX_CACHED_RESULT_COUNT && isEqual; ++i) {
|
||||
isEqual =
|
||||
isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
||||
}
|
||||
|
||||
if (!YGFloatIsUndefined(computedFlexBasis) ||
|
||||
!YGFloatIsUndefined(layout.computedFlexBasis)) {
|
||||
isEqual = isEqual && (computedFlexBasis == layout.computedFlexBasis);
|
||||
}
|
||||
if (!YGFloatIsUndefined(measuredDimensions[0]) ||
|
||||
!YGFloatIsUndefined(layout.measuredDimensions[0])) {
|
||||
isEqual =
|
||||
isEqual && (measuredDimensions[0] == layout.measuredDimensions[0]);
|
||||
}
|
||||
if (!YGFloatIsUndefined(measuredDimensions[1]) ||
|
||||
!YGFloatIsUndefined(layout.measuredDimensions[1])) {
|
||||
isEqual =
|
||||
isEqual && (measuredDimensions[1] == layout.measuredDimensions[1]);
|
||||
}
|
||||
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
bool operator!=(YGLayout layout) const {
|
||||
return !(*this == layout);
|
||||
}
|
||||
};
|
||||
|
||||
struct YGStyle {
|
||||
@@ -150,7 +216,7 @@ struct YGStyle {
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct YGConfig {
|
||||
struct YGConfig {
|
||||
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
|
||||
bool useWebDefaults;
|
||||
bool useLegacyStretchBehaviour;
|
||||
@@ -158,7 +224,7 @@ typedef struct YGConfig {
|
||||
YGLogger logger;
|
||||
YGNodeClonedFunc cloneNodeCallback;
|
||||
void* context;
|
||||
} YGConfig;
|
||||
};
|
||||
|
||||
#define YG_UNDEFINED_VALUES \
|
||||
{ .value = YGUndefined, .unit = YGUnitUndefined }
|
||||
@@ -272,6 +338,8 @@ static const YGLayout gYGNodeLayoutDefaults = {
|
||||
.computedWidth = -1,
|
||||
.computedHeight = -1,
|
||||
},
|
||||
.didUseLegacyFlag = false,
|
||||
.doesLegacyStretchFlagAffectsLayout = false,
|
||||
};
|
||||
|
||||
extern bool YGFloatsEqual(const float a, const float b);
|
||||
|
Reference in New Issue
Block a user