From d04b1e5a16c07e1d7e3225ea42230a8905f92708 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:52:27 -0700 Subject: [PATCH] Ensure full layout occurs when a system scale change occurs --- .../react/renderer/components/root/RootShadowNode.cpp | 4 +++- .../ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp | 4 +++- .../react-native/ReactCommon/yoga/yoga/node/LayoutResults.cpp | 1 + .../react-native/ReactCommon/yoga/yoga/node/LayoutResults.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/root/RootShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/root/RootShadowNode.cpp index 015366dacc8466..55fe705dec1388 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/root/RootShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/root/RootShadowNode.cpp @@ -49,7 +49,9 @@ RootShadowNode::Unshared RootShadowNode::clone( /* .props = */ props, }); - if (layoutConstraints != getConcreteProps().layoutConstraints) { + if (layoutConstraints != getConcreteProps().layoutConstraints || + layoutContext.pointScaleFactor != + getConcreteProps().layoutContext.pointScaleFactor) { newRootShadowNode->dirtyLayout(); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 58394a4563210b..74c634ab36964b 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -2140,7 +2140,8 @@ bool calculateLayoutInternal( const bool needToVisitNode = (node->isDirty() && layout->generationCount != generationCount) || - layout->lastOwnerDirection != ownerDirection; + layout->lastOwnerDirection != ownerDirection || + layout->lastScale != node->getConfig()->getPointScaleFactor(); if (needToVisitNode) { // Invalidate the cached results. @@ -2255,6 +2256,7 @@ bool calculateLayoutInternal( reason); layout->lastOwnerDirection = ownerDirection; + layout->lastScale = node->getConfig()->getPointScaleFactor(); if (cachedResults == nullptr) { layoutMarkerData.maxMeasureCache = std::max( diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.cpp b/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.cpp index fd70870e65b3a7..d1a8ecc78b5fcf 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.cpp @@ -21,6 +21,7 @@ bool LayoutResults::operator==(LayoutResults layout) const { direction() == layout.direction() && hadOverflow() == layout.hadOverflow() && lastOwnerDirection == layout.lastOwnerDirection && + lastScale == layout.lastScale && nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex && cachedLayout == layout.cachedLayout && computedFlexBasis == layout.computedFlexBasis; diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.h b/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.h index f42c27795c107d..bec3d1293d4661 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.h +++ b/packages/react-native/ReactCommon/yoga/yoga/node/LayoutResults.h @@ -31,6 +31,7 @@ struct LayoutResults { // information to break early when nothing changed uint32_t generationCount = 0; Direction lastOwnerDirection = Direction::Inherit; + float lastScale = 1.0f; uint32_t nextCachedMeasurementsIndex = 0; std::array cachedMeasurements = {};