fix missing invalidation if owner has undefinied dims

This commit is contained in:
Lukas Wöhrl
2020-06-11 21:21:20 +02:00
parent ede65bbce4
commit ab1ed0c320
3 changed files with 41 additions and 1 deletions

View File

@@ -38,6 +38,9 @@ public:
uint32_t generationCount = 0;
YGDirection lastOwnerDirection = YGDirectionInherit;
bool lastOwnerHadUndefinedHeight = false;
bool lastOwnerHadUndefinedWidth = false;
uint32_t nextCachedMeasurementsIndex = 0;
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
cachedMeasurements = {};

View File

@@ -3811,9 +3811,14 @@ bool YGLayoutNodeInternal(
depth++;
bool ownerHasUndefinedHeight = YGFloatIsUndefined(ownerHeight);
bool ownerHasUndefinedWidth = YGFloatIsUndefined(ownerWidth);
const bool needToVisitNode =
(node->isDirty() && layout->generationCount != generationCount) ||
layout->lastOwnerDirection != ownerDirection;
layout->lastOwnerDirection != ownerDirection ||
layout->lastOwnerHadUndefinedHeight != ownerHasUndefinedHeight||
layout->lastOwnerHadUndefinedWidth != ownerHasUndefinedWidth;
if (needToVisitNode) {
// Invalidate the cached results.
@@ -3995,6 +4000,8 @@ bool YGLayoutNodeInternal(
}
layout->lastOwnerDirection = ownerDirection;
layout->lastOwnerHadUndefinedHeight = ownerHasUndefinedHeight;
layout->lastOwnerHadUndefinedWidth = ownerHasUndefinedWidth;
if (cachedResults == nullptr) {
if (layout->nextCachedMeasurementsIndex + 1 >