Skip to content

Cleanup unneeded ReactCommon patching, and extra hostplatform overrides #14697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"xtree": "cpp",
"xutility": "cpp",
"xstddef": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"cfloat": "cpp"
},
"search.exclude": {
"**/dist/**/*.js": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Cleanup a bunch of unneeded ReactCommon patching, and extra hostplatform overrides",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion vnext/Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
string literals. It prevents code like
wchar_t* str = L"hello";
from compiling. -->
<AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings /await</AdditionalOptions>
<AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings</AdditionalOptions>
</ClCompile>
<Link>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
Expand Down
4 changes: 1 addition & 3 deletions vnext/Desktop/React.Windows.Desktop.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,13 @@
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
"$(ReactNativeWindowsDir)Microsoft.ReactNative";
"$(ReactNativeWindowsDir)Microsoft.ReactNative\Fabric\platform";
"$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactHost";
"$(ReactNativeWindowsDir)Microsoft.ReactNative\Views";
"$(ReactNativeWindowsDir)codegen";
"$(ReactNativeWindowsDir)codegen\react\components\rnwcore";
$(ReactNativeDir)\ReactCommon\react\renderer\graphics\platform\cxx;
%(AdditionalIncludeDirectories);
</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings /bigobj /await</AdditionalOptions>
<AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings /bigobj</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeTypeInfo Condition="'$(Configuration)'=='Debug' OR '$(UseFabric)' == 'true'">true</RuntimeTypeInfo>
Expand Down
8 changes: 4 additions & 4 deletions vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ void ShadowNode::EnsureUnsealed() noexcept {
}
}

