react-native-windows 0.74.20 → 0.74.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Microsoft.ReactNative/ComponentView.idl +44 -32
- package/Microsoft.ReactNative/Composition.Input.idl +3 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +43 -24
- package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
- package/Microsoft.ReactNative/Fabric/AbiEventEmitter.cpp +21 -0
- package/Microsoft.ReactNative/Fabric/AbiEventEmitter.h +23 -0
- package/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp +7 -0
- package/Microsoft.ReactNative/Fabric/AbiShadowNode.h +3 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +334 -65
- package/Microsoft.ReactNative/Fabric/ComponentView.h +162 -38
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +2 -2
- package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +29 -7
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +23 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +118 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +12 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +147 -119
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +4 -8
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +129 -106
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +31 -54
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -0
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +61 -0
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +9 -8
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +1 -4
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +3 -5
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +1 -6
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +108 -18
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +33 -5
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +137 -56
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +21 -4
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +45 -10
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +9 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +209 -189
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +2 -5
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +22 -10
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +4 -5
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +115 -168
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +11 -14
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +14 -11
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +12 -4
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +338 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +66 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +56 -4
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +7 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +2 -4
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +40 -9
- package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +4 -0
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +1 -3
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +25 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +4 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +1 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +9 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +13 -3
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +64 -4
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +104 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.h +78 -0
- package/Microsoft.ReactNative/ReactCoreInjection.h +0 -1
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +17 -1
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
- package/Microsoft.ReactNative/Timer.idl +1 -1
- package/Microsoft.ReactNative/packages.lock.json +0 -10
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/WinUI.props +1 -1
- package/Shared/Shared.vcxitems +43 -0
- package/Shared/Shared.vcxitems.filters +3 -0
- package/Shared/TurboModuleManager.cpp +0 -3
- package/just-task.js +1 -1
- package/package.json +3 -3
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +1 -0
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
|
|
5
|
+
#include <Fabric/AbiComponentDescriptor.h>
|
|
6
|
+
#include <Fabric/AbiViewComponentDescriptor.h>
|
|
7
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
5
8
|
#include <react/renderer/core/ReactPrimitives.h>
|
|
6
9
|
#include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
|
|
7
10
|
#include "winrt/Microsoft.ReactNative.Composition.h"
|
|
@@ -16,7 +19,7 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
16
19
|
ReactCompositionViewComponentBuilder() noexcept;
|
|
17
20
|
|
|
18
21
|
public: // IReactViewComponentBuilder
|
|
19
|
-
void
|
|
22
|
+
void SetComponentViewInitializer(const ComponentViewInitializer &initializer) noexcept;
|
|
20
23
|
void SetCreateProps(ViewPropsFactory impl) noexcept;
|
|
21
24
|
|
|
22
25
|
// (Object handle, Microsoft.ReactNative.IComponentState state) => void
|
|
@@ -28,8 +31,19 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
28
31
|
void SetMeasureContentHandler(MeasureContentHandler impl) noexcept;
|
|
29
32
|
void SetLayoutHandler(LayoutHandler impl) noexcept;
|
|
30
33
|
|
|
34
|
+
void SetCustomCommandHandler(HandleCommandDelegate impl) noexcept;
|
|
35
|
+
void SetFinalizeUpdateHandler(UpdateFinalizerDelegate impl) noexcept;
|
|
36
|
+
void SetUpdatePropsHandler(UpdatePropsDelegate impl) noexcept;
|
|
37
|
+
void SetUpdateStateHandler(UpdateStateDelegate impl) noexcept;
|
|
38
|
+
void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl) noexcept;
|
|
39
|
+
void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl) noexcept;
|
|
40
|
+
void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl) noexcept;
|
|
41
|
+
|
|
31
42
|
public: // Composition::IReactCompositionViewComponentBuilder
|
|
32
|
-
void
|
|
43
|
+
void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept;
|
|
44
|
+
void SetContentIslandComponentViewInitializer(const ComponentIslandComponentViewInitializer &initializer) noexcept;
|
|
45
|
+
|
|
46
|
+
void SetCreateVisualHandler(CreateVisualDelegate impl) noexcept;
|
|
33
47
|
|
|
34
48
|
public:
|
|
35
49
|
IComponentProps CreateProps(ViewProps props) noexcept;
|
|
@@ -39,7 +53,7 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
39
53
|
winrt::Microsoft::ReactNative::IComponentProps props) noexcept;
|
|
40
54
|
MeasureContentHandler MeasureContentHandler() const noexcept;
|
|
41
55
|
LayoutHandler LayoutHandler() const noexcept;
|
|
42
|
-
|
|
56
|
+
facebook::react::ComponentDescriptorConstructor *GetComponentDescriptorProvider() const noexcept;
|
|
43
57
|
|
|
44
58
|
winrt::Microsoft::ReactNative::ComponentView CreateView(
|
|
45
59
|
const IReactContext &reactContext,
|
|
@@ -47,15 +61,29 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
|
|
|
47
61
|
const Experimental::ICompositionContext &context) noexcept;
|
|
48
62
|
|
|
49
63
|
private:
|
|
64
|
+
void InitializeComponentView(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept;
|
|
65
|
+
|
|
50
66
|
ViewPropsFactory m_propsFactory;
|
|
51
67
|
ViewShadowNodeFactory m_shadowNodeFactory;
|
|
52
68
|
ViewShadowNodeCloner m_shadowNodeCloner;
|
|
53
69
|
InitialStateDataFactory m_initialStateDataFactory;
|
|
54
70
|
winrt::Microsoft::ReactNative::MeasureContentHandler m_measureContent;
|
|
55
71
|
winrt::Microsoft::ReactNative::LayoutHandler m_layoutHandler;
|
|
72
|
+
std::function<winrt::Microsoft::ReactNative::ComponentView(
|
|
73
|
+
const IReactContext &reactContext,
|
|
74
|
+
int32_t tag,
|
|
75
|
+
const Experimental::ICompositionContext &context)>
|
|
76
|
+
m_fnCreateView;
|
|
77
|
+
std::function<facebook::react::ComponentDescriptorConstructor *()> m_descriptorConstructorFactory;
|
|
78
|
+
winrt::Microsoft::ReactNative::HandleCommandDelegate m_customCommandHandler;
|
|
79
|
+
winrt::Microsoft::ReactNative::UpdateFinalizerDelegate m_finalizeUpdateHandler;
|
|
80
|
+
winrt::Microsoft::ReactNative::UpdatePropsDelegate m_updatePropsHandler;
|
|
81
|
+
winrt::Microsoft::ReactNative::UpdateStateDelegate m_updateStateHandler;
|
|
82
|
+
winrt::Microsoft::ReactNative::UpdateEventEmitterDelegate m_updateEventEmitterHandler;
|
|
83
|
+
winrt::Microsoft::ReactNative::MountChildComponentViewDelegate m_mountChildComponentViewHandler;
|
|
84
|
+
winrt::Microsoft::ReactNative::UnmountChildComponentViewDelegate m_unmountChildComponentViewHandler;
|
|
56
85
|
|
|
57
|
-
|
|
58
|
-
CompositionViewComponentViewFactory m_createView{nullptr};
|
|
86
|
+
winrt::Microsoft::ReactNative::Composition::CreateVisualDelegate m_createVisualHandler;
|
|
59
87
|
};
|
|
60
88
|
|
|
61
89
|
} // namespace winrt::Microsoft::ReactNative::Composition
|
|
@@ -58,10 +58,6 @@ struct CompositionReactViewInstance
|
|
|
58
58
|
void UpdateRootView() noexcept;
|
|
59
59
|
void UninitRootView() noexcept;
|
|
60
60
|
|
|
61
|
-
private:
|
|
62
|
-
template <class TAction>
|
|
63
|
-
Mso::Future<void> PostInUIQueue(TAction &&action) noexcept;
|
|
64
|
-
|
|
65
61
|
private:
|
|
66
62
|
winrt::weak_ref<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland> m_weakRootControl;
|
|
67
63
|
IReactDispatcher m_uiDispatcher{nullptr};
|
|
@@ -102,50 +98,46 @@ void CompositionReactViewInstance::UninitRootView() noexcept {
|
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
// ReactViewInstance inline implementation
|
|
107
|
-
//===========================================================================
|
|
108
|
-
|
|
109
|
-
template <class TAction>
|
|
110
|
-
inline Mso::Future<void> CompositionReactViewInstance::PostInUIQueue(TAction &&action) noexcept {
|
|
111
|
-
// ReactViewInstance has shorter lifetime than ReactRootControl. Thus, we capture this WeakPtr.
|
|
112
|
-
auto promise = Mso::Promise<void>();
|
|
113
|
-
|
|
114
|
-
m_uiDispatcher.Post([promise, weakThis{get_weak()}, action{std::forward<TAction>(action)}]() mutable {
|
|
115
|
-
if (auto strongThis = weakThis.get()) {
|
|
116
|
-
if (auto rootControl = strongThis->m_weakRootControl.get()) {
|
|
117
|
-
action(rootControl);
|
|
118
|
-
promise.SetValue();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
promise.TryCancel();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return promise.AsFuture();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
void ApplyConstraints(
|
|
101
|
+
void ReactNativeIsland::ApplyConstraints(
|
|
129
102
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraintsIn,
|
|
130
|
-
facebook::react::LayoutConstraints &layoutConstraintsOut) noexcept {
|
|
103
|
+
facebook::react::LayoutConstraints &layoutConstraintsOut) const noexcept {
|
|
131
104
|
layoutConstraintsOut.minimumSize = {layoutConstraintsIn.MinimumSize.Width, layoutConstraintsIn.MinimumSize.Height};
|
|
132
105
|
layoutConstraintsOut.maximumSize = {layoutConstraintsIn.MaximumSize.Width, layoutConstraintsIn.MaximumSize.Height};
|
|
133
|
-
|
|
134
|
-
|
|
106
|
+
if (layoutConstraintsIn.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::Undefined) {
|
|
107
|
+
if (m_island) {
|
|
108
|
+
layoutConstraintsOut.layoutDirection =
|
|
109
|
+
(m_island.LayoutDirection() == winrt::Microsoft::UI::Content::ContentLayoutDirection::LeftToRight)
|
|
110
|
+
? facebook::react::LayoutDirection::LeftToRight
|
|
111
|
+
: facebook::react::LayoutDirection::RightToLeft;
|
|
112
|
+
} else if (m_hwnd) {
|
|
113
|
+
auto styles = GetWindowLongPtrW(m_hwnd, GWL_EXSTYLE);
|
|
114
|
+
layoutConstraintsOut.layoutDirection = ((styles & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL)
|
|
115
|
+
? facebook::react::LayoutDirection::RightToLeft
|
|
116
|
+
: facebook::react::LayoutDirection::LeftToRight;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
layoutConstraintsOut.layoutDirection =
|
|
120
|
+
static_cast<facebook::react::LayoutDirection>(layoutConstraintsIn.LayoutDirection);
|
|
121
|
+
}
|
|
135
122
|
}
|
|
136
123
|
|
|
137
|
-
ReactNativeIsland::ReactNativeIsland() noexcept {}
|
|
138
|
-
|
|
139
|
-
#ifdef USE_WINUI3
|
|
140
124
|
ReactNativeIsland::ReactNativeIsland(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept
|
|
141
|
-
: m_compositor(compositor)
|
|
142
|
-
|
|
125
|
+
: m_compositor(compositor),
|
|
126
|
+
m_layoutConstraints({{0, 0}, {0, 0}, winrt::Microsoft::ReactNative::LayoutDirection::Undefined}) {
|
|
127
|
+
InitTextScaleMultiplier();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ReactNativeIsland::ReactNativeIsland() noexcept : ReactNativeIsland(nullptr) {}
|
|
143
131
|
|
|
144
132
|
ReactNativeIsland::~ReactNativeIsland() noexcept {
|
|
145
133
|
#ifdef USE_WINUI3
|
|
146
|
-
if (m_island
|
|
134
|
+
if (m_island) {
|
|
147
135
|
m_island.AutomationProviderRequested(m_islandAutomationProviderRequestedToken);
|
|
148
136
|
m_island.StateChanged(m_islandStateChangedToken);
|
|
137
|
+
#ifdef USE_EXPERIMENTAL_WINUI3
|
|
138
|
+
m_island.Connected(m_islandConnectedToken);
|
|
139
|
+
m_island.Disconnected(m_islandDisconnectedToken);
|
|
140
|
+
#endif
|
|
149
141
|
}
|
|
150
142
|
#endif
|
|
151
143
|
|
|
@@ -165,6 +157,7 @@ void ReactNativeIsland::ReactViewHost(winrt::Microsoft::ReactNative::IReactViewH
|
|
|
165
157
|
}
|
|
166
158
|
|
|
167
159
|
if (m_reactViewHost) {
|
|
160
|
+
UninitRootView();
|
|
168
161
|
m_reactViewHost.DetachViewInstance();
|
|
169
162
|
}
|
|
170
163
|
|
|
@@ -199,6 +192,12 @@ void ReactNativeIsland::AddRenderedVisual(
|
|
|
199
192
|
assert(!m_hasRenderedVisual);
|
|
200
193
|
InternalRootVisual().InsertAt(visual, 0);
|
|
201
194
|
m_hasRenderedVisual = true;
|
|
195
|
+
|
|
196
|
+
if (m_mounted) {
|
|
197
|
+
if (auto componentView = GetComponentView()) {
|
|
198
|
+
componentView->onMounted();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
void ReactNativeIsland::RemoveRenderedVisual(
|
|
@@ -265,6 +264,10 @@ void ReactNativeIsland::ScaleFactor(float value) noexcept {
|
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
266
|
|
|
267
|
+
float ReactNativeIsland::FontSizeMultiplier() const noexcept {
|
|
268
|
+
return m_textScaleMultiplier;
|
|
269
|
+
}
|
|
270
|
+
|
|
268
271
|
int64_t ReactNativeIsland::RootTag() const noexcept {
|
|
269
272
|
return m_rootTag;
|
|
270
273
|
}
|
|
@@ -330,7 +333,7 @@ winrt::IInspectable ReactNativeIsland::GetUiaProvider() noexcept {
|
|
|
330
333
|
if (m_uiaProvider == nullptr) {
|
|
331
334
|
m_uiaProvider =
|
|
332
335
|
winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider>(*this);
|
|
333
|
-
if (m_hwnd) {
|
|
336
|
+
if (m_hwnd && !m_island) {
|
|
334
337
|
auto pRootProvider =
|
|
335
338
|
static_cast<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider *>(
|
|
336
339
|
m_uiaProvider.as<IRawElementProviderSimple>().get());
|
|
@@ -346,6 +349,10 @@ void ReactNativeIsland::SetWindow(uint64_t hwnd) noexcept {
|
|
|
346
349
|
m_hwnd = reinterpret_cast<HWND>(hwnd);
|
|
347
350
|
}
|
|
348
351
|
|
|
352
|
+
HWND ReactNativeIsland::GetHwndForParenting() noexcept {
|
|
353
|
+
return m_hwnd;
|
|
354
|
+
}
|
|
355
|
+
|
|
349
356
|
int64_t ReactNativeIsland::SendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept {
|
|
350
357
|
if (m_rootTag == -1)
|
|
351
358
|
return 0;
|
|
@@ -365,7 +372,7 @@ int64_t ReactNativeIsland::SendMessage(uint32_t msg, uint64_t wParam, int64_t lP
|
|
|
365
372
|
bool ReactNativeIsland::CapturePointer(
|
|
366
373
|
const winrt::Microsoft::ReactNative::Composition::Input::Pointer &pointer,
|
|
367
374
|
facebook::react::Tag tag) noexcept {
|
|
368
|
-
if (m_hwnd) {
|
|
375
|
+
if (m_hwnd && !m_island) {
|
|
369
376
|
SetCapture(m_hwnd);
|
|
370
377
|
}
|
|
371
378
|
return m_CompositionEventHandler->CapturePointer(pointer, tag);
|
|
@@ -375,7 +382,7 @@ void ReactNativeIsland::ReleasePointerCapture(
|
|
|
375
382
|
const winrt::Microsoft::ReactNative::Composition::Input::Pointer &pointer,
|
|
376
383
|
facebook::react::Tag tag) noexcept {
|
|
377
384
|
if (m_CompositionEventHandler->ReleasePointerCapture(pointer, tag)) {
|
|
378
|
-
if (m_hwnd) {
|
|
385
|
+
if (m_hwnd && !m_island) {
|
|
379
386
|
if (m_hwnd == GetCapture()) {
|
|
380
387
|
ReleaseCapture();
|
|
381
388
|
}
|
|
@@ -398,6 +405,7 @@ void ReactNativeIsland::InitRootView(
|
|
|
398
405
|
m_context = winrt::Microsoft::ReactNative::ReactContext(std::move(context));
|
|
399
406
|
m_reactViewOptions = std::move(viewOptions);
|
|
400
407
|
m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
|
|
408
|
+
m_CompositionEventHandler->Initialize();
|
|
401
409
|
|
|
402
410
|
UpdateRootViewInternal();
|
|
403
411
|
|
|
@@ -440,8 +448,9 @@ void ReactNativeIsland::UninitRootView() noexcept {
|
|
|
440
448
|
uiManager->stopSurface(static_cast<facebook::react::SurfaceId>(RootTag()));
|
|
441
449
|
|
|
442
450
|
// This is needed to ensure that the unmount JS logic is completed before the the instance is shutdown during
|
|
443
|
-
// instance destruction. Aligns with similar code in ReactInstanceWin::DetachRootView for paper Future: Instead
|
|
444
|
-
// method should return a Promise, which should be resolved when the JS logic is complete.
|
|
451
|
+
// instance destruction. Aligns with similar code in ReactInstanceWin::DetachRootView for paper Future: Instead
|
|
452
|
+
// this method should return a Promise, which should be resolved when the JS logic is complete. The task will auto
|
|
453
|
+
// set the event on destruction to ensure that the event is set if the JS Queue has already been shutdown
|
|
445
454
|
Mso::ManualResetEvent mre;
|
|
446
455
|
m_context.JSDispatcher().Post([&]() { mre.Set(); });
|
|
447
456
|
mre.Wait();
|
|
@@ -506,9 +515,8 @@ facebook::react::AttributedStringBox CreateLoadingAttributedString() noexcept {
|
|
|
506
515
|
return facebook::react::AttributedStringBox{attributedString};
|
|
507
516
|
}
|
|
508
517
|
|
|
509
|
-
facebook::react::Size MeasureLoading(
|
|
510
|
-
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints
|
|
511
|
-
float scaleFactor) {
|
|
518
|
+
facebook::react::Size ReactNativeIsland::MeasureLoading(
|
|
519
|
+
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints) const noexcept {
|
|
512
520
|
facebook::react::LayoutConstraints fbLayoutConstraints;
|
|
513
521
|
ApplyConstraints(layoutConstraints, fbLayoutConstraints);
|
|
514
522
|
|
|
@@ -521,7 +529,7 @@ facebook::react::Size MeasureLoading(
|
|
|
521
529
|
textLayout->GetMetrics(&tm);
|
|
522
530
|
|
|
523
531
|
return fbLayoutConstraints.clamp(
|
|
524
|
-
{loadingActivityHorizontalOffset *
|
|
532
|
+
{loadingActivityHorizontalOffset * m_scaleFactor + tm.width, loadingBarHeight * m_scaleFactor});
|
|
525
533
|
}
|
|
526
534
|
|
|
527
535
|
winrt::event_token ReactNativeIsland::SizeChanged(
|
|
@@ -551,7 +559,7 @@ void ReactNativeIsland::NotifySizeChanged() noexcept {
|
|
|
551
559
|
if (rootComponentView) {
|
|
552
560
|
size = rootComponentView->layoutMetrics().frame.size;
|
|
553
561
|
} else if (m_loadingVisual) {
|
|
554
|
-
size = MeasureLoading(m_layoutConstraints
|
|
562
|
+
size = MeasureLoading(m_layoutConstraints);
|
|
555
563
|
}
|
|
556
564
|
|
|
557
565
|
m_size = {size.width, size.height};
|
|
@@ -645,11 +653,34 @@ void ReactNativeIsland::ShowInstanceLoading() noexcept {
|
|
|
645
653
|
InternalRootVisual().InsertAt(m_loadingVisual, m_hasRenderedVisual ? 1 : 0);
|
|
646
654
|
}
|
|
647
655
|
|
|
656
|
+
void ReactNativeIsland::InitTextScaleMultiplier() noexcept {
|
|
657
|
+
m_uiSettings = winrt::Windows::UI::ViewManagement::UISettings();
|
|
658
|
+
m_textScaleMultiplier = static_cast<float>(m_uiSettings.TextScaleFactor());
|
|
659
|
+
m_textScaleChangedRevoker = m_uiSettings.TextScaleFactorChanged(
|
|
660
|
+
winrt::auto_revoke,
|
|
661
|
+
[this](const winrt::Windows::UI::ViewManagement::UISettings &uiSettings, const winrt::IInspectable &) {
|
|
662
|
+
if (m_context) {
|
|
663
|
+
m_context.UIDispatcher().Post(
|
|
664
|
+
[wkThis = get_weak(), textScaleMultiplier = static_cast<float>(uiSettings.TextScaleFactor())]() {
|
|
665
|
+
if (auto strongThis = wkThis.get()) {
|
|
666
|
+
strongThis->m_textScaleMultiplier = textScaleMultiplier;
|
|
667
|
+
strongThis->Arrange(strongThis->m_layoutConstraints, strongThis->m_viewportOffset);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
|
|
648
674
|
winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
649
675
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
650
|
-
const winrt::Windows::Foundation::Point &viewportOffset) const
|
|
676
|
+
const winrt::Windows::Foundation::Point &viewportOffset) const {
|
|
651
677
|
facebook::react::Size size{0, 0};
|
|
652
678
|
|
|
679
|
+
if (layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight &&
|
|
680
|
+
layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::RightToLeft &&
|
|
681
|
+
layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::Undefined)
|
|
682
|
+
winrt::throw_hresult(E_INVALIDARG);
|
|
683
|
+
|
|
653
684
|
facebook::react::LayoutConstraints constraints;
|
|
654
685
|
ApplyConstraints(layoutConstraints, constraints);
|
|
655
686
|
|
|
@@ -657,15 +688,14 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
|
657
688
|
if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
|
|
658
689
|
winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
|
|
659
690
|
facebook::react::LayoutContext context;
|
|
660
|
-
|
|
691
|
+
context.fontSizeMultiplier = m_textScaleMultiplier;
|
|
661
692
|
context.pointScaleFactor = static_cast<facebook::react::Float>(m_scaleFactor);
|
|
662
|
-
context.fontSizeMultiplier = static_cast<facebook::react::Float>(m_scaleFactor);
|
|
663
693
|
context.viewportOffset = {viewportOffset.X, viewportOffset.Y};
|
|
664
694
|
|
|
665
695
|
size = fabricuiManager->measureSurface(static_cast<facebook::react::SurfaceId>(m_rootTag), constraints, context);
|
|
666
696
|
}
|
|
667
697
|
} else if (m_loadingVisual) {
|
|
668
|
-
size = MeasureLoading(layoutConstraints
|
|
698
|
+
size = MeasureLoading(layoutConstraints);
|
|
669
699
|
}
|
|
670
700
|
|
|
671
701
|
auto clampedSize = constraints.clamp(size);
|
|
@@ -674,7 +704,12 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
|
674
704
|
|
|
675
705
|
void ReactNativeIsland::Arrange(
|
|
676
706
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
677
|
-
const winrt::Windows::Foundation::Point &viewportOffset)
|
|
707
|
+
const winrt::Windows::Foundation::Point &viewportOffset) {
|
|
708
|
+
if (layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight &&
|
|
709
|
+
layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::RightToLeft &&
|
|
710
|
+
layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::Undefined)
|
|
711
|
+
winrt::throw_hresult(E_INVALIDARG);
|
|
712
|
+
|
|
678
713
|
m_layoutConstraints = layoutConstraints;
|
|
679
714
|
m_viewportOffset = viewportOffset;
|
|
680
715
|
facebook::react::LayoutConstraints fbLayoutConstraints;
|
|
@@ -684,8 +719,8 @@ void ReactNativeIsland::Arrange(
|
|
|
684
719
|
if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
|
|
685
720
|
winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
|
|
686
721
|
facebook::react::LayoutContext context;
|
|
722
|
+
context.fontSizeMultiplier = m_textScaleMultiplier;
|
|
687
723
|
context.pointScaleFactor = static_cast<facebook::react::Float>(m_scaleFactor);
|
|
688
|
-
context.fontSizeMultiplier = static_cast<facebook::react::Float>(m_scaleFactor);
|
|
689
724
|
context.viewportOffset = {viewportOffset.X, viewportOffset.Y};
|
|
690
725
|
|
|
691
726
|
fabricuiManager->constraintSurfaceLayout(
|
|
@@ -693,12 +728,11 @@ void ReactNativeIsland::Arrange(
|
|
|
693
728
|
}
|
|
694
729
|
} else if (m_loadingVisual) {
|
|
695
730
|
// TODO: Resize to align loading
|
|
696
|
-
auto s = fbLayoutConstraints.clamp(MeasureLoading(layoutConstraints
|
|
731
|
+
auto s = fbLayoutConstraints.clamp(MeasureLoading(layoutConstraints));
|
|
697
732
|
NotifySizeChanged();
|
|
698
733
|
}
|
|
699
734
|
}
|
|
700
735
|
|
|
701
|
-
#ifdef USE_WINUI3
|
|
702
736
|
winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
|
|
703
737
|
if (!m_compositor) {
|
|
704
738
|
return nullptr;
|
|
@@ -752,12 +786,59 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
|
|
|
752
786
|
if (args.DidRasterizationScaleChange()) {
|
|
753
787
|
pThis->ScaleFactor(island.RasterizationScale());
|
|
754
788
|
}
|
|
789
|
+
if (args.DidLayoutDirectionChange()) {
|
|
790
|
+
pThis->Arrange(pThis->m_layoutConstraints, pThis->m_viewportOffset);
|
|
791
|
+
}
|
|
792
|
+
#ifndef USE_EXPERIMENTAL_WINUI3 // Use this in place of Connected/Disconnected events for now. -- Its not quite what we
|
|
793
|
+
// want, but it will do for now.
|
|
794
|
+
if (args.DidSiteVisibleChange()) {
|
|
795
|
+
if (island.IsSiteVisible()) {
|
|
796
|
+
pThis->OnMounted();
|
|
797
|
+
} else {
|
|
798
|
+
pThis->OnUnmounted();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
#endif
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
#ifdef USE_EXPERIMENTAL_WINUI3
|
|
805
|
+
m_islandConnectedToken = m_island.Connected(
|
|
806
|
+
[weakThis = get_weak()](
|
|
807
|
+
winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
|
|
808
|
+
if (auto pThis = weakThis.get()) {
|
|
809
|
+
pThis->OnMounted();
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
m_islandDisconnectedToken = m_island.Disconnected(
|
|
814
|
+
[weakThis = get_weak()](
|
|
815
|
+
winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
|
|
816
|
+
if (auto pThis = weakThis.get()) {
|
|
817
|
+
pThis->OnUnmounted();
|
|
755
818
|
}
|
|
756
819
|
});
|
|
820
|
+
#endif
|
|
757
821
|
}
|
|
758
822
|
return m_island;
|
|
759
823
|
}
|
|
760
|
-
|
|
824
|
+
|
|
825
|
+
void ReactNativeIsland::OnMounted() noexcept {
|
|
826
|
+
if (m_mounted)
|
|
827
|
+
return;
|
|
828
|
+
m_mounted = true;
|
|
829
|
+
if (auto componentView = GetComponentView()) {
|
|
830
|
+
componentView->onMounted();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
void ReactNativeIsland::OnUnmounted() noexcept {
|
|
835
|
+
if (!m_mounted)
|
|
836
|
+
return;
|
|
837
|
+
m_mounted = false;
|
|
838
|
+
if (auto componentView = GetComponentView()) {
|
|
839
|
+
componentView->onUnmounted();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
761
842
|
|
|
762
843
|
winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
|
|
763
844
|
ReactNativeIsland::GetComponentView() noexcept {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include <react/renderer/core/LayoutConstraints.h>
|
|
11
11
|
#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
|
|
12
12
|
#include <winrt/Microsoft.ReactNative.h>
|
|
13
|
+
#include <winrt/Windows.UI.ViewManagement.h>
|
|
13
14
|
#include "CompositionEventHandler.h"
|
|
14
15
|
#include "ReactHost/React.h"
|
|
15
16
|
|
|
@@ -46,10 +47,8 @@ struct ReactNativeIsland
|
|
|
46
47
|
ReactNativeIsland() noexcept;
|
|
47
48
|
~ReactNativeIsland() noexcept;
|
|
48
49
|
|
|
49
|
-
#ifdef USE_WINUI3
|
|
50
50
|
ReactNativeIsland(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept;
|
|
51
51
|
winrt::Microsoft::UI::Content::ContentIsland Island();
|
|
52
|
-
#endif
|
|
53
52
|
|
|
54
53
|
// property ReactViewHost
|
|
55
54
|
ReactNative::IReactViewHost ReactViewHost() noexcept;
|
|
@@ -61,6 +60,9 @@ struct ReactNativeIsland
|
|
|
61
60
|
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual InternalRootVisual() noexcept;
|
|
62
61
|
void InternalRootVisual(winrt::Microsoft::ReactNative::Composition::Experimental::IVisual const &value) noexcept;
|
|
63
62
|
|
|
63
|
+
void OnMounted() noexcept;
|
|
64
|
+
void OnUnmounted() noexcept;
|
|
65
|
+
|
|
64
66
|
// property Size
|
|
65
67
|
winrt::Windows::Foundation::Size Size() noexcept;
|
|
66
68
|
void Size(winrt::Windows::Foundation::Size value) noexcept;
|
|
@@ -69,6 +71,8 @@ struct ReactNativeIsland
|
|
|
69
71
|
float ScaleFactor() noexcept;
|
|
70
72
|
void ScaleFactor(float value) noexcept;
|
|
71
73
|
|
|
74
|
+
float FontSizeMultiplier() const noexcept;
|
|
75
|
+
|
|
72
76
|
winrt::event_token SizeChanged(
|
|
73
77
|
winrt::Windows::Foundation::EventHandler<winrt::Microsoft::ReactNative::RootViewSizeChangedEventArgs> const
|
|
74
78
|
&handler) noexcept;
|
|
@@ -78,6 +82,7 @@ struct ReactNativeIsland
|
|
|
78
82
|
void AddRenderedVisual(const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept;
|
|
79
83
|
void RemoveRenderedVisual(const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept;
|
|
80
84
|
bool TrySetFocus() noexcept;
|
|
85
|
+
HWND GetHwndForParenting() noexcept;
|
|
81
86
|
|
|
82
87
|
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader Resources() noexcept;
|
|
83
88
|
void Resources(const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept;
|
|
@@ -87,10 +92,10 @@ struct ReactNativeIsland
|
|
|
87
92
|
|
|
88
93
|
winrt::Windows::Foundation::Size Measure(
|
|
89
94
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
90
|
-
const winrt::Windows::Foundation::Point &viewportOffset) const
|
|
95
|
+
const winrt::Windows::Foundation::Point &viewportOffset) const;
|
|
91
96
|
void Arrange(
|
|
92
97
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
93
|
-
const winrt::Windows::Foundation::Point &viewportOffset)
|
|
98
|
+
const winrt::Windows::Foundation::Point &viewportOffset);
|
|
94
99
|
|
|
95
100
|
winrt::Microsoft::ReactNative::FocusNavigationResult NavigateFocus(
|
|
96
101
|
const winrt::Microsoft::ReactNative::FocusNavigationRequest &request) noexcept;
|
|
@@ -126,6 +131,8 @@ struct ReactNativeIsland
|
|
|
126
131
|
winrt::event_token m_islandFrameworkClosedToken;
|
|
127
132
|
winrt::event_token m_islandAutomationProviderRequestedToken;
|
|
128
133
|
winrt::event_token m_islandStateChangedToken;
|
|
134
|
+
winrt::event_token m_islandConnectedToken;
|
|
135
|
+
winrt::event_token m_islandDisconnectedToken;
|
|
129
136
|
#endif
|
|
130
137
|
|
|
131
138
|
HWND m_hwnd{0};
|
|
@@ -133,10 +140,14 @@ struct ReactNativeIsland
|
|
|
133
140
|
bool m_isJSViewAttached{false};
|
|
134
141
|
bool m_hasRenderedVisual{false};
|
|
135
142
|
bool m_showingLoadingUI{false};
|
|
143
|
+
bool m_mounted{false};
|
|
136
144
|
IReactDispatcher m_uiDispatcher{nullptr};
|
|
137
145
|
winrt::IInspectable m_uiaProvider{nullptr};
|
|
138
146
|
int64_t m_rootTag{-1};
|
|
139
147
|
float m_scaleFactor{1.0};
|
|
148
|
+
float m_textScaleMultiplier{1.0};
|
|
149
|
+
winrt::Windows::UI::ViewManagement::UISettings::TextScaleFactorChanged_revoker m_textScaleChangedRevoker;
|
|
150
|
+
winrt::Windows::UI::ViewManagement::UISettings m_uiSettings{nullptr};
|
|
140
151
|
winrt::Windows::Foundation::Size m_size{0, 0};
|
|
141
152
|
winrt::Microsoft::ReactNative::ReactContext m_context;
|
|
142
153
|
winrt::Microsoft::ReactNative::IReactViewHost m_reactViewHost;
|
|
@@ -162,6 +173,12 @@ struct ReactNativeIsland
|
|
|
162
173
|
void UpdateRootVisualSize() noexcept;
|
|
163
174
|
void UpdateLoadingVisualSize() noexcept;
|
|
164
175
|
Composition::Experimental::IDrawingSurfaceBrush CreateLoadingVisualBrush() noexcept;
|
|
176
|
+
void ApplyConstraints(
|
|
177
|
+
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraintsIn,
|
|
178
|
+
facebook::react::LayoutConstraints &layoutConstraintsOut) const noexcept;
|
|
179
|
+
facebook::react::Size MeasureLoading(
|
|
180
|
+
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints) const noexcept;
|
|
181
|
+
void InitTextScaleMultiplier() noexcept;
|
|
165
182
|
};
|
|
166
183
|
|
|
167
184
|
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
@@ -24,8 +24,7 @@ RootComponentView::RootComponentView(
|
|
|
24
24
|
reactContext,
|
|
25
25
|
ComponentViewFeatures::Default &
|
|
26
26
|
~(ComponentViewFeatures::Background | ComponentViewFeatures::ShadowProps |
|
|
27
|
-
ComponentViewFeatures::NativeBorder)
|
|
28
|
-
false) {}
|
|
27
|
+
ComponentViewFeatures::NativeBorder)) {}
|
|
29
28
|
|
|
30
29
|
RootComponentView::~RootComponentView() {
|
|
31
30
|
if (auto rootView = m_wkRootView.get()) {
|
|
@@ -41,8 +40,8 @@ winrt::Microsoft::ReactNative::ComponentView RootComponentView::Create(
|
|
|
41
40
|
return winrt::make<RootComponentView>(compContext, tag, reactContext);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
RootComponentView *RootComponentView::rootComponentView() noexcept {
|
|
45
|
-
return this;
|
|
43
|
+
RootComponentView *RootComponentView::rootComponentView() const noexcept {
|
|
44
|
+
return const_cast<RootComponentView *>(this);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
void RootComponentView::updateLayoutMetrics(
|
|
@@ -92,12 +91,18 @@ bool RootComponentView::NavigateFocus(const winrt::Microsoft::ReactNative::Focus
|
|
|
92
91
|
? FocusManager::FindFirstFocusableElement(*this)
|
|
93
92
|
: FocusManager::FindLastFocusableElement(*this);
|
|
94
93
|
if (view) {
|
|
95
|
-
TrySetFocusedComponent(
|
|
94
|
+
TrySetFocusedComponent(
|
|
95
|
+
view,
|
|
96
|
+
request.Reason() == winrt::Microsoft::ReactNative::FocusNavigationReason::First
|
|
97
|
+
? winrt::Microsoft::ReactNative::FocusNavigationDirection::First
|
|
98
|
+
: winrt::Microsoft::ReactNative::FocusNavigationDirection::Last);
|
|
96
99
|
}
|
|
97
100
|
return view != nullptr;
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
bool RootComponentView::TrySetFocusedComponent(
|
|
103
|
+
bool RootComponentView::TrySetFocusedComponent(
|
|
104
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
105
|
+
winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept {
|
|
101
106
|
auto target = view;
|
|
102
107
|
auto selfView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(target);
|
|
103
108
|
if (selfView && !selfView->focusable()) {
|
|
@@ -111,7 +116,7 @@ bool RootComponentView::TrySetFocusedComponent(const winrt::Microsoft::ReactNati
|
|
|
111
116
|
return false;
|
|
112
117
|
|
|
113
118
|
auto losingFocusArgs = winrt::make<winrt::Microsoft::ReactNative::implementation::LosingFocusEventArgs>(
|
|
114
|
-
target, m_focusedComponent, target);
|
|
119
|
+
target, direction, m_focusedComponent, target);
|
|
115
120
|
if (m_focusedComponent) {
|
|
116
121
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_focusedComponent)
|
|
117
122
|
->onLosingFocus(losingFocusArgs);
|
|
@@ -119,7 +124,7 @@ bool RootComponentView::TrySetFocusedComponent(const winrt::Microsoft::ReactNati
|
|
|
119
124
|
|
|
120
125
|
if (losingFocusArgs.NewFocusedComponent()) {
|
|
121
126
|
auto gettingFocusArgs = winrt::make<winrt::Microsoft::ReactNative::implementation::GettingFocusEventArgs>(
|
|
122
|
-
target, m_focusedComponent, losingFocusArgs.NewFocusedComponent());
|
|
127
|
+
target, direction, m_focusedComponent, losingFocusArgs.NewFocusedComponent());
|
|
123
128
|
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(losingFocusArgs.NewFocusedComponent())
|
|
124
129
|
->onGettingFocus(gettingFocusArgs);
|
|
125
130
|
|
|
@@ -139,13 +144,16 @@ bool RootComponentView::TryMoveFocus(bool next) noexcept {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
Mso::Functor<bool(const winrt::Microsoft::ReactNative::ComponentView &)> fn =
|
|
142
|
-
[currentlyFocused = m_focusedComponent](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
147
|
+
[currentlyFocused = m_focusedComponent, next](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
143
148
|
if (view == currentlyFocused)
|
|
144
149
|
return false;
|
|
145
150
|
|
|
146
151
|
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(view)
|
|
147
152
|
->rootComponentView()
|
|
148
|
-
->TrySetFocusedComponent(
|
|
153
|
+
->TrySetFocusedComponent(
|
|
154
|
+
view,
|
|
155
|
+
next ? winrt::Microsoft::ReactNative::FocusNavigationDirection::Next
|
|
156
|
+
: winrt::Microsoft::ReactNative::FocusNavigationDirection::Previous);
|
|
149
157
|
};
|
|
150
158
|
|
|
151
159
|
return winrt::Microsoft::ReactNative::implementation::walkTree(m_focusedComponent, next, fn);
|
|
@@ -203,8 +211,35 @@ winrt::IInspectable RootComponentView::UiaProviderFromPoint(const POINT &ptPixel
|
|
|
203
211
|
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(view)->EnsureUiaProvider();
|
|
204
212
|
}
|
|
205
213
|
|
|
214
|
+
float RootComponentView::FontSizeMultiplier() const noexcept {
|
|
215
|
+
if (auto rootView = m_wkRootView.get()) {
|
|
216
|
+
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)
|
|
217
|
+
->FontSizeMultiplier();
|
|
218
|
+
}
|
|
219
|
+
assert(false);
|
|
220
|
+
return 1.0f;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
winrt::Microsoft::UI::Content::ContentIsland RootComponentView::parentContentIsland() noexcept {
|
|
224
|
+
if (auto rootView = m_wkRootView.get()) {
|
|
225
|
+
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)->Island();
|
|
226
|
+
}
|
|
227
|
+
return nullptr;
|
|
228
|
+
}
|
|
229
|
+
|
|
206
230
|
winrt::Microsoft::ReactNative::implementation::ClipState RootComponentView::getClipState() noexcept {
|
|
207
231
|
return winrt::Microsoft::ReactNative::implementation::ClipState::NoClip;
|
|
208
232
|
}
|
|
209
233
|
|
|
234
|
+
HWND RootComponentView::GetHwndForParenting() noexcept {
|
|
235
|
+
if (auto rootView = m_wkRootView.get()) {
|
|
236
|
+
auto hwnd = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)
|
|
237
|
+
->GetHwndForParenting();
|
|
238
|
+
if (hwnd)
|
|
239
|
+
return hwnd;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return base_type::GetHwndForParenting();
|
|
243
|
+
}
|
|
244
|
+
|
|
210
245
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -28,13 +28,17 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
|
|
|
28
28
|
|
|
29
29
|
winrt::Microsoft::ReactNative::ComponentView GetFocusedComponent() noexcept;
|
|
30
30
|
void SetFocusedComponent(const winrt::Microsoft::ReactNative::ComponentView &value) noexcept;
|
|
31
|
-
bool TrySetFocusedComponent(
|
|
31
|
+
bool TrySetFocusedComponent(
|
|
32
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
33
|
+
winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept;
|
|
32
34
|
|
|
33
35
|
bool NavigateFocus(const winrt::Microsoft::ReactNative::FocusNavigationRequest &request) noexcept;
|
|
34
36
|
|
|
35
37
|
bool TryMoveFocus(bool next) noexcept;
|
|
36
38
|
|
|
37
|
-
RootComponentView *rootComponentView() noexcept override;
|
|
39
|
+
RootComponentView *rootComponentView() const noexcept override;
|
|
40
|
+
|
|
41
|
+
winrt::Microsoft::UI::Content::ContentIsland parentContentIsland() noexcept;
|
|
38
42
|
|
|
39
43
|
// Index that visuals can be inserted into OuterVisual for debugging UI
|
|
40
44
|
uint32_t overlayIndex() noexcept;
|
|
@@ -42,6 +46,7 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
|
|
|
42
46
|
|
|
43
47
|
HRESULT GetFragmentRoot(IRawElementProviderFragmentRoot **pRetVal) noexcept;
|
|
44
48
|
winrt::Microsoft::ReactNative::implementation::ClipState getClipState() noexcept override;
|
|
49
|
+
float FontSizeMultiplier() const noexcept;
|
|
45
50
|
|
|
46
51
|
void updateLayoutMetrics(
|
|
47
52
|
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
@@ -59,6 +64,8 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
|
|
|
59
64
|
winrt::Microsoft::ReactNative::ComponentView FindFirstFocusableElement() noexcept;
|
|
60
65
|
winrt::Microsoft::ReactNative::ComponentView FindLastFocusableElement() noexcept;
|
|
61
66
|
|
|
67
|
+
HWND GetHwndForParenting() noexcept override;
|
|
68
|
+
|
|
62
69
|
private:
|
|
63
70
|
// should this be a ReactTaggedView? - It shouldn't actually matter since if the view is going away it should always
|
|
64
71
|
// be clearing its focus But being a reactTaggedView might make it easier to identify cases where that isn't
|