mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Do not swapLeftAnd right if not in RTL (#38748)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38748 changelog: [internal] Android was setting flag `swapLeftAndRightInRTL` to true regardless if the context was RTL or LTR. This causes unnecessary tree traversal + invalidation of all yoga nodes. This is a completely unnecessary work when layout direction is left to right. To fix this, I made sure Android not longer sets `swapLeftAndRightInRTL` to true and in Fabric we only check the flag for RTL context. Reviewed By: NickGerleman Differential Revision: D47913605 fbshipit-source-id: 1d938b0dc9ba16a73b076f626055055162e3495f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
704efe590c
commit
95e7a74a50
+3
@@ -154,4 +154,7 @@ public class ReactFeatureFlags {
|
||||
|
||||
/** Use native view configs in bridgeless mode. */
|
||||
public static boolean useNativeViewConfigsInBridgelessMode = false;
|
||||
|
||||
/** Only swap left and right on Android in RTL scripts. */
|
||||
public static boolean doNotSwapLeftAndRightOnAndroidInLTR = false;
|
||||
}
|
||||
|
||||
@@ -431,6 +431,8 @@ void Binding::installFabricUIManager(
|
||||
getFeatureFlagValue("enableCppPropsIteratorSetter");
|
||||
CoreFeatures::useNativeState = getFeatureFlagValue("useNativeState");
|
||||
CoreFeatures::enableMapBuffer = getFeatureFlagValue("useMapBufferProps");
|
||||
CoreFeatures::doNotSwapLeftAndRightOnAndroidInLTR =
|
||||
getFeatureFlagValue("doNotSwapLeftAndRightOnAndroidInLTR");
|
||||
|
||||
// RemoveDelete mega-op
|
||||
ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction =
|
||||
|
||||
+10
-2
@@ -17,6 +17,7 @@
|
||||
#include <react/renderer/core/TraitCast.h>
|
||||
#include <react/renderer/debug/DebugStringConvertibleItem.h>
|
||||
#include <react/renderer/debug/SystraceSection.h>
|
||||
#include <react/utils/CoreFeatures.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -550,8 +551,15 @@ void YogaLayoutableShadowNode::layoutTree(
|
||||
|
||||
threadLocalLayoutContext = layoutContext;
|
||||
|
||||
if (layoutContext.swapLeftAndRightInRTL) {
|
||||
swapLeftAndRightInTree(*this);
|
||||
if (CoreFeatures::doNotSwapLeftAndRightOnAndroidInLTR) {
|
||||
if (layoutConstraints.layoutDirection == LayoutDirection::RightToLeft &&
|
||||
layoutContext.swapLeftAndRightInRTL) {
|
||||
swapLeftAndRightInTree(*this);
|
||||
}
|
||||
} else {
|
||||
if (layoutContext.swapLeftAndRightInRTL) {
|
||||
swapLeftAndRightInTree(*this);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -17,5 +17,6 @@ bool CoreFeatures::cacheLastTextMeasurement = false;
|
||||
bool CoreFeatures::cancelImageDownloadsOnRecycle = false;
|
||||
bool CoreFeatures::enableGranularScrollViewStateUpdatesIOS = false;
|
||||
bool CoreFeatures::enableMountHooks = false;
|
||||
bool CoreFeatures::doNotSwapLeftAndRightOnAndroidInLTR = false;
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -50,6 +50,9 @@ class CoreFeatures {
|
||||
|
||||
// Report mount operations from the host platform to notify mount hooks.
|
||||
static bool enableMountHooks;
|
||||
|
||||
// Only swap left and right on Android in RTL scripts.
|
||||
static bool doNotSwapLeftAndRightOnAndroidInLTR;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
Reference in New Issue
Block a user