From 5694a8a4b31560e1a164be3d706e5681c1d38274 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 21 Jan 2025 14:54:45 -0800 Subject: [PATCH] Implement prop diffing for basic props in Summary: This diff implements the diffing for basic props of changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D59972040 --- .../components/view/HostPlatformViewProps.cpp | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp index 352b8274c929db..d46e6425f9c84e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp @@ -145,10 +145,116 @@ folly::dynamic HostPlatformViewProps::getDiffProps( ? &defaultProps : static_cast(prevProps); + if (this == oldProps) { + return result; + } if (focusable != oldProps->focusable) { result["focusable"] = focusable; } + if (hasTVPreferredFocus != oldProps->hasTVPreferredFocus) { + result["hasTVPreferredFocus"] = hasTVPreferredFocus; + } + + if (needsOffscreenAlphaCompositing != + oldProps->needsOffscreenAlphaCompositing) { + result["needsOffscreenAlphaCompositing"] = needsOffscreenAlphaCompositing; + } + + if (renderToHardwareTextureAndroid != + oldProps->renderToHardwareTextureAndroid) { + result["renderToHardwareTextureAndroid"] = renderToHardwareTextureAndroid; + } + + if (opacity != oldProps->opacity) { + result["opacity"] = opacity; + } + + if (backgroundColor != oldProps->backgroundColor) { + result["backgroundColor"] = *backgroundColor; + } + + if (shadowColor != oldProps->shadowColor) { + result["shadowColor"] = *shadowColor; + } + + if (shadowOpacity != oldProps->shadowOpacity) { + result["shadowOpacity"] = shadowOpacity; + } + + if (shadowRadius != oldProps->shadowRadius) { + result["shadowRadius"] = shadowRadius; + } + + if (shouldRasterize != oldProps->shouldRasterize) { + result["shouldRasterize"] = shouldRasterize; + } + + if (collapsable != oldProps->collapsable) { + result["collapsable"] = collapsable; + } + + if (removeClippedSubviews != oldProps->removeClippedSubviews) { + result["removeClippedSubviews"] = removeClippedSubviews; + } + + if (onLayout != oldProps->onLayout) { + result["onLayout"] = onLayout; + } + + if (zIndex != oldProps->zIndex) { + result["zIndex"] = zIndex.value(); + } + + if (pointerEvents != oldProps->pointerEvents) { + std::string value; + switch (pointerEvents) { + case PointerEventsMode::BoxOnly: + result["pointerEvents"] = "box-only"; + break; + case PointerEventsMode::BoxNone: + result["pointerEvents"] = "box-none"; + break; + case PointerEventsMode::None: + result["pointerEvents"] = "none"; + break; + default: + result["pointerEvents"] = "auto"; + break; + } + + if (nativeId != oldProps->nativeId) { + result["nativeId"] = nativeId; + } + + if (testId != oldProps->testId) { + result["testId"] = testId; + } + + if (accessible != oldProps->accessible) { + result["accessible"] = accessible; + } + + if (getClipsContentToBounds() != oldProps->getClipsContentToBounds()) { + result["overflow"] = getClipsContentToBounds() ? "hidden" : "visible"; + result["scroll"] = result["overflow"]; + } + + if (backfaceVisibility != oldProps->backfaceVisibility) { + switch (backfaceVisibility) { + case BackfaceVisibility::Auto: + result["backfaceVisibility"] = "auto"; + break; + case BackfaceVisibility::Visible: + result["backfaceVisibility"] = "visible"; + break; + case BackfaceVisibility::Hidden: + result["backfaceVisibility"] = "hidden"; + break; + } + } + } + return result; }