Skip to content

Commit 283b8a9

Browse files
coadometa-codesync[bot]
authored andcommitted
Seal renderer Graphics public boundary
Summary: Keep the CSS-free color parsing helpers (`parsePlatformColorFn`, `fromRawValueShared`, and `parsePlatformColor`) in the public Graphics API so the platform `fromRawValue` wrappers remain inline. Move `hashGetColourArguments` and `configurePlatformColorCacheInvalidationHook` into private implementation scope, and remove unsupported dormant parser headers from the React Native macOS mirror. Stop exporting CSS, fbjni, and the Android cache library from the Buck target, and express implementation-only dependencies privately in Buck and CMake. The retained shared helper header depends only on `RawValue`, `Color`, and `ContextContainer`; CSS parsing headers remain confined to the implementation file. Regenerate C++ API snapshots to remove the private hash and cache declarations while retaining the public color parser helpers and inline `fromRawValue` entry point. Changelog: [Internal] Differential Revision: D119500886
1 parent 131864c commit 283b8a9

9 files changed

Lines changed: 30 additions & 66 deletions

File tree

packages/react-native/ReactCommon/react/renderer/graphics/CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ target_include_directories(react_renderer_graphics INTERFACE ${REACT_COMMON_DIR}
2727

2828
react_native_android_selector(fbjni fbjni "")
2929
target_link_libraries(react_renderer_graphics
30-
glog
31-
${fbjni}
32-
folly_runtime
33-
react_cxxstableapi
34-
react_debug
35-
react_renderer_css
36-
react_renderer_debug
37-
react_utils
30+
PUBLIC
31+
${fbjni}
32+
folly_runtime
33+
react_cxxstableapi
34+
react_renderer_debug
35+
react_utils
36+
PRIVATE
37+
glog
38+
react_debug
39+
react_featureflags
40+
react_renderer_css
3841
)
3942
target_compile_reactnative_options(react_renderer_graphics PRIVATE)
4043
target_compile_options(react_renderer_graphics PRIVATE -Wpedantic)

packages/react-native/ReactCommon/react/renderer/graphics/React/Graphics.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
#include <react/renderer/graphics/fromRawValueShared.h>
5656
#include <react/renderer/graphics/rounding.h>
5757

58-
#ifdef ANDROID
59-
#include <react/renderer/graphics/configurePlatformColorCacheInvalidationHook.h>
60-
#endif
61-
6258
#if defined(__APPLE__) && defined(__OBJC__)
6359
#include <react/renderer/graphics/RCTPlatformColorUtils.h>
6460
#endif

packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
#include <react/renderer/graphics/PlatformColorParser.h>
99

10-
#include "configurePlatformColorCacheInvalidationHook.h"
11-
10+
#include <fbjni/NativeRunnable.h>
1211
#include <fbjni/fbjni.h>
1312
#include <folly/container/EvictingCacheMap.h>
1413
#include <react/renderer/css/CSSColor.h>
@@ -20,6 +19,22 @@
2019

2120
namespace facebook::react {
2221

22+
namespace {
23+
24+
void configurePlatformColorCacheInvalidationHook(std::function<void()>&& hook) {
25+
auto appearanceModuleClass = jni::findClassLocal(
26+
"com/facebook/react/modules/appearance/AppearanceModule");
27+
if (appearanceModuleClass) {
28+
auto callbackField =
29+
appearanceModuleClass->getStaticField<jni::JRunnable::javaobject>(
30+
"invalidatePlatformColorCache");
31+
jni::local_ref<jni::JRunnable> invalidationCallback =
32+
jni::JNativeRunnable::newObjectCxxArgs(std::move(hook));
33+
appearanceModuleClass->setStaticFieldValue(
34+
callbackField, invalidationCallback.get());
35+
}
36+
}
37+
2338
size_t hashGetColourArguments(
2439
int32_t surfaceId,
2540
const std::vector<std::string>& resourcePaths) {
@@ -31,6 +46,8 @@ size_t hashGetColourArguments(
3146
return seed;
3247
}
3348

49+
} // namespace
50+
3451
SharedColor parsePlatformColor(
3552
const ContextContainer& contextContainer,
3653
int32_t surfaceId,

packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
#include <react/renderer/graphics/Color.h>
1313
#include <react/renderer/graphics/fromRawValueShared.h>
1414
#include <react/utils/ContextContainer.h>
15-
#include <cstddef>
16-
#include <string>
17-
#include <vector>
1815

1916
namespace facebook::react {
2017

21-
size_t hashGetColourArguments(int32_t surfaceId, const std::vector<std::string> &resourcePaths);
22-
2318
SharedColor parsePlatformColor(const ContextContainer &contextContainer, int32_t surfaceId, const RawValue &value);
2419

2520
inline void

packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/configurePlatformColorCacheInvalidationHook.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/configurePlatformColorCacheInvalidationHook.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ size_t facebook::react::attributedStringFragmentHashDisplayWise(const facebook::
943943
size_t facebook::react::attributedStringFragmentHashLayoutWise(const facebook::react::AttributedString::Fragment& fragment);
944944
size_t facebook::react::attributedStringHashDisplayWise(const facebook::react::AttributedString& attributedString);
945945
size_t facebook::react::attributedStringHashLayoutWise(const facebook::react::AttributedString& attributedString);
946-
size_t facebook::react::hashGetColourArguments(int32_t surfaceId, const std::vector<std::string>& resourcePaths);
947946
size_t facebook::react::textAttributesHashLayoutWise(const facebook::react::TextAttributes& textAttributes);
948947
std::function<void(folly::dynamic)> facebook::react::makeCallback(std::weak_ptr<facebook::react::Instance> instance, const folly::dynamic& callbackId);
949948
std::optional<facebook::react::BlendMode> facebook::react::blendModeFromString(std::string_view blendModeName);
@@ -1073,7 +1072,6 @@ void facebook::react::bindHasComponentProvider(facebook::jsi::Runtime& runtime,
10731072
void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger);
10741073
void facebook::react::bindNativePerformanceNow(facebook::jsi::Runtime& runtime);
10751074
void facebook::react::cloneProp(facebook::react::BaseViewProps& viewProps, const facebook::react::AnimatedPropBase& animatedProp);
1076-
void facebook::react::configurePlatformColorCacheInvalidationHook(std::function<void()>&& hook);
10771075
void facebook::react::defineReadOnlyGlobal(facebook::jsi::Runtime& runtime, const std::string& propName, facebook::jsi::Value&& value);
10781076
void facebook::react::ensureThreadDurationJNIEnvAttached();
10791077
void facebook::react::fromRawValue(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result);

scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,6 @@ size_t facebook::react::attributedStringFragmentHashDisplayWise(const facebook::
942942
size_t facebook::react::attributedStringFragmentHashLayoutWise(const facebook::react::AttributedString::Fragment& fragment);
943943
size_t facebook::react::attributedStringHashDisplayWise(const facebook::react::AttributedString& attributedString);
944944
size_t facebook::react::attributedStringHashLayoutWise(const facebook::react::AttributedString& attributedString);
945-
size_t facebook::react::hashGetColourArguments(int32_t surfaceId, const std::vector<std::string>& resourcePaths);
946945
size_t facebook::react::textAttributesHashLayoutWise(const facebook::react::TextAttributes& textAttributes);
947946
std::optional<facebook::react::BlendMode> facebook::react::blendModeFromString(std::string_view blendModeName);
948947
std::optional<facebook::react::BoxShadow> facebook::react::fromCSSShadow(const facebook::react::CSSShadow& cssShadow);
@@ -1069,7 +1068,6 @@ void facebook::react::bindHasComponentProvider(facebook::jsi::Runtime& runtime,
10691068
void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger);
10701069
void facebook::react::bindNativePerformanceNow(facebook::jsi::Runtime& runtime);
10711070
void facebook::react::cloneProp(facebook::react::BaseViewProps& viewProps, const facebook::react::AnimatedPropBase& animatedProp);
1072-
void facebook::react::configurePlatformColorCacheInvalidationHook(std::function<void()>&& hook);
10731071
void facebook::react::defineReadOnlyGlobal(facebook::jsi::Runtime& runtime, const std::string& propName, facebook::jsi::Value&& value);
10741072
void facebook::react::ensureThreadDurationJNIEnvAttached();
10751073
void facebook::react::fromRawValue(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result);

scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ size_t facebook::react::attributedStringFragmentHashDisplayWise(const facebook::
943943
size_t facebook::react::attributedStringFragmentHashLayoutWise(const facebook::react::AttributedString::Fragment& fragment);
944944
size_t facebook::react::attributedStringHashDisplayWise(const facebook::react::AttributedString& attributedString);
945945
size_t facebook::react::attributedStringHashLayoutWise(const facebook::react::AttributedString& attributedString);
946-
size_t facebook::react::hashGetColourArguments(int32_t surfaceId, const std::vector<std::string>& resourcePaths);
947946
size_t facebook::react::textAttributesHashLayoutWise(const facebook::react::TextAttributes& textAttributes);
948947
std::function<void(folly::dynamic)> facebook::react::makeCallback(std::weak_ptr<facebook::react::Instance> instance, const folly::dynamic& callbackId);
949948
std::optional<facebook::react::BlendMode> facebook::react::blendModeFromString(std::string_view blendModeName);
@@ -1073,7 +1072,6 @@ void facebook::react::bindHasComponentProvider(facebook::jsi::Runtime& runtime,
10731072
void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger);
10741073
void facebook::react::bindNativePerformanceNow(facebook::jsi::Runtime& runtime);
10751074
void facebook::react::cloneProp(facebook::react::BaseViewProps& viewProps, const facebook::react::AnimatedPropBase& animatedProp);
1076-
void facebook::react::configurePlatformColorCacheInvalidationHook(std::function<void()>&& hook);
10771075
void facebook::react::defineReadOnlyGlobal(facebook::jsi::Runtime& runtime, const std::string& propName, facebook::jsi::Value&& value);
10781076
void facebook::react::ensureThreadDurationJNIEnvAttached();
10791077
void facebook::react::fromRawValue(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result);

0 commit comments

Comments
 (0)