react-native-windows 0.76.8 → 0.76.9

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.
Files changed (128) hide show
  1. package/Libraries/Components/Button.windows.js +9 -0
  2. package/Libraries/Components/Pressable/Pressable.windows.js +9 -0
  3. package/Libraries/Components/TextInput/TextInput.windows.js +11 -1
  4. package/Libraries/Components/Touchable/TouchableBounce.windows.js +229 -0
  5. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +373 -0
  6. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -0
  7. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +8 -0
  8. package/Libraries/Components/View/View.windows.js +11 -1
  9. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  10. package/Libraries/Components/View/ViewAccessibility.windows.js +3 -0
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Image/Image.windows.js +7 -0
  13. package/Libraries/Modal/Modal.windows.js +4 -1
  14. package/Libraries/Text/Text.windows.js +14 -1
  15. package/Libraries/Text/TextProps.windows.js +3 -0
  16. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  17. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +97 -0
  18. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.h +53 -0
  19. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +160 -17
  20. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
  21. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -2
  22. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +428 -39
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +39 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +55 -33
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -3
  27. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +43 -5
  28. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  29. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.cpp +115 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.h +41 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +298 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.h +59 -0
  33. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +106 -56
  34. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
  35. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +163 -10
  36. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +17 -1
  37. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
  38. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
  39. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +348 -316
  40. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  41. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +78 -0
  42. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  43. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +22 -0
  44. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -5
  45. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +99 -37
  46. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  47. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +81 -22
  48. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +21 -2
  49. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +6 -1
  50. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +41 -37
  51. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +76 -33
  52. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +8 -2
  53. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  54. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  55. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  56. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
  57. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
  58. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +1 -1
  59. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +15 -1
  60. package/Microsoft.ReactNative/IReactContext.cpp +2 -2
  61. package/Microsoft.ReactNative/IReactContext.h +1 -1
  62. package/Microsoft.ReactNative/IReactContext.idl +2 -2
  63. package/Microsoft.ReactNative/IReactPackageBuilder.idl +3 -3
  64. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +97 -87
  65. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +4 -0
  66. package/Microsoft.ReactNative/Modules/AlertModule.cpp +9 -4
  67. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +1 -1
  68. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +32 -35
  69. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +7 -4
  70. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +1 -1
  71. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +2 -2
  72. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +2 -2
  73. package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +1 -1
  74. package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
  75. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +3 -3
  76. package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +1 -1
  77. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +7 -5
  78. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -1
  79. package/Microsoft.ReactNative/Modules/Timing.cpp +2 -2
  80. package/Microsoft.ReactNative/ReactHost/IReactInstance.h +5 -0
  81. package/Microsoft.ReactNative/ReactHost/React.h +0 -3
  82. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +36 -12
  83. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  84. package/Microsoft.ReactNative/ReactNativeHost.cpp +9 -4
  85. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  86. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +3 -3
  87. package/Microsoft.ReactNative/ReactPackageBuilder.h +4 -4
  88. package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -2
  89. package/Microsoft.ReactNative/Views/DevMenu.cpp +6 -6
  90. package/Microsoft.ReactNative/Views/DevMenu.h +1 -1
  91. package/Microsoft.ReactNative/XamlUIService.cpp +13 -7
  92. package/Microsoft.ReactNative/XamlUIService.h +4 -1
  93. package/Microsoft.ReactNative/XamlUIService.idl +2 -0
  94. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +6 -2
  95. package/Microsoft.ReactNative.Cxx/NativeModules.h +29 -0
  96. package/Microsoft.ReactNative.Cxx/ReactContext.h +1 -1
  97. package/Microsoft.ReactNative.Cxx/XamlUtils.h +12 -0
  98. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  99. package/PropertySheets/React.Cpp.props +3 -0
  100. package/PropertySheets/WebView2.props +1 -1
  101. package/PropertySheets/WinUI.props +5 -4
  102. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  103. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  104. package/Shared/InspectorPackagerConnection.cpp +2 -5
  105. package/Shared/InspectorPackagerConnection.h +2 -2
  106. package/Shared/Networking/WinRTWebSocketResource.cpp +369 -7
  107. package/Shared/Networking/WinRTWebSocketResource.h +118 -0
  108. package/Shared/Shared.vcxitems +12 -5
  109. package/Shared/Shared.vcxitems.filters +11 -4
  110. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
  111. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
  112. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
  113. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
  114. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
  115. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
  116. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
  117. package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
  118. package/codegen/react/components/rnwcore/ModalHostView.g.h +279 -0
  119. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
  120. package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
  121. package/codegen/react/components/rnwcore/Switch.g.h +263 -0
  122. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
  123. package/just-task.js +1 -1
  124. package/package.json +3 -3
  125. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
  126. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  127. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  128. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -9,7 +9,6 @@
