Skip to content

Commit

Permalink
[0.74] Renaming CompositionRootView as ReactNativeIsland, Ability to …
Browse files Browse the repository at this point in the history
…override ViewStyle of Root View (#13319)

* Renaming CompositionRootView as ReactNativeIsland (#13304)

* Rename CompositionRootView files

* Fix format

* Fix build errors in playground-composition

* Change files

* Fix build issues

* Add ability to override the ViewStyle of the root View component (#13315)

* Add ability to override the ViewStyle of the root View component

* Change files

* fix

* [Fabric] Touch pointer moved was being reported to richedit as a pointerup (#13313)

* [Fabric] Touch pointer moved was being reported to richedit as a pointerup

* Change files

* update change files

* Align AppRegistry with 0.74 version

---------

Co-authored-by: Sharath Manchala <[email protected]>
  • Loading branch information
acoates-ms and sharath2727 authored Jun 7, 2024
1 parent 4c3a355 commit 1ed0cd4
Show file tree
Hide file tree
Showing 32 changed files with 1,108 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Fabric] Touch pointer moved was being reported to richedit as a pointerup",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add ability to override the ViewStyle of the root View component",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Rename CompositionRootView to ReactNativeIsland",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ constexpr PCWSTR mainComponentName = L"RNTesterApp";
std::vector<std::string> g_Errors;
std::vector<std::string> g_Warnings;
HWND global_hwnd;
winrt::Microsoft::ReactNative::CompositionRootView *global_rootView{nullptr};
winrt::Microsoft::ReactNative::ReactNativeIsland *global_rootView{nullptr};
winrt::Microsoft::ReactNative::IReactContext global_reactContext{nullptr};

// Forward declarations of functions included in this code module:
Expand All @@ -41,7 +41,7 @@ float ScaleFactor(HWND hwnd) noexcept {
}

void UpdateRootViewSizeToAppWindow(
winrt::Microsoft::ReactNative::CompositionRootView const &rootView,
winrt::Microsoft::ReactNative::ReactNativeIsland const &rootView,
winrt::Microsoft::UI::Windowing::AppWindow const &window) {
auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
auto scaleFactor = ScaleFactor(hwnd);
Expand Down Expand Up @@ -142,7 +142,7 @@ _Use_decl_annotations_ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE, PSTR
// Create a RootView which will present a react-native component
winrt::Microsoft::ReactNative::ReactViewOptions viewOptions;
viewOptions.ComponentName(mainComponentName);
auto rootView = winrt::Microsoft::ReactNative::CompositionRootView(compositor);
auto rootView = winrt::Microsoft::ReactNative::ReactNativeIsland(compositor);
rootView.ReactViewHost(winrt::Microsoft::ReactNative::ReactCoreInjection::MakeViewHost(host, viewOptions));

// Update the size of the RootView when the AppWindow changes size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct WindowData {
static constexpr uint16_t defaultDebuggerPort = 9229;

std::wstring m_bundleFile;
winrt::Microsoft::ReactNative::CompositionRootView m_compRootView{nullptr};
winrt::Microsoft::ReactNative::ReactNativeIsland m_compRootView{nullptr};
winrt::Microsoft::ReactNative::ReactNativeHost m_host{nullptr};
winrt::Microsoft::ReactNative::ReactInstanceSettings m_instanceSettings{nullptr};
bool m_useLiftedComposition{true};
Expand Down Expand Up @@ -236,9 +236,9 @@ struct WindowData {

if (!m_compRootView) {
if (windowData->m_useLiftedComposition) {
m_compRootView = winrt::Microsoft::ReactNative::CompositionRootView(g_liftedCompositor);
m_compRootView = winrt::Microsoft::ReactNative::ReactNativeIsland(g_liftedCompositor);
} else {
m_compRootView = winrt::Microsoft::ReactNative::CompositionRootView();
m_compRootView = winrt::Microsoft::ReactNative::ReactNativeIsland();
}

if (windowData->m_useLiftedComposition) {
Expand Down
10 changes: 5 additions & 5 deletions vnext/Desktop/module.g.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.200615.7


#include "pch.h"
#include "winrt/base.h"
void* winrt_make_Microsoft_Internal_TestController();
void* winrt_make_Microsoft_ReactNative_CompositionRootView();
void* winrt_make_Microsoft_ReactNative_ReactNativeIsland();
#ifdef USE_WINUI3
void *winrt_make_Microsoft_ReactNative_Composition_Experimental_MicrosoftCompositionContextHelper();
#endif
Expand All @@ -28,7 +28,7 @@ void* winrt_make_facebook_react_NativeLogEventSource();
void* winrt_make_facebook_react_NativeTraceEventSource();

#ifndef USE_FABRIC
void* winrt_make_Microsoft_ReactNative_CompositionRootView() {
void* winrt_make_Microsoft_ReactNative_ReactNativeIsland() {
winrt::throw_hresult(E_NOTIMPL);
}
void* winrt_make_Microsoft_ReactNative_Composition_ViewComponentView() {
Expand Down Expand Up @@ -61,8 +61,8 @@ void* __stdcall winrt_get_activation_factory([[maybe_unused]] std::wstring_view
{
return winrt_make_Microsoft_Internal_TestController();
}
if (requal(name, L"Microsoft.ReactNative.CompositionRootView")) {
return winrt_make_Microsoft_ReactNative_CompositionRootView();
if (requal(name, L"Microsoft.ReactNative.ReactNativeIsland")) {
return winrt_make_Microsoft_ReactNative_ReactNativeIsland();
}
#ifdef USE_WINUI3
if (requal(name, L"Microsoft.ReactNative.Composition.Experimental.MicrosoftCompositionContextHelper")) {
Expand Down
2 changes: 1 addition & 1 deletion vnext/Microsoft.ReactNative/CompositionHwndHost.idl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import "IJSValueWriter.idl";
import "ReactCoreInjection.idl";
import "ReactNativeHost.idl";
import "CompositionRootView.idl";
import "ReactNativeIsland.idl";
#include "NamespaceRedirect.h"
#include "DocString.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <windowsx.h>
#include <winrt/Windows.UI.Input.h>
#include "Composition.Input.h"
#include "CompositionRootView.h"
#include "CompositionViewComponentView.h"
#include "ReactNativeIsland.h"
#include "RootComponentView.h"

#ifdef USE_WINUI3
Expand Down Expand Up @@ -151,10 +151,10 @@ struct CompositionInputKeyboardSource : winrt::implements<

CompositionEventHandler::CompositionEventHandler(
const winrt::Microsoft::ReactNative::ReactContext &context,
const winrt::Microsoft::ReactNative::CompositionRootView &CompositionRootView)
: m_context(context), m_wkRootView(CompositionRootView) {
const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland)
: m_context(context), m_wkRootView(reactNativeIsland) {
#ifdef USE_WINUI3
if (auto island = CompositionRootView.Island()) {
if (auto island = reactNativeIsland.Island()) {
auto pointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(island);

m_pointerPressedToken =
Expand Down Expand Up @@ -241,7 +241,7 @@ CompositionEventHandler::CompositionEventHandler(
focusedComponent
? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(
strongRootView)
->RootTag()),
args);
Expand All @@ -264,7 +264,7 @@ CompositionEventHandler::CompositionEventHandler(
focusedComponent
? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(
strongRootView)
->RootTag()),
args);
Expand All @@ -288,7 +288,7 @@ CompositionEventHandler::CompositionEventHandler(
focusedComponent
? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(
strongRootView)
->RootTag()),
args);
Expand Down Expand Up @@ -323,7 +323,7 @@ CompositionEventHandler::~CompositionEventHandler() {
facebook::react::SurfaceId CompositionEventHandler::SurfaceId() const noexcept {
if (auto strongRootView = m_wkRootView.get()) {
return static_cast<facebook::react::SurfaceId>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(strongRootView)->RootTag());
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(strongRootView)->RootTag());
}
return -1;
}
Expand Down Expand Up @@ -456,11 +456,11 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
auto focusedComponent = RootComponentView().GetFocusedComponent();
auto args = winrt::make<
winrt::Microsoft::ReactNative::Composition::Input::implementation::CharacterReceivedRoutedEventArgs>(
focusedComponent ? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
strongRootView)
->RootTag()),
focusedComponent
? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(strongRootView)
->RootTag()),
msg,
wParam,
lParam);
Expand All @@ -477,11 +477,11 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
if (auto strongRootView = m_wkRootView.get()) {
auto focusedComponent = RootComponentView().GetFocusedComponent();
auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::KeyRoutedEventArgs>(
focusedComponent ? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
strongRootView)
->RootTag()),
focusedComponent
? focusedComponent.Tag()
: static_cast<facebook::react::Tag>(
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(strongRootView)
->RootTag()),
msg,
wParam,
lParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CompositionEventHandler {
public:
CompositionEventHandler(
const winrt::Microsoft::ReactNative::ReactContext &context,
const winrt::Microsoft::ReactNative::CompositionRootView &CompositionRootView);
const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland);
virtual ~CompositionEventHandler();

int64_t SendMessage(HWND hwnd, uint32_t msg, uint64_t wParam, int64_t lParam) noexcept;
Expand Down Expand Up @@ -154,7 +154,7 @@ class CompositionEventHandler {
PointerId m_touchId = 0;

std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
winrt::weak_ref<winrt::Microsoft::ReactNative::CompositionRootView> m_wkRootView;
winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
winrt::Microsoft::ReactNative::ReactContext m_context;

facebook::react::Tag m_pointerCapturingComponentTag{-1}; // Component that has captured input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
#include "CompositionRootAutomationProvider.h"
#include "CompositionRootView.h"
#include "ReactNativeIsland.h"

#if USE_WINUI3
#include <winrt/Microsoft.UI.Content.h>
Expand All @@ -39,7 +39,7 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept {
if (auto liftedCompositor =
winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerCompositor(
compositionContext)) {
m_compRootView = winrt::Microsoft::ReactNative::CompositionRootView(liftedCompositor);
m_compRootView = winrt::Microsoft::ReactNative::ReactNativeIsland(liftedCompositor);

auto bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
liftedCompositor, winrt::Microsoft::UI::GetWindowIdFromWindow(m_hwnd));
Expand All @@ -52,7 +52,7 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept {
m_compRootView.ScaleFactor(ScaleFactor());
bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
} else {
m_compRootView = winrt::Microsoft::ReactNative::CompositionRootView();
m_compRootView = winrt::Microsoft::ReactNative::ReactNativeIsland();
m_compRootView.as<winrt::Microsoft::ReactNative::Composition::Experimental::IInternalCompositionRootView>()
.SetWindow(reinterpret_cast<uint64_t>(m_hwnd));

Expand Down Expand Up @@ -149,7 +149,7 @@ void CompositionHwndHost::ReactViewHost(ReactNative::IReactViewHost const &value
}

IInspectable CompositionHwndHost::UiaProvider() noexcept {
auto compRootView = winrt::get_self<implementation::CompositionRootView>(m_compRootView);
auto compRootView = winrt::get_self<implementation::ReactNativeIsland>(m_compRootView);
auto provider = compRootView->GetUiaProvider();
auto pRootProvider = static_cast<CompositionRootAutomationProvider *>(provider.as<IRawElementProviderSimple>().get());
if (pRootProvider != nullptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct CompositionHwndHost : CompositionHwndHostT<CompositionHwndHost> {
float ScaleFactor() noexcept;

HWND m_hwnd;
winrt::Microsoft::ReactNative::CompositionRootView m_compRootView{nullptr};
winrt::Microsoft::ReactNative::ReactNativeIsland m_compRootView{nullptr};
LONG m_height{0};
LONG m_width{0};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <winrt/Microsoft.UI.Input.h>
#endif

#include <Fabric/Composition/CompositionRootView.h>
#include <Fabric/Composition/ReactNativeIsland.h>

namespace winrt::Microsoft::ReactNative::implementation {

CompositionRootAutomationProvider::CompositionRootAutomationProvider(
const winrt::Microsoft::ReactNative::CompositionRootView &rootView) noexcept
const winrt::Microsoft::ReactNative::ReactNativeIsland &rootView) noexcept
: m_wkRootView{rootView} {}

// Implementations should return NULL for a top-level element that is hosted in a window. Other elements should return
Expand Down Expand Up @@ -170,7 +170,7 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_ProviderOptions(Provide
winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
CompositionRootAutomationProvider::rootComponentView() noexcept {
if (auto rootView = m_wkRootView.get()) {
auto innerRootView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(rootView);
auto innerRootView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView);
if (auto view = innerRootView->GetComponentView()) {
return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <inspectable.h>

namespace winrt::Microsoft::ReactNative::implementation {
struct CompositionRootView;
struct ReactNativeIsland;

class CompositionRootAutomationProvider : public winrt::implements<
CompositionRootAutomationProvider,
Expand Down Expand Up @@ -39,7 +39,7 @@ class CompositionRootAutomationProvider : public winrt::implements<
virtual HRESULT __stdcall AdviseEventAdded(EVENTID idEvent, SAFEARRAY *psaProperties) override;
virtual HRESULT __stdcall AdviseEventRemoved(EVENTID idEvent, SAFEARRAY *psaProperties) override;

CompositionRootAutomationProvider(const winrt::Microsoft::ReactNative::CompositionRootView &rootView) noexcept;
CompositionRootAutomationProvider(const winrt::Microsoft::ReactNative::ReactNativeIsland &rootView) noexcept;

void SetHwnd(HWND hwnd) noexcept;
#ifdef USE_WINUI3
Expand Down Expand Up @@ -72,7 +72,7 @@ class CompositionRootAutomationProvider : public winrt::implements<
// practice ATs tend to only listen to a dozen or so props and events, so std::vector is likely better than maps.
std::vector<AdvisedEvent> m_advisedEvents{};
std::vector<AdvisedEvent> m_advisedProperties{};
winrt::weak_ref<winrt::Microsoft::ReactNative::CompositionRootView> m_wkRootView;
winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
HWND m_hwnd{nullptr};
#ifdef USE_WINUI3
winrt::Microsoft::UI::Content::ContentIsland m_island{nullptr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <AutoDraw.h>
#include <Fabric/AbiState.h>
#include <Fabric/AbiViewProps.h>
#include <Fabric/Composition/CompositionRootView.h>
#include <Fabric/Composition/ReactNativeIsland.h>
#include <Fabric/FabricUIManagerModule.h>
#include <UI.Xaml.Controls.h>
#include <Utils/KeyboardUtils.h>
Expand Down Expand Up @@ -270,12 +270,12 @@ bool ComponentView::CapturePointer(const winrt::Microsoft::ReactNative::Composit
if (!root)
return false;

auto rootView = uiManager->GetCompositionRootView(root->Tag());
auto rootView{uiManager->GetReactNativeIsland(root->Tag())};
if (!rootView) {
return false;
}

return winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(rootView)->CapturePointer(
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)->CapturePointer(
pointer, static_cast<facebook::react::Tag>(Tag()));
}

Expand All @@ -289,12 +289,12 @@ void ComponentView::ReleasePointerCapture(
if (!root)
return;

auto rootView = uiManager->GetCompositionRootView(root->Tag());
auto rootView{uiManager->GetReactNativeIsland(root->Tag())};
if (!rootView) {
return;
}

return winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(rootView)
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)
->ReleasePointerCapture(pointer, static_cast<facebook::react::Tag>(Tag()));
}

Expand Down
Loading

0 comments on commit 1ed0cd4

Please sign in to comment.