diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/ViewEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/view/ViewEventEmitter.h new file mode 100644 index 00000000000000..2ad0d4e4190505 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/view/ViewEventEmitter.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook::react { +using ViewEventEmitter = HostPlatformViewEventEmitter; +using SharedViewEventEmitter = std::shared_ptr; +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/ViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/view/ViewProps.h new file mode 100644 index 00000000000000..f1d3bb0c286bf7 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/view/ViewProps.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook::react { +using ViewProps = HostPlatformViewProps; +using SharedViewProps = std::shared_ptr; +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp index 4e4aa9479205cb..2375c2dea84cca 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp @@ -7,7 +7,7 @@ #include "ViewShadowNode.h" #include -#include +#include #include #include @@ -56,12 +56,13 @@ void ViewShadowNode::initialize() noexcept { viewProps.accessibilityViewIsModal || viewProps.importantForAccessibility != ImportantForAccessibility::Auto || viewProps.removeClippedSubviews || - ViewTraitsInitializer::formsStackingContext(viewProps); + HostPlatformViewTraitsInitializer::formsStackingContext(viewProps); bool formsView = formsStackingContext || isColorMeaningful(viewProps.backgroundColor) || !(viewProps.yogaStyle.border() == YGStyle::Edges{}) || - !viewProps.testId.empty() || ViewTraitsInitializer::formsView(viewProps); + !viewProps.testId.empty() || + HostPlatformViewTraitsInitializer::formsView(viewProps); if (formsView) { traits_.set(ShadowNodeTraits::Trait::FormsView); @@ -75,7 +76,7 @@ void ViewShadowNode::initialize() noexcept { traits_.unset(ShadowNodeTraits::Trait::FormsStackingContext); } - traits_.set(ViewTraitsInitializer::extraTraits()); + traits_.set(HostPlatformViewTraitsInitializer::extraTraits()); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewEventEmitter.h similarity index 73% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewEventEmitter.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewEventEmitter.h index 23140c98b561ba..24c9a19a7f4dfc 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewEventEmitter.h @@ -10,6 +10,5 @@ #include namespace facebook::react { -using ViewEventEmitter = BaseViewEventEmitter; -using SharedViewEventEmitter = std::shared_ptr; +using HostPlatformViewEventEmitter = BaseViewEventEmitter; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp similarity index 92% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.cpp rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp index 20f2d5feea3b31..85f74f20a2c45b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -#include "ViewProps.h" +#include "HostPlatformViewProps.h" #include @@ -17,9 +17,9 @@ namespace facebook::react { -ViewProps::ViewProps( +HostPlatformViewProps::HostPlatformViewProps( const PropsParserContext &context, - ViewProps const &sourceProps, + HostPlatformViewProps const &sourceProps, RawProps const &rawProps, bool shouldSetRawProps) : BaseViewProps(context, sourceProps, rawProps, shouldSetRawProps), @@ -89,7 +89,7 @@ ViewProps::ViewProps( return; \ } -void ViewProps::setProp( +void HostPlatformViewProps::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, const char *propName, @@ -99,7 +99,7 @@ void ViewProps::setProp( // reuse the same values. BaseViewProps::setProp(context, hash, propName, value); - static auto defaults = ViewProps{}; + static auto defaults = HostPlatformViewProps{}; switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(elevation); @@ -112,12 +112,13 @@ void ViewProps::setProp( } } -bool ViewProps::getProbablyMoreHorizontalThanVertical_DEPRECATED() const { +bool HostPlatformViewProps::getProbablyMoreHorizontalThanVertical_DEPRECATED() + const { return yogaStyle.flexDirection() == YGFlexDirectionRow; } #if RN_DEBUG_STRING_CONVERTIBLE -SharedDebugStringConvertibleList ViewProps::getDebugProps() const { +SharedDebugStringConvertibleList HostPlatformViewProps::getDebugProps() const { return BaseViewProps::getDebugProps(); } #endif diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h similarity index 88% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h index 5ebda517aeae40..dd08ff16edf84a 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h @@ -20,16 +20,12 @@ namespace facebook::react { -class ViewProps; - -using SharedViewProps = std::shared_ptr; - -class ViewProps : public BaseViewProps { +class HostPlatformViewProps : public BaseViewProps { public: - ViewProps() = default; - ViewProps( + HostPlatformViewProps() = default; + HostPlatformViewProps( const PropsParserContext &context, - ViewProps const &sourceProps, + HostPlatformViewProps const &sourceProps, RawProps const &rawProps, bool shouldSetRawProps = true); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewTraitsInitializer.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewTraitsInitializer.h similarity index 70% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewTraitsInitializer.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewTraitsInitializer.h index e8d6ac59db5673..8b77755c93b6c7 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewTraitsInitializer.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewTraitsInitializer.h @@ -10,13 +10,13 @@ #include #include -namespace facebook::react::ViewTraitsInitializer { +namespace facebook::react::HostPlatformViewTraitsInitializer { -static bool formsStackingContext(ViewProps const &viewProps) { +inline bool formsStackingContext(ViewProps const &viewProps) { return viewProps.elevation != 0; } -static bool formsView(ViewProps const &viewProps) { +inline bool formsView(ViewProps const &viewProps) { return viewProps.nativeBackground.has_value() || viewProps.nativeForeground.has_value() || viewProps.focusable || viewProps.hasTVPreferredFocus || @@ -24,8 +24,8 @@ static bool formsView(ViewProps const &viewProps) { viewProps.renderToHardwareTextureAndroid; } -static ShadowNodeTraits::Trait extraTraits() { +inline ShadowNodeTraits::Trait extraTraits() { return ShadowNodeTraits::Trait::AndroidMapBufferPropsSupported; } -} // namespace facebook::react::ViewTraitsInitializer +} // namespace facebook::react::HostPlatformViewTraitsInitializer diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewPropsMapBuffer.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewPropsMapBuffer.cpp index 0d48e8dae46a91..c358f4f71215ca 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewPropsMapBuffer.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/ViewPropsMapBuffer.cpp @@ -6,8 +6,8 @@ */ #include "ViewPropsMapBuffer.h" -#include "ViewProps.h" +#include #include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/YogaStylablePropsMapBuffer.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/YogaStylablePropsMapBuffer.cpp index a0b5072000527a..5d5ece381b2330 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/YogaStylablePropsMapBuffer.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/YogaStylablePropsMapBuffer.cpp @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -#include "ViewProps.h" #include "ViewPropsMapBuffer.h" +#include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewEventEmitter.h similarity index 73% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewEventEmitter.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewEventEmitter.h index 23140c98b561ba..24c9a19a7f4dfc 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewEventEmitter.h @@ -10,6 +10,5 @@ #include namespace facebook::react { -using ViewEventEmitter = BaseViewEventEmitter; -using SharedViewEventEmitter = std::shared_ptr; +using HostPlatformViewEventEmitter = BaseViewEventEmitter; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewProps.h similarity index 78% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewProps.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewProps.h index 6e2d465236bcdb..527985d2990214 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewProps.h @@ -10,6 +10,5 @@ #include namespace facebook::react { -using ViewProps = BaseViewProps; -using SharedViewProps = std::shared_ptr; +using HostPlatformViewProps = BaseViewProps; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewTraitsInitializer.h b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewTraitsInitializer.h similarity index 58% rename from packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewTraitsInitializer.h rename to packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewTraitsInitializer.h index 72b7203dea5ba2..b46dcd024f5d56 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/ViewTraitsInitializer.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewTraitsInitializer.h @@ -10,18 +10,18 @@ #include #include -namespace facebook::react::ViewTraitsInitializer { +namespace facebook::react::HostPlatformViewTraitsInitializer { -static bool formsStackingContext(ViewProps const &props) { +inline bool formsStackingContext(ViewProps const &props) { return false; } -static bool formsView(ViewProps const &props) { +inline bool formsView(ViewProps const &props) { return false; } -static ShadowNodeTraits::Trait extraTraits() { +inline ShadowNodeTraits::Trait extraTraits() { return ShadowNodeTraits::Trait::None; } -} // namespace facebook::react::ViewTraitsInitializer +} // namespace facebook::react::HostPlatformViewTraitsInitializer