winrt::IInspectable ShadowNode::Tag() const noexcept {
winrt::Windows::Foundation::IInspectable ShadowNode::Tag() const noexcept {
return m_tag;
}

void ShadowNode::Tag(winrt::IInspectable tag) noexcept {
void ShadowNode::Tag(winrt::Windows::Foundation::IInspectable tag) noexcept {
m_tag = tag;
}

winrt::IInspectable ShadowNode::StateData() const noexcept {
winrt::Windows::Foundation::IInspectable ShadowNode::StateData() const noexcept {
if (auto shadowNode = m_shadowNode.lock()) {
auto state = shadowNode->getState();
react_native_assert(state && "State must not be `nullptr`.");
Expand All @@ -55,7 +55,7 @@ winrt::IInspectable ShadowNode::StateData() const noexcept {
return nullptr;
}

void ShadowNode::StateData(winrt::IInspectable tag) noexcept {
void ShadowNode::StateData(winrt::Windows::Foundation::IInspectable tag) noexcept {
if (auto shadowNode = m_shadowNode.lock()) {
shadowNode->ensureUnsealed();

Expand Down
10 changes: 5 additions & 5 deletions vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ struct ShadowNode : ShadowNodeT<ShadowNode> {
ShadowNode(facebook::react::ShadowNode::Shared shadowNode) noexcept;

void EnsureUnsealed() noexcept;
winrt::IInspectable Tag() const noexcept;
void Tag(winrt::IInspectable tag) noexcept;
winrt::Windows::Foundation::IInspectable Tag() const noexcept;
void Tag(winrt::Windows::Foundation::IInspectable tag) noexcept;

winrt::IInspectable StateData() const noexcept;
void StateData(winrt::IInspectable tag) noexcept;
winrt::Windows::Foundation::IInspectable StateData() const noexcept;
void StateData(winrt::Windows::Foundation::IInspectable tag) noexcept;

winrt::Microsoft::ReactNative::EventEmitter EventEmitter() const noexcept;

protected:
facebook::react::ShadowNode::Weak m_shadowNode;
winrt::IInspectable m_tag;
winrt::Windows::Foundation::IInspectable m_tag;
};

} // namespace winrt::Microsoft::ReactNative::implementation
Expand Down
11 changes: 6 additions & 5 deletions vnext/Microsoft.ReactNative/Fabric/ComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ struct ComponentView
const noexcept;
virtual void parent(const winrt::Microsoft::ReactNative::ComponentView &parent) noexcept;
virtual winrt::Microsoft::ReactNative::ComponentView Parent() const noexcept;
virtual winrt::IVectorView<winrt::Microsoft::ReactNative::ComponentView> Children() const noexcept;
virtual winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::ReactNative::ComponentView> Children()
const noexcept;
virtual void theme(winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme) noexcept;
virtual winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme() const noexcept;
virtual void onThemeChanged() noexcept;
Expand Down Expand Up @@ -206,7 +207,7 @@ struct ComponentView
// If ignorePointerEvents = true, all Components are treated as valid targets
virtual facebook::react::Tag
hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents = false) const noexcept;
virtual winrt::IInspectable EnsureUiaProvider() noexcept;
virtual winrt::Windows::Foundation::IInspectable EnsureUiaProvider() noexcept;
virtual std::optional<std::string> getAccessiblityValue() noexcept;
virtual void setAcccessiblityValue(std::string &&value) noexcept;
virtual bool getAcccessiblityIsReadOnly() noexcept;
Expand All @@ -223,8 +224,8 @@ struct ComponentView
virtual const winrt::Microsoft::ReactNative::IComponentProps userProps(
facebook::react::Props::Shared const &props) noexcept;

void UserData(const winrt::IInspectable &userData) noexcept;
winrt::IInspectable UserData() const noexcept;
void UserData(const winrt::Windows::Foundation::IInspectable &userData) noexcept;
winrt::Windows::Foundation::IInspectable UserData() const noexcept;

virtual void MountChildComponentView(
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
Expand Down Expand Up @@ -256,7 +257,7 @@ struct ComponentView
winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder> m_builder;
bool m_mounted : 1 {false};
const facebook::react::Tag m_tag;
winrt::IInspectable m_userData;
winrt::Windows::Foundation::IInspectable m_userData;
mutable winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *m_rootView{nullptr};
mutable winrt::Microsoft::ReactNative::Composition::implementation::Theme *m_theme{nullptr};
const winrt::Microsoft::ReactNative::ReactContext m_reactContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <CppWinRTIncludes.h>
#include <Fabric/ComponentView.h>
#include <Microsoft.ReactNative.Cxx/ReactContext.h>
#include <react/renderer/components/view/ViewEventEmitter.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ContentIslandComponentView : ContentIslandComponentViewT<ContentIslandCom

bool focusable() const noexcept override;

winrt::IInspectable EnsureUiaProvider() noexcept override;
winrt::Windows::Foundation::IInspectable EnsureUiaProvider() noexcept override;

void onGotFocus(const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "ParagraphComponentView.h"

#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>

#include <AutoDraw.h>
#include <Utils/ValueUtils.h>
#include <react/renderer/components/text/ParagraphShadowNode.h>
Expand Down Expand Up @@ -169,7 +171,7 @@ void ParagraphComponentView::updateVisualBrush() noexcept {
constraints.maximumSize.height =
m_layoutMetrics.frame.size.height - m_layoutMetrics.contentInsets.top - m_layoutMetrics.contentInsets.bottom;

facebook::react::TextLayoutManager::GetTextLayout(
facebook::react::WindowsTextLayoutManager::GetTextLayout(
m_attributedStringBox, m_paragraphAttributes, constraints, m_textLayout);

requireNewBrush = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "FocusNavigationRequest.g.cpp"
#include "ReactNativeIsland.g.cpp"
#include <RootViewSizeChangedEventArgs.g.h>
#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>

#include <AutoDraw.h>
#include <DynamicWriter.h>
Expand Down Expand Up @@ -609,7 +610,7 @@ facebook::react::Size ReactNativeIsland::MeasureLoading(

auto attributedStringBox = CreateLoadingAttributedString();
winrt::com_ptr<::IDWriteTextLayout> textLayout;
facebook::react::TextLayoutManager::GetTextLayout(
facebook::react::WindowsTextLayoutManager::GetTextLayout(
attributedStringBox, CreateLoadingParagraphAttributes(), fbLayoutConstraints, textLayout);

DWRITE_TEXT_METRICS tm;
Expand Down Expand Up @@ -691,7 +692,7 @@ Composition::Experimental::IDrawingSurfaceBrush ReactNativeIsland::CreateLoading
textAttributes.foregroundColor = facebook::react::whiteColor();

winrt::com_ptr<::IDWriteTextLayout> textLayout;
facebook::react::TextLayoutManager::GetTextLayout(
facebook::react::WindowsTextLayoutManager::GetTextLayout(
attributedStringBox, CreateLoadingParagraphAttributes(), constraints, textLayout);

DWRITE_TEXT_METRICS tm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
facebook::react::LayoutMetrics const &layoutMetrics,
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;

winrt::IInspectable UiaProviderFromPoint(const POINT &ptPixels) noexcept;
winrt::Windows::Foundation::IInspectable UiaProviderFromPoint(const POINT &ptPixels) noexcept;

RootComponentView(
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <unordered_map>

#include <react/renderer/components/text/ParagraphComponentDescriptor.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>

namespace facebook::react {
Expand All @@ -21,7 +22,7 @@ class WindowsTextInputComponentDescriptor final : public ConcreteComponentDescri
public:
WindowsTextInputComponentDescriptor(const ComponentDescriptorParameters &parameters)
: ConcreteComponentDescriptor<WindowsTextInputShadowNode>(parameters),
textLayoutManager_(std::make_shared<TextLayoutManager>(contextContainer_)) {}
textLayoutManager_(getManagerByName<TextLayoutManager>(contextContainer_, TextLayoutManagerKey)) {}

/*
virtual State::Shared createInitialState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <Fabric/Composition/UiaHelpers.h>
#include <Utils/ValueUtils.h>
#include <react/renderer/components/textinput/TextInputState.h>
#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>
#include <tom.h>
#include <unicode.h>
#include <winrt/Microsoft.UI.Input.h>
Expand Down Expand Up @@ -1482,7 +1483,7 @@ winrt::com_ptr<::IDWriteTextLayout> WindowsTextInputComponentView::CreatePlaceho
constraints.maximumSize.width = static_cast<FLOAT>(m_imgWidth);
constraints.maximumSize.height = static_cast<FLOAT>(m_imgHeight);

facebook::react::TextLayoutManager::GetTextLayout(
facebook::react::WindowsTextLayoutManager::GetTextLayout(
facebook::react::AttributedStringBox(attributedString), {} /*TODO*/, constraints, textLayout);

return textLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ void WindowsTextInputShadowNode::setTextLayoutManager(std::shared_ptr<const Text
Size WindowsTextInputShadowNode::measureContent(
const LayoutContext &layoutContext,
const LayoutConstraints &layoutConstraints) const {
if (getStateData().cachedAttributedStringId != 0) {
facebook::react::ParagraphAttributes paragraphAttributes{};
paragraphAttributes.maximumNumberOfLines = getConcreteProps().multiline ? 0 : 1;
return textLayoutManager_
->measureCachedSpannableById(getStateData().cachedAttributedStringId, paragraphAttributes, layoutConstraints)
.size;
}

// Layout is called right after measure.
// Measure is marked as `const`, and `layout` is not; so State can be updated
// during layout, but not during `measure`. If State is out-of-date in layout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>

#include <react/components/rnwcore/EventEmitters.h>
#include <unordered_map>
#include "WindowsTextInputEventEmitter.h"
Expand All @@ -13,8 +15,6 @@
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/utils/ContextContainer.h>

#include <react/renderer/textlayoutmanager/TextLayoutManager.h>

namespace facebook::react {

extern const char WindowsTextInputComponentName[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include "TooltipService.h"

#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>

#include <CompositionSwitcher.Experimental.interop.h>
#include <Fabric/Composition/CompositionViewComponentView.h>
#include <react/renderer/attributedstring/AttributedStringBox.h>
#include <react/renderer/core/LayoutConstraints.h>
#include <react/renderer/textlayoutmanager/TextLayoutManager.h>
#include <winrt/Microsoft.ReactNative.Composition.h>
#include <winrt/Windows.UI.ViewManagement.h>
#include "TextDrawing.h"
Expand Down Expand Up @@ -255,7 +256,7 @@ void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentV
layoutConstraints.minimumSize.height = 0;
layoutConstraints.minimumSize.width = 0;

facebook::react::TextLayoutManager::GetTextLayout(
facebook::react::WindowsTextLayoutManager::GetTextLayout(
tooltipData->attributedString, {} /*paragraphAttributes*/, layoutConstraints, tooltipData->textLayout);

if (tooltipData->textLayout) {
Expand Down
10 changes: 7 additions & 3 deletions vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ HRESULT UiaGetBoundingRectangleHelper(::Microsoft::ReactNative::ReactTaggedView

HRESULT UiaSetFocusHelper(::Microsoft::ReactNative::ReactTaggedView &view) noexcept;

void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, bool oldValue, bool newValue) noexcept;
void UpdateUiaProperty(
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
bool oldValue,
bool newValue) noexcept;

void UpdateUiaProperty(
winrt::IInspectable provider,
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
const std::string &oldValue,
const std::string &newValue) noexcept;

void UpdateUiaProperty(
winrt::IInspectable provider,
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
const std::optional<std::string> &oldValue,
const std::optional<std::string> &newValue) noexcept;
Expand Down
11 changes: 10 additions & 1 deletion vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
#include <UI.Xaml.Controls.h>
#include <react/components/rnwcore/ComponentDescriptors.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/components/text/ParagraphComponentDescriptor.h>
#include <react/renderer/core/DynamicPropsUtilities.h>
#include <react/renderer/core/EventBeat.h>
#include <react/renderer/runtimescheduler/RuntimeScheduler.h>
#include <react/renderer/scheduler/Scheduler.h>
#include <react/renderer/scheduler/SchedulerToolbox.h>
#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>
#include <react/utils/ContextContainer.h>
#include <winrt/Windows.Graphics.Display.h>
#include <winrt/Windows.UI.Composition.Desktop.h>
Expand Down Expand Up @@ -74,14 +76,21 @@ void FabricUIManager::installFabricUIManager() noexcept {
auto runtimeScheduler = SchedulerSettings::RuntimeSchedulerFromProperties(m_context.Properties());

if (runtimeScheduler) {
contextContainer->insert("RuntimeScheduler", runtimeScheduler);
contextContainer->insert(facebook::react::RuntimeSchedulerKey, runtimeScheduler);
runtimeExecutor = [runtimeScheduler](std::function<void(facebook::jsi::Runtime & runtime)> &&callback) {
runtimeScheduler->scheduleWork(std::move(callback));
};
} else {
runtimeExecutor = SchedulerSettings::GetRuntimeExecutor(m_context.Properties());
}

// Use an empty ContextContainer here, since using contextContainer would cause a ref cycle. We are not currently
// using the ContextContainer within WindowsTextLayoutManager/TextLayoutManager anyway
contextContainer->insert(
facebook::react::TextLayoutManagerKey,
std::make_shared<facebook::react::WindowsTextLayoutManager>(
std::make_shared<facebook::react::ContextContainer>()));

facebook::react::EventBeat::Factory asynchronousBeatFactory =
[runtimeScheduler, context = m_context](std::shared_ptr<facebook::react::EventBeat::OwnerBox> const &ownerBox) {
return std::make_unique<AsynchronousEventBeat>(ownerBox, context, runtimeScheduler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#pragma once

#include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>

#include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
#include <ReactPropertyBag.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
Expand Down

This file was deleted.

This file was deleted.

Loading