From 8aa97bb8cb286791933b4a90a73b50996da19431 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 14 Oct 2026 02:31:21 -0700 Subject: [PATCH] Upgrade `react/renderer/dom` visibility to "for frameworks" (#59032) Summary: Pull Request resolved: https://github.com/react/react-native/pull/59032 Reclassifies `react/renderer/dom` from private to "for frameworks" under the C++ stable API three-tier visibility model. Third-party frameworks rely on these shadow tree helpers; for example, `react-native-reanimated` calls `dom::getParentNode` to resolve a node's parent in the current revision. As a private header, `DOM.h` would hard-error for such consumers once they opt into `RN_STRICT_API`, with no escape hatch. As a "for frameworks" header it emits a suppressible warning that can be acknowledged with `RN_ALLOW_FRAMEWORKS`. Without `RN_STRICT_API` the guards are inert, so no existing build changes behaviour. `DOM.h` only reaches `RootShadowNode.h` ("for frameworks") and `ShadowNode.h` (public), so the retier introduces no tier boundary breaks. `react/nativemodule/dom` (the `NativeDOM` TurboModule) stays private. Changelog: [Internal] ___ landed-with-radar-review Differential Revision: D124966422 fbshipit-source-id: 907dccb0a764fa3e094b1e0f57257b71c7e25ef8 --- .../ReactCommon/react/renderer/dom/DOM.h | 2 +- .../ReactAndroidFrameworksCxx.api | 62 +++++++++++++++++++ .../api-snapshots/ReactAppleFrameworksCxx.api | 62 +++++++++++++++++++ .../ReactCommonFrameworksCxx.api | 62 +++++++++++++++++++ 4 files changed, 187 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/dom/DOM.h b/packages/react-native/ReactCommon/react/renderer/dom/DOM.h index 5dafeaea03c..8f6496779c8 100644 --- a/packages/react-native/ReactCommon/react/renderer/dom/DOM.h +++ b/packages/react-native/ReactCommon/react/renderer/dom/DOM.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api index 6910cec834b..011a67c223d 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api @@ -8732,6 +8732,68 @@ concept facebook::react::detail::css::keywords::hasWrapReverse = (CSSKeywordSet< constexpr facebook::react::Color facebook::react::HostPlatformColor::UndefinedColor; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINED_BY; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINS; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_DISCONNECTED; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_FOLLOWING; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_PRECEDING; +bool facebook::react::dom::isConnected(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMBorderWidthRounded facebook::react::dom::getBorderWidth(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMOffset facebook::react::dom::getOffset(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMPoint facebook::react::dom::getScrollPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMRect facebook::react::dom::getBoundingClientRect(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, bool includeTransform); +facebook::react::dom::DOMRect facebook::react::dom::measureInWindow(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getInnerSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getScrollSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::RNMeasureRect facebook::react::dom::measure(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::optional facebook::react::dom::measureLayout(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& relativeToShadowNode); +std::shared_ptr facebook::react::dom::getElementById(const std::shared_ptr& currentRevision, const std::string& id); +std::shared_ptr facebook::react::dom::getParentNode(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTagName(const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTextContent(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::vector> facebook::react::dom::getChildNodes(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +uint_fast16_t facebook::react::dom::compareDocumentPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& otherShadowNode); + +struct facebook::react::dom::DOMBorderWidthRounded { + public int bottom; + public int left; + public int right; + public int top; +} + +struct facebook::react::dom::DOMOffset { + public double left; + public double top; + public std::shared_ptr offsetParent; +} + +struct facebook::react::dom::DOMPoint { + public double x; + public double y; +} + +struct facebook::react::dom::DOMRect { + public double height; + public double width; + public double x; + public double y; +} + +struct facebook::react::dom::DOMSizeRounded { + public int height; + public int width; +} + +struct facebook::react::dom::RNMeasureRect { + public double height; + public double pageX; + public double pageY; + public double width; + public double x; + public double y; +} + + std::shared_ptr facebook::react::CoreComponentsRegistry::sharedProviderRegistry(); void facebook::react::CoreComponentsRegistry::addCoreComponents(std::shared_ptr registry); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api index 098da6a59a9..d4bb31bd721 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api @@ -10644,6 +10644,68 @@ template concept facebook::react::detail::css::keywords::hasWrapReverse = (CSSKeywordSet && requires() { T::WrapReverse; }); +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINED_BY; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINS; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_DISCONNECTED; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_FOLLOWING; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_PRECEDING; +bool facebook::react::dom::isConnected(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMBorderWidthRounded facebook::react::dom::getBorderWidth(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMOffset facebook::react::dom::getOffset(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMPoint facebook::react::dom::getScrollPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMRect facebook::react::dom::getBoundingClientRect(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, bool includeTransform); +facebook::react::dom::DOMRect facebook::react::dom::measureInWindow(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getInnerSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getScrollSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::RNMeasureRect facebook::react::dom::measure(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::optional facebook::react::dom::measureLayout(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& relativeToShadowNode); +std::shared_ptr facebook::react::dom::getElementById(const std::shared_ptr& currentRevision, const std::string& id); +std::shared_ptr facebook::react::dom::getParentNode(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTagName(const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTextContent(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::vector> facebook::react::dom::getChildNodes(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +uint_fast16_t facebook::react::dom::compareDocumentPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& otherShadowNode); + +struct facebook::react::dom::DOMBorderWidthRounded { + public int bottom; + public int left; + public int right; + public int top; +} + +struct facebook::react::dom::DOMOffset { + public double left; + public double top; + public std::shared_ptr offsetParent; +} + +struct facebook::react::dom::DOMPoint { + public double x; + public double y; +} + +struct facebook::react::dom::DOMRect { + public double height; + public double width; + public double x; + public double y; +} + +struct facebook::react::dom::DOMSizeRounded { + public int height; + public int width; +} + +struct facebook::react::dom::RNMeasureRect { + public double height; + public double pageX; + public double pageY; + public double width; + public double x; + public double y; +} + + facebook::jsi::Value facebook::react::TurboModuleConvertUtils::convertObjCObjectToJSIValue(facebook::jsi::Runtime& runtime, id value); id facebook::react::TurboModuleConvertUtils::convertJSIValueToObjCObject(facebook::jsi::Runtime& runtime, const facebook::jsi::Value& value, const std::shared_ptr& jsInvoker, BOOL useNSNull = NO, BOOL mustCopyBytes = YES); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api index 2087b958d16..b3011c1fec0 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api @@ -5971,6 +5971,68 @@ template concept facebook::react::detail::css::keywords::hasWrapReverse = (CSSKeywordSet && requires() { T::WrapReverse; }); +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINED_BY; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_CONTAINS; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_DISCONNECTED; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_FOLLOWING; +constexpr uint_fast16_t facebook::react::dom::DOCUMENT_POSITION_PRECEDING; +bool facebook::react::dom::isConnected(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMBorderWidthRounded facebook::react::dom::getBorderWidth(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMOffset facebook::react::dom::getOffset(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMPoint facebook::react::dom::getScrollPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMRect facebook::react::dom::getBoundingClientRect(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, bool includeTransform); +facebook::react::dom::DOMRect facebook::react::dom::measureInWindow(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getInnerSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::DOMSizeRounded facebook::react::dom::getScrollSize(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +facebook::react::dom::RNMeasureRect facebook::react::dom::measure(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::optional facebook::react::dom::measureLayout(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& relativeToShadowNode); +std::shared_ptr facebook::react::dom::getElementById(const std::shared_ptr& currentRevision, const std::string& id); +std::shared_ptr facebook::react::dom::getParentNode(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTagName(const facebook::react::ShadowNode& shadowNode); +std::string facebook::react::dom::getTextContent(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +std::vector> facebook::react::dom::getChildNodes(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode); +uint_fast16_t facebook::react::dom::compareDocumentPosition(const facebook::react::RootShadowNode::Shared& currentRevision, const facebook::react::ShadowNode& shadowNode, const facebook::react::ShadowNode& otherShadowNode); + +struct facebook::react::dom::DOMBorderWidthRounded { + public int bottom; + public int left; + public int right; + public int top; +} + +struct facebook::react::dom::DOMOffset { + public double left; + public double top; + public std::shared_ptr offsetParent; +} + +struct facebook::react::dom::DOMPoint { + public double x; + public double y; +} + +struct facebook::react::dom::DOMRect { + public double height; + public double width; + public double x; + public double y; +} + +struct facebook::react::dom::DOMSizeRounded { + public int height; + public int width; +} + +struct facebook::react::dom::RNMeasureRect { + public double height; + public double pageX; + public double pageY; + public double width; + public double x; + public double y; +} + + template constexpr bool facebook::react::bridging::supportsToJs(), std::declval(), nullptr))>>; template