Skip to content

Commit b3e239b

Browse files
coadofacebook-github-bot
authored andcommitted
Keep ImageManager primitives free of private debug headers
Summary: The public `react/renderer/imagemanager/primitives.h` header included the private `react/renderer/debug/debugStringConvertibleUtils.h` for the inline body of `ImageSource::getDebugProps()`. Because the include was unconditional, any strict consumer of `<React/ImageManager.h>` or `<React/Image.h>` (which reaches `primitives.h` through the Image event emitter) hit the private header guard and failed to compile. Include the public `DebugStringConvertible.h` and `flags.h` headers instead, which provide `SharedDebugStringConvertibleList` and `RN_DEBUG_STRING_CONVERTIBLE`, and keep only the `getDebugProps()` declaration in the header under the existing `RN_DEBUG_STRING_CONVERTIBLE` guard. Move its unchanged implementation into a new `primitives.cpp`, the only place that needs the private debug helpers. Buck, CMake, and CocoaPods already compile every `imagemanager/*.cpp`, so no build-file changes are needed. Changelog: [Internal] Differential Revision: D122534446
1 parent 217ee34 commit b3e239b

2 files changed

Lines changed: 52 additions & 22 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include <react/renderer/imagemanager/primitives.h>
9+
10+
#if RN_DEBUG_STRING_CONVERTIBLE
11+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
12+
#endif
13+
14+
namespace facebook::react {
15+
16+
#if RN_DEBUG_STRING_CONVERTIBLE
17+
SharedDebugStringConvertibleList ImageSource::getDebugProps(
18+
const std::string& prefix) const {
19+
ImageSource imageSource{};
20+
21+
SharedDebugStringConvertibleList headersList;
22+
for (const auto& header : headers) {
23+
headersList.push_back(debugStringConvertibleItem(
24+
prefix + "-header-" + header.first, header.second));
25+
}
26+
27+
return headersList +
28+
SharedDebugStringConvertibleList{
29+
debugStringConvertibleItem(
30+
prefix + "-type", toString(type), toString(imageSource.type)),
31+
debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri),
32+
debugStringConvertibleItem(
33+
prefix + "-bundle", bundle, imageSource.bundle),
34+
debugStringConvertibleItem(
35+
prefix + "-scale", scale, imageSource.scale),
36+
debugStringConvertibleItem(
37+
prefix + "-size",
38+
react::toString(size),
39+
react::toString(imageSource.size)),
40+
debugStringConvertibleItem(prefix + "-body", body, imageSource.body),
41+
debugStringConvertibleItem(
42+
prefix + "-method", method, imageSource.method),
43+
debugStringConvertibleItem(
44+
prefix + "-cache", toString(cache), toString(imageSource.cache)),
45+
};
46+
}
47+
#endif
48+
49+
} // namespace facebook::react

‎packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include <react/debug/react_native_assert.h>
1616
#include <react/renderer/core/graphicsConversions.h>
1717
#include <react/renderer/core/propsConversions.h>
18-
#include <react/renderer/debug/debugStringConvertibleUtils.h>
18+
#include <react/renderer/debug/DebugStringConvertible.h>
19+
#include <react/renderer/debug/flags.h>
1920
#include <react/renderer/graphics/Float.h>
2021
#include <react/renderer/graphics/Size.h>
2122

@@ -97,27 +98,7 @@ class ImageSource {
9798
#endif
9899

99100
#if RN_DEBUG_STRING_CONVERTIBLE
100-
SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const
101-
{
102-
ImageSource imageSource{};
103-
104-
SharedDebugStringConvertibleList headersList;
105-
for (const auto &header : headers) {
106-
headersList.push_back(debugStringConvertibleItem(prefix + "-header-" + header.first, header.second));
107-
}
108-
109-
return headersList +
110-
SharedDebugStringConvertibleList{
111-
debugStringConvertibleItem(prefix + "-type", toString(type), toString(imageSource.type)),
112-
debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri),
113-
debugStringConvertibleItem(prefix + "-bundle", bundle, imageSource.bundle),
114-
debugStringConvertibleItem(prefix + "-scale", scale, imageSource.scale),
115-
debugStringConvertibleItem(prefix + "-size", react::toString(size), react::toString(imageSource.size)),
116-
debugStringConvertibleItem(prefix + "-body", body, imageSource.body),
117-
debugStringConvertibleItem(prefix + "-method", method, imageSource.method),
118-
debugStringConvertibleItem(prefix + "-cache", toString(cache), toString(imageSource.cache)),
119-
};
120-
}
101+
SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const;
121102

122103
std::string toString(const Type &typeValue) const
123104
{

0 commit comments

Comments
 (0)