9
9
  #include <IReactContext.h>
10
10
  #include <React.h>
11
11
  #include <Views/DevMenu.h>
12
- #include <Views/ShadowNodeBase.h>
13
12
  #include <windows.h>
14
13
  #include <windowsx.h>
15
14
  #include <winrt/Windows.UI.Core.h>
@@ -142,9 +141,8 @@ struct CompositionInputKeyboardSource : winrt::implements<
142
141
 
143
142
  CompositionEventHandler::CompositionEventHandler(
144
143
  const winrt::Microsoft::ReactNative::ReactContext &context,
145
- const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland,
146
- const int fragmentTag)
147
- : m_fragmentTag(fragmentTag), m_context(context), m_wkRootView(reactNativeIsland) {}
144
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland)
145
+ : m_context(context), m_wkRootView(reactNativeIsland) {}
148
146
 
149
147
  void CompositionEventHandler::Initialize() noexcept {
150
148
  #ifdef USE_WINUI3
@@ -198,6 +196,20 @@ void CompositionEventHandler::Initialize() noexcept {
198
196
  }
199
197
  });
200
198
 
199
+ m_pointerExitedToken = pointerSource.PointerExited([wkThis = weak_from_this()](
200
+ winrt::Microsoft::UI::Input::InputPointerSource const &,
201
+ winrt::Microsoft::UI::Input::PointerEventArgs const &args) {
202
+ if (auto strongThis = wkThis.lock()) {
203
+ if (auto strongRootView = strongThis->m_wkRootView.get()) {
204
+ if (strongThis->SurfaceId() == -1)
205
+ return;
206
+ auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
207
+ args.CurrentPoint(), strongRootView.ScaleFactor());
208
+ strongThis->onPointerExited(pp, args.KeyModifiers());
209
+ }
210
+ }
211
+ });
212
+
201
213
  m_pointerCaptureLostToken =
202
214
  pointerSource.PointerCaptureLost([wkThis = weak_from_this()](
203
215
  winrt::Microsoft::UI::Input::InputPointerSource const &,
@@ -348,11 +360,8 @@ facebook::react::SurfaceId CompositionEventHandler::SurfaceId() const noexcept {
348
360
 
349
361
  winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView &
350
362
  CompositionEventHandler::RootComponentView() const noexcept {
351
- auto rootComponentViewDescriptor = (::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties()))
352
- ->GetViewRegistry()
353
- .componentViewDescriptorWithTag(SurfaceId());
354
- return *rootComponentViewDescriptor.view
355
- .as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>();
363
+ auto island = m_wkRootView.get();
364
+ return *winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(island)->GetComponentView();
356
365
  }
357
366
 
358
367
  void CompositionEventHandler::onPointerWheelChanged(
@@ -365,6 +374,9 @@ void CompositionEventHandler::onPointerWheelChanged(
365
374
  facebook::react::Point ptLocal;
366
375
  facebook::react::Point ptScaled = {static_cast<float>(position.X), static_cast<float>(position.Y)};
367
376
 
377
+ // In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we
378
+ // need to apply the current origin
379
+ ptScaled += RootComponentView().layoutMetrics().frame.origin;
368
380
  auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
369
381
 
370
382
  if (tag == -1)
@@ -977,6 +989,11 @@ void CompositionEventHandler::getTargetPointerArgs(
977
989
  tag = -1;
978
990
 
979
991
  ptScaled = {position.X, position.Y};
992
+
993
+ // In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we need
994
+ // to apply the current origin
995
+ ptScaled += RootComponentView().layoutMetrics().frame.origin;
996
+
980
997
  if (std::find(m_capturedPointers.begin(), m_capturedPointers.end(), pointerId) != m_capturedPointers.end()) {
981
998
  assert(m_pointerCapturingComponentTag != -1);
982
999
  tag = m_pointerCapturingComponentTag;
@@ -989,30 +1006,7 @@ void CompositionEventHandler::getTargetPointerArgs(
989
1006
  ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
990
1007
  }
991
1008
  } else {
992
- if (m_fragmentTag == -1) {
993
- tag = RootComponentView().hitTest(ptScaled, ptLocal);
994
- return;
995
- }
996
-
997
- // check if the fragment tag exists
998
- if (!fabricuiManager->GetViewRegistry().findComponentViewWithTag(m_fragmentTag)) {
999
- return;
1000
- }
1001
-
1002
- auto fagmentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(m_fragmentTag).view;
1003
- auto fagmentchildren = fagmentView.Children();
1004
-
1005
- // call the hitTest with the fargment as the RootComponent
1006
- for (auto index = fagmentchildren.Size(); index > 0; index--) {
1007
- auto childView = fagmentchildren.GetAt(index - 1);
1008
- auto targetTag =
1009
- winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(childView)->hitTest(
1010
- ptScaled, ptLocal);
1011
- if (targetTag != -1) {
1012
- tag = targetTag;
1013
- break;
1014
- }
1015
- }
1009
+ tag = RootComponentView().hitTest(ptScaled, ptLocal);
1016
1010
  }
1017
1011
  }
1018
1012
 
@@ -1083,6 +1077,34 @@ void CompositionEventHandler::onPointerMoved(
1083
1077
  }
1084
1078
  }
1085
1079
 
1080
+ void CompositionEventHandler::onPointerExited(
1081
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
1082
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
1083
+ if (SurfaceId() == -1)
1084
+ return;
1085
+
1086
+ int pointerId = pointerPoint.PointerId();
1087
+ auto position = pointerPoint.Position();
1088
+
1089
+ if (std::shared_ptr<FabricUIManager> fabricuiManager =
1090
+ ::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties())) {
1091
+ facebook::react::Tag tag = -1;
1092
+ facebook::react::Point ptLocal, ptScaled;
1093
+ getTargetPointerArgs(fabricuiManager, pointerPoint, tag, ptScaled, ptLocal);
1094
+
1095
+ tag = -1;
1096
+
1097
+ auto args = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerRoutedEventArgs>(
1098
+ m_context, tag, pointerPoint, keyModifiers);
1099
+
1100
+ facebook::react::PointerEvent pointerEvent = CreatePointerEventFromIncompleteHoverData(ptScaled, ptLocal);
1101
+
1102
+ auto handler = [](std::vector<winrt::Microsoft::ReactNative::ComponentView> &eventPathViews) {};
1103
+
1104
+ HandleIncomingPointerEvent(pointerEvent, nullptr, pointerPoint, keyModifiers, handler);
1105
+ }
1106
+ }
1107
+
1086
1108
  void CompositionEventHandler::onPointerPressed(
1087
1109
  const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
1088
1110
  winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
@@ -31,8 +31,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
31
31
  public:
32
32
  CompositionEventHandler(
33
33
  const winrt::Microsoft::ReactNative::ReactContext &context,
34
- const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland,
35
- const int fragmentTag);
34
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland);
36
35
  virtual ~CompositionEventHandler();
37
36
 
38
37
  void Initialize() noexcept;
@@ -58,6 +57,9 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
58
57
  void onPointerMoved(
59
58
  const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
60
59
  winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
60
+ void onPointerExited(
61
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
62
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
61
63
  void onPointerWheelChanged(
62
64
  const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
63
65
  winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
@@ -152,7 +154,6 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
152
154
 
153
155
  std::map<PointerId, ActiveTouch> m_activeTouches; // iOS is map of touch event args to ActiveTouch..?
154
156
  PointerId m_touchId = 0;
155
- int m_fragmentTag = -1;
156
157
 
157
158
  std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
158
159
  winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
@@ -171,6 +172,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
171
172
  winrt::event_token m_pointerMovedToken;
172
173
  winrt::event_token m_pointerWheelChangedToken;
173
174
  winrt::event_token m_pointerCaptureLostToken;
175
+ winrt::event_token m_pointerExitedToken;
174
176
  winrt::event_token m_keyDownToken;
175
177
  winrt::event_token m_keyUpToken;
176
178
  winrt::event_token m_characterReceivedToken;
@@ -27,6 +27,25 @@ HRESULT __stdcall CompositionRootAutomationProvider::GetRuntimeId(SAFEARRAY **pR
27
27
 
28
28
  *pRetVal = nullptr;
29
29
 
30
+ if (!m_island)
31
+ return E_FAIL;
32
+
33
+ *pRetVal = SafeArrayCreateVector(VT_I4, 0, 3);
34
+ if (*pRetVal == nullptr)
35
+ return E_OUTOFMEMORY;
36
+
37
+ auto rgiRuntimeId = static_cast<int *>((*pRetVal)->pvData);
38
+
39
+ rgiRuntimeId[0] = UiaAppendRuntimeId;
40
+ rgiRuntimeId[1] = 0;
41
+ rgiRuntimeId[2] = 0;
42
+
43
+ if (auto rootView = m_wkRootView.get()) {
44
+ auto tag = rootView.RootTag();
45
+ rgiRuntimeId[1] = LODWORD(tag);
46
+ rgiRuntimeId[2] = HIDWORD(tag);
47
+ }
48
+
30
49
  return S_OK;
31
50
  }
32
51
 
@@ -153,8 +172,18 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_FragmentRoot(IRawElemen
153
172
  if (pRetVal == nullptr)
154
173
  return E_POINTER;
155
174
 
156
- AddRef();
157
- *pRetVal = this;
175
+ *pRetVal = nullptr;
176
+
177
+ #ifdef USE_EXPERIMENTAL_WINUI3
178
+ if (m_island) {
179
+ auto parentRoot = m_island.FragmentRootAutomationProvider();
180
+ auto spFragment = parentRoot.try_as<IRawElementProviderFragmentRoot>();
181
+ if (spFragment) {
182
+ *pRetVal = spFragment.detach();
183
+ return S_OK;
184
+ }
185
+ }
186
+ #endif
158
187
 
159
188
  return S_OK;
160
189
  }
@@ -167,7 +196,7 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_ProviderOptions(Provide
167
196
  return S_OK;
168
197
  }
169
198
 
170
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
199
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
171
200
  CompositionRootAutomationProvider::rootComponentView() noexcept {
172
201
  if (auto rootView = m_wkRootView.get()) {
173
202
  auto innerRootView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView);
@@ -249,8 +278,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::Navigate(
249
278
  if (pRetVal == nullptr)
250
279
  return E_POINTER;
251
280
 
252
- // Fragment roots do not enable navigation to a parent or siblings; navigation among fragment roots is handled by the
253
- // default window providers. Elements in fragments must navigate only to other elements within that fragment.
254
281
  if (direction == NavigateDirection_FirstChild || direction == NavigateDirection_LastChild) {
255
282
  if (auto rootView = rootComponentView()) {
256
283
  auto uiaProvider = rootView->EnsureUiaProvider();
@@ -260,6 +287,17 @@ HRESULT __stdcall CompositionRootAutomationProvider::Navigate(
260
287
  return S_OK;
261
288
  }
262
289
  }
290
+ } else if (direction == NavigateDirection_Parent) {
291
+ #ifdef USE_EXPERIMENTAL_WINUI3
292
+ if (m_island) {
293
+ auto parent = m_island.ParentAutomationProvider();
294
+ auto spFragment = parent.try_as<IRawElementProviderFragment>();
295
+ if (spFragment) {
296
+ *pRetVal = spFragment.detach();
297
+ return S_OK;
298
+ }
299
+ }
300
+ #endif
263
301
  }
264
302
  *pRetVal = nullptr;
265
303
  return S_OK;
@@ -63,7 +63,8 @@ class CompositionRootAutomationProvider : public winrt::implements<
63
63
  };
64
64
 
65
65
  private:
66
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *rootComponentView() noexcept;
66
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
67
+ rootComponentView() noexcept;
67
68
 
68
69
  HRESULT AdvisePropertiesAdded(SAFEARRAY *psaProperties) noexcept;
69
70
  HRESULT AdvisePropertiesRemoved(SAFEARRAY *psaProperties) noexcept;
@@ -0,0 +1,115 @@
1
+ #include "pch.h"
2
+ #include <Fabric/ComponentView.h>
3
+ #include <Fabric/Composition/ParagraphComponentView.h>
4
+ #include <Fabric/Composition/TextInput/WindowsTextInputComponentView.h>
5
+ #include <Unicode.h>
6
+ #include "CompositionTextRangeProvider.h"
7
+ #include "RootComponentView.h"
8
+ #include "UiaHelpers.h"
9
+
10
+ namespace winrt::Microsoft::ReactNative::implementation {
11
+
12
+ CompositionTextProvider::CompositionTextProvider(
13
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
14
+ CompositionDynamicAutomationProvider *parentProvider) noexcept
15
+ : m_view{componentView} {
16
+ m_parentProvider.copy_from(parentProvider);
17
+ EnsureTextRangeProvider();
18
+ }
19
+
20
+ void CompositionTextProvider::EnsureTextRangeProvider() {
21
+ auto strongView = m_view.view();
22
+
23
+ if (!strongView)
24
+ return;
25
+
26
+ if (!m_textRangeProvider) {
27
+ m_textRangeProvider =
28
+ winrt::make<CompositionTextRangeProvider>(
29
+ strongView.as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), m_parentProvider.get())
30
+ .try_as<ITextRangeProvider>();
31
+ }
32
+ }
33
+
34
+ HRESULT __stdcall CompositionTextProvider::get_DocumentRange(ITextRangeProvider **pRetVal) {
35
+ if (pRetVal == nullptr)
36
+ return E_POINTER;
37
+ auto strongView = m_view.view();
38
+
39
+ if (!strongView)
40
+ return UIA_E_ELEMENTNOTAVAILABLE;
41
+
42
+ if (m_textRangeProvider == nullptr)
43
+ return UIA_E_ELEMENTNOTAVAILABLE;
44
+
45
+ m_textRangeProvider.copy_to(pRetVal);
46
+ return S_OK;
47
+ }
48
+
49
+ HRESULT __stdcall CompositionTextProvider::get_SupportedTextSelection(SupportedTextSelection *pRetVal) {
50
+ if (pRetVal == nullptr)
51
+ return E_POINTER;
52
+ auto strongView = m_view.view();
53
+
54
+ if (!strongView)
55
+ return UIA_E_ELEMENTNOTAVAILABLE;
56
+
57
+ if (strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>()) {
58
+ *pRetVal = SupportedTextSelection_Single;
59
+ } else if (
60
+ auto textView =
61
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ParagraphComponentView>()) {
62
+ auto props = std::static_pointer_cast<const facebook::react::ParagraphProps>(textView->props());
63
+ if (props == nullptr)
64
+ return UIA_E_ELEMENTNOTAVAILABLE;
65
+ *pRetVal = props->isSelectable ? SupportedTextSelection_Single : SupportedTextSelection_None;
66
+ } else {
67
+ *pRetVal = SupportedTextSelection_None;
68
+ }
69
+
70
+ return S_OK;
71
+ }
72
+
73
+ HRESULT __stdcall CompositionTextProvider::GetSelection(SAFEARRAY **pRetVal) {
74
+ // no-op
75
+ *pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 0);
76
+ return S_OK;
77
+ }
78
+
79
+ HRESULT __stdcall CompositionTextProvider::GetVisibleRanges(SAFEARRAY **pRetVal) {
80
+ *pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1);
81
+ if (m_textRangeProvider == nullptr)
82
+ return UIA_E_ELEMENTNOTAVAILABLE;
83
+ LONG pos = 0;
84
+ return SafeArrayPutElement(*pRetVal, &pos, m_textRangeProvider.get());
85
+ }
86
+
87
+ HRESULT __stdcall CompositionTextProvider::RangeFromChild(
88
+ IRawElementProviderSimple *childElement,
89
+ ITextRangeProvider **pRetVal) {
90
+ // no-op
91
+ *pRetVal = nullptr;
92
+ return S_OK;
93
+ }
94
+
95
+ HRESULT __stdcall CompositionTextProvider::RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal) {
96
+ // no-op
97
+ if (m_textRangeProvider == nullptr)
98
+ return UIA_E_ELEMENTNOTAVAILABLE;
99
+ m_textRangeProvider.copy_to(pRetVal);
100
+ return S_OK;
101
+ }
102
+ HRESULT __stdcall CompositionTextProvider::GetCaretRange(BOOL *isActive, ITextRangeProvider **pRetVal) {
103
+ // no-op
104
+ *pRetVal = nullptr;
105
+ return S_OK;
106
+ }
107
+
108
+ HRESULT __stdcall CompositionTextProvider::RangeFromAnnotation(
109
+ IRawElementProviderSimple *annotationElement,
110
+ ITextRangeProvider **pRetVal) {
111
+ // no-op
112
+ *pRetVal = nullptr;
113
+ return S_OK;
114
+ }
115
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,41 @@
1
+ #pragma once
2
+
3
+ #include <Fabric/Composition/CompositionDynamicAutomationProvider.h>
4
+ #include <Fabric/Composition/CompositionViewComponentView.h>
5
+ #include <Fabric/ReactTaggedView.h>
6
+ #include <UIAutomation.h>
7
+ #include <inspectable.h>
8
+ #include <uiautomationcore.h>
9
+
10
+ namespace winrt::Microsoft::ReactNative::implementation {
11
+
12
+ class CompositionTextProvider : public winrt::implements<CompositionTextProvider, ITextProvider, ITextProvider2> {
13
+ public:
14
+ CompositionTextProvider(
15
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
16
+ CompositionDynamicAutomationProvider *parentProvider) noexcept;
17
+
18
+ // inherited via ITextProvider
19
+ virtual HRESULT __stdcall get_DocumentRange(ITextRangeProvider **pRetVal) override;
20
+ virtual HRESULT __stdcall get_SupportedTextSelection(SupportedTextSelection *pRetVal) override;
21
+ virtual HRESULT __stdcall GetSelection(SAFEARRAY **pRetVal) override;
22
+ virtual HRESULT __stdcall GetVisibleRanges(SAFEARRAY **pRetVal) override;
23
+ virtual HRESULT __stdcall RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal)
24
+ override;
25
+ virtual HRESULT __stdcall RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal) override;
26
+
27
+ // inherited via ITextProvider2
28
+ virtual HRESULT __stdcall GetCaretRange(BOOL *isActive, ITextRangeProvider **pRetVal) override;
29
+ virtual HRESULT __stdcall RangeFromAnnotation(
30
+ IRawElementProviderSimple *annotationElement,
31
+ ITextRangeProvider **pRetVal) override;
32
+
33
+ void EnsureTextRangeProvider();
34
+
35
+ private:
36
+ ::Microsoft::ReactNative::ReactTaggedView m_view;
37
+ winrt::com_ptr<ITextRangeProvider> m_textRangeProvider;
38
+ winrt::com_ptr<CompositionDynamicAutomationProvider> m_parentProvider;
39
+ };
40
+
41
+ } // namespace winrt::Microsoft::ReactNative::implementation