react-native-windows 0.74.46 → 0.74.48

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 (51) hide show
  1. package/Directory.Build.props +1 -1
  2. package/Libraries/Components/View/View.windows.js +13 -5
  3. package/Libraries/Components/View/ViewAccessibility.d.ts +67 -0
  4. package/Libraries/Components/View/ViewPropTypes.windows.js +2 -0
  5. package/Libraries/NativeComponent/BaseViewConfig.windows.js +4 -0
  6. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +1 -1
  7. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +47 -0
  8. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +1 -0
  9. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +81 -94
  10. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -1
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.cpp +115 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.h +41 -0
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +319 -0
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.h +59 -0
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +48 -1
  16. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +43 -34
  17. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +2 -2
  18. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +11 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +152 -17
  20. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +5 -0
  21. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +2 -1
  22. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +2 -1
  23. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +43 -1
  24. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +27 -2
  25. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +22 -4
  26. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +16 -3
  27. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +24 -0
  28. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +4 -0
  29. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/MouseEvent.h +20 -0
  30. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +133 -32
  31. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +12 -0
  32. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +1 -3
  33. package/Microsoft.ReactNative/packages.lock.json +30 -106
  34. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -1
  35. package/Microsoft.ReactNative.Managed/packages.lock.json +3 -3
  36. package/Microsoft.ReactNative.Managed.CodeGen/Microsoft.ReactNative.Managed.CodeGen.csproj +1 -1
  37. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Debug.pubxml +1 -1
  38. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Release.pubxml +1 -1
  39. package/Microsoft.ReactNative.Managed.CodeGen/packages.lock.json +3 -3
  40. package/PropertySheets/External/Microsoft.ReactNative.WindowsSdk.Default.props +4 -4
  41. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  42. package/PropertySheets/JSEngine.props +1 -1
  43. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +4 -4
  44. package/ReactCommon/cgmanifest.json +1 -1
  45. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +26 -4
  46. package/Scripts/Tfs/Start-TestServers.ps1 +2 -1
  47. package/Scripts/rnw-dependencies.ps1 +38 -25
  48. package/Shared/Shared.vcxitems +6 -0
  49. package/Shared/Shared.vcxitems.filters +8 -0
  50. package/package.json +3 -3
  51. package/fmt/packages.lock.json +0 -13
@@ -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
@@ -0,0 +1,319 @@
1
+ #include "pch.h"
2
+ #include "CompositionTextRangeProvider.h"
3
+ #include <Fabric/ComponentView.h>
4
+ #include <Fabric/Composition/ParagraphComponentView.h>
5
+ #include <Fabric/Composition/TextInput/WindowsTextInputComponentView.h>
6
+ #include <Fabric/platform/react/renderer/graphics/HostPlatformColor.h>
7
+ #include <Unicode.h>
8
+ #include "RootComponentView.h"
9
+ #include "UiaHelpers.h"
10
+
11
+ namespace winrt::Microsoft::ReactNative::implementation {
12
+
13
+ CompositionTextRangeProvider::CompositionTextRangeProvider(
14
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
15
+ CompositionDynamicAutomationProvider *parentProvider) noexcept
16
+ : m_view{componentView} {
17
+ m_parentProvider.copy_from(parentProvider);
18
+ }
19
+
20
+ HRESULT __stdcall CompositionTextRangeProvider::Clone(ITextRangeProvider **pRetVal) {
21
+ if (pRetVal == nullptr)
22
+ return E_POINTER;
23
+
24
+ auto clone = winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionTextRangeProvider>(
25
+ m_view.view().as<winrt::Microsoft::ReactNative::Composition::ComponentView>(), m_parentProvider.get());
26
+ *pRetVal = clone.detach();
27
+ return S_OK;
28
+ }
29
+
30
+ HRESULT __stdcall CompositionTextRangeProvider::Compare(ITextRangeProvider *range, BOOL *pRetVal) {
31
+ if (pRetVal == nullptr)
32
+ return E_POINTER;
33
+ if (range == nullptr) {
34
+ *pRetVal = FALSE;
35
+ return S_OK;
36
+ }
37
+
38
+ // Try to cast to our type , considering provider only supports a single range per view
39
+ auto other = dynamic_cast<CompositionTextRangeProvider *>(range);
40
+ if (other && other->m_view.view() == m_view.view()) {
41
+ *pRetVal = TRUE;
42
+ } else {
43
+ *pRetVal = FALSE;
44
+ }
45
+ return S_OK;
46
+ }
47
+
48
+ HRESULT __stdcall CompositionTextRangeProvider::CompareEndpoints(
49
+ TextPatternRangeEndpoint endpoint,
50
+ ITextRangeProvider *targetRange,
51
+ TextPatternRangeEndpoint targetEndpoint,
52
+ int *pRetVal) {
53
+ if (pRetVal == nullptr)
54
+ return E_POINTER;
55
+
56
+ // For a single-range provider, always equal:
57
+ *pRetVal = 0;
58
+ return S_OK;
59
+ }
60
+
61
+ HRESULT __stdcall CompositionTextRangeProvider::ExpandToEnclosingUnit(TextUnit unit) {
62
+ // no-op
63
+ return S_OK;
64
+ }
65
+
66
+ HRESULT __stdcall CompositionTextRangeProvider::FindAttribute(
67
+ TEXTATTRIBUTEID attributeId,
68
+ VARIANT val,
69
+ BOOL backward,
70
+ ITextRangeProvider **pRetVal) {
71
+ // no-op
72
+ *pRetVal = nullptr;
73
+ return S_OK;
74
+ }
75
+
76
+ HRESULT __stdcall CompositionTextRangeProvider::FindText(
77
+ BSTR text,
78
+ BOOL backward,
79
+ BOOL ignoreCase,
80
+ ITextRangeProvider **pRetVal) {
81
+ // no-op
82
+ *pRetVal = nullptr;
83
+ return S_OK;
84
+ }
85
+
86
+ HRESULT __stdcall CompositionTextRangeProvider::GetAttributeValue(TEXTATTRIBUTEID attributeId, VARIANT *pRetVal) {
87
+ if (pRetVal == nullptr)
88
+ return E_POINTER;
89
+ auto strongView = m_view.view();
90
+
91
+ if (!strongView)
92
+ return UIA_E_ELEMENTNOTAVAILABLE;
93
+
94
+ auto props = std::static_pointer_cast<const facebook::react::ParagraphProps>(
95
+ winrt::get_self<ComponentView>(strongView)->props());
96
+
97
+ auto textinputProps = std::static_pointer_cast<const facebook::react::WindowsTextInputProps>(
98
+ winrt::get_self<ComponentView>(strongView)->props());
99
+
100
+ auto isTextInput =
101
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>();
102
+
103
+ if (props == nullptr)
104
+ return UIA_E_ELEMENTNOTAVAILABLE;
105
+
106
+ if (attributeId == UIA_BackgroundColorAttributeId) {
107
+ pRetVal->vt = VT_I4;
108
+ pRetVal->lVal = (*props->backgroundColor).AsColorRefWithAlpha();
109
+ } else if (attributeId == UIA_CapStyleAttributeId) {
110
+ pRetVal->vt = VT_I4;
111
+ auto fontVariant = facebook::react::FontVariant::Default;
112
+ auto textTransform = facebook::react::TextTransform::None;
113
+ if (props->textAttributes.fontVariant.has_value()) {
114
+ fontVariant = props->textAttributes.fontVariant.value();
115
+ }
116
+ if (props->textAttributes.textTransform.has_value()) {
117
+ textTransform = props->textAttributes.textTransform.value();
118
+ }
119
+ if (fontVariant == facebook::react::FontVariant::SmallCaps) {
120
+ pRetVal->lVal = CapStyle_SmallCap;
121
+ } else if (textTransform == facebook::react::TextTransform::Capitalize) {
122
+ pRetVal->lVal = CapStyle_Titling;
123
+ } else if (textTransform == facebook::react::TextTransform::Lowercase) {
124
+ pRetVal->lVal = CapStyle_None;
125
+ } else if (textTransform == facebook::react::TextTransform::Uppercase) {
126
+ pRetVal->lVal = CapStyle_AllCap;
127
+ }
128
+ } else if (attributeId == UIA_FontNameAttributeId) {
129
+ pRetVal->vt = VT_BSTR;
130
+ auto fontName = props->textAttributes.fontFamily;
131
+ if (fontName.empty()) {
132
+ fontName = "Segoe UI";
133
+ }
134
+ std::wstring wfontName(fontName.begin(), fontName.end());
135
+ pRetVal->bstrVal = SysAllocString(wfontName.c_str());
136
+ } else if (attributeId == UIA_FontSizeAttributeId) {
137
+ pRetVal->vt = VT_R8;
138
+ pRetVal->dblVal = props->textAttributes.fontSize;
139
+ } else if (attributeId == UIA_FontWeightAttributeId) {
140
+ if (props->textAttributes.fontWeight.has_value()) {
141
+ pRetVal->vt = VT_I4;
142
+ pRetVal->lVal = static_cast<long>(props->textAttributes.fontWeight.value());
143
+ }
144
+ } else if (attributeId == UIA_ForegroundColorAttributeId) {
145
+ pRetVal->vt = VT_I4;
146
+ pRetVal->lVal = (*props->textAttributes.foregroundColor).AsColorRefWithAlpha();
147
+ } else if (attributeId == UIA_IsItalicAttributeId) {
148
+ pRetVal->vt = VT_BOOL;
149
+ pRetVal->boolVal = (props->textAttributes.fontStyle.has_value() &&
150
+ props->textAttributes.fontStyle.value() == facebook::react::FontStyle::Italic)
151
+ ? VARIANT_TRUE
152
+ : VARIANT_FALSE;
153
+ } else if (attributeId == UIA_IsReadOnlyAttributeId) {
154
+ pRetVal->vt = VT_BOOL;
155
+ pRetVal->boolVal = isTextInput ? textinputProps->editable ? VARIANT_FALSE : VARIANT_TRUE : VARIANT_TRUE;
156
+ } else if (attributeId == UIA_HorizontalTextAlignmentAttributeId) {
157
+ pRetVal->vt = VT_I4;
158
+ auto textAlign = facebook::react::TextAlignment::Center;
159
+ if (props->textAttributes.alignment.has_value()) {
160
+ textAlign = props->textAttributes.alignment.value();
161
+ }
162
+ if (textAlign == facebook::react::TextAlignment::Left) {
163
+ pRetVal->lVal = HorizontalTextAlignment_Left;
164
+ } else if (textAlign == facebook::react::TextAlignment::Right) {
165
+ pRetVal->lVal = HorizontalTextAlignment_Right;
166
+ } else if (textAlign == facebook::react::TextAlignment::Center) {
167
+ pRetVal->lVal = HorizontalTextAlignment_Centered;
168
+ } else if (textAlign == facebook::react::TextAlignment::Justified) {
169
+ pRetVal->lVal = HorizontalTextAlignment_Justified;
170
+ } else if (textAlign == facebook::react::TextAlignment::Natural) {
171
+ pRetVal->lVal = HorizontalTextAlignment_Left;
172
+ }
173
+ } else if (attributeId == UIA_StrikethroughColorAttributeId) {
174
+ if (props->textAttributes.textDecorationLineType.has_value() &&
175
+ (props->textAttributes.textDecorationLineType.value() ==
176
+ facebook::react::TextDecorationLineType::Strikethrough ||
177
+ props->textAttributes.textDecorationLineType.value() ==
178
+ facebook::react::TextDecorationLineType::UnderlineStrikethrough)) {
179
+ pRetVal->vt = VT_I4;
180
+ pRetVal->lVal = (*props->textAttributes.textDecorationColor).AsColorRefWithAlpha();
181
+ }
182
+ } else if (attributeId == UIA_StrikethroughStyleAttributeId) {
183
+ if (props->textAttributes.textDecorationLineType.has_value() &&
184
+ (props->textAttributes.textDecorationLineType.value() ==
185
+ facebook::react::TextDecorationLineType::Strikethrough ||
186
+ props->textAttributes.textDecorationLineType.value() ==
187
+ facebook::react::TextDecorationLineType::UnderlineStrikethrough)) {
188
+ pRetVal->vt = VT_I4;
189
+ auto style = props->textAttributes.textDecorationStyle.value();
190
+ pRetVal->lVal = GetTextDecorationLineStyle(style);
191
+ }
192
+ } else if (attributeId == UIA_UnderlineColorAttributeId) {
193
+ if (props->textAttributes.textDecorationLineType.has_value() &&
194
+ (props->textAttributes.textDecorationLineType.value() == facebook::react::TextDecorationLineType::Underline ||
195
+ props->textAttributes.textDecorationLineType.value() ==
196
+ facebook::react::TextDecorationLineType::UnderlineStrikethrough)) {
197
+ pRetVal->vt = VT_I4;
198
+ pRetVal->lVal = (*props->textAttributes.textDecorationColor).AsColorRefWithAlpha();
199
+ }
200
+ } else if (attributeId == UIA_UnderlineStyleAttributeId) {
201
+ if (props->textAttributes.textDecorationLineType.has_value() &&
202
+ (props->textAttributes.textDecorationLineType.value() == facebook::react::TextDecorationLineType::Underline ||
203
+ props->textAttributes.textDecorationLineType.value() ==
204
+ facebook::react::TextDecorationLineType::UnderlineStrikethrough)) {
205
+ pRetVal->vt = VT_I4;
206
+ auto style = props->textAttributes.textDecorationStyle.value();
207
+ pRetVal->lVal = GetTextDecorationLineStyle(style);
208
+ }
209
+ }
210
+ return S_OK;
211
+ }
212
+
213
+ HRESULT __stdcall CompositionTextRangeProvider::GetBoundingRectangles(SAFEARRAY **pRetVal) {
214
+ if (pRetVal == nullptr)
215
+ return E_POINTER;
216
+ UiaRect rect;
217
+ auto hr = m_parentProvider->get_BoundingRectangle(&rect);
218
+ if (FAILED(hr))
219
+ return hr;
220
+ *pRetVal = SafeArrayCreateVector(VT_R8, 0, 4);
221
+ double *pData = nullptr;
222
+ hr = SafeArrayAccessData(*pRetVal, reinterpret_cast<void **>(&pData));
223
+ if (FAILED(hr))
224
+ return hr;
225
+ pData[0] = rect.left;
226
+ pData[1] = rect.top;
227
+ pData[2] = rect.width;
228
+ pData[3] = rect.height;
229
+ hr = SafeArrayUnaccessData(*pRetVal);
230
+ if (FAILED(hr))
231
+ return hr;
232
+ return S_OK;
233
+ }
234
+
235
+ HRESULT __stdcall CompositionTextRangeProvider::GetChildren(SAFEARRAY **pRetVal) {
236
+ // no-op
237
+ *pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 0);
238
+ return S_OK;
239
+ }
240
+
241
+ HRESULT __stdcall CompositionTextRangeProvider::GetEnclosingElement(IRawElementProviderSimple **pRetVal) {
242
+ // no-op
243
+ *pRetVal = nullptr;
244
+ return S_OK;
245
+ }
246
+
247
+ HRESULT __stdcall CompositionTextRangeProvider::GetText(int maxLength, BSTR *pRetVal) {
248
+ if (pRetVal == nullptr)
249
+ return E_POINTER;
250
+ auto strongView = m_view.view();
251
+
252
+ if (!strongView)
253
+ return UIA_E_ELEMENTNOTAVAILABLE;
254
+ auto paragraphView =
255
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ParagraphComponentView>();
256
+ std::string text = "";
257
+ if (paragraphView) {
258
+ text = paragraphView->DefaultAccessibleName();
259
+ } else {
260
+ auto textInputView =
261
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>();
262
+ if (textInputView) {
263
+ text = textInputView->getAccessiblityValue().value().empty() ? textInputView->DefaultAccessibleName()
264
+ : textInputView->getAccessiblityValue().value();
265
+ } else {
266
+ return UIA_E_NOTSUPPORTED;
267
+ }
268
+ }
269
+
270
+ std::wstring wtext(text.begin(), text.end());
271
+ *pRetVal = SysAllocString(wtext.c_str());
272
+ return S_OK;
273
+ }
274
+
275
+ HRESULT __stdcall CompositionTextRangeProvider::Move(TextUnit unit, int count, int *pRetVal) {
276
+ // no-op
277
+ *pRetVal = 0;
278
+ return S_OK;
279
+ }
280
+
281
+ HRESULT __stdcall CompositionTextRangeProvider::MoveEndpointByRange(
282
+ TextPatternRangeEndpoint endpoint,
283
+ ITextRangeProvider *targetRange,
284
+ TextPatternRangeEndpoint targetEndpoint) {
285
+ // no-op
286
+ return S_OK;
287
+ }
288
+
289
+ HRESULT __stdcall CompositionTextRangeProvider::MoveEndpointByUnit(
290
+ TextPatternRangeEndpoint endpoint,
291
+ TextUnit unit,
292
+ int count,
293
+ int *pRetVal) {
294
+ // no-op
295
+ *pRetVal = 0;
296
+ return S_OK;
297
+ }
298
+
299
+ HRESULT __stdcall CompositionTextRangeProvider::ScrollIntoView(BOOL alignToTop) {
300
+ // no-op
301
+ return S_OK;
302
+ }
303
+
304
+ // All the below methods should be implemented once the selection comes for paragraph and TextInput
305
+
306
+ HRESULT __stdcall CompositionTextRangeProvider::AddToSelection() {
307
+ // no-op
308
+ return S_OK;
309
+ }
310
+ HRESULT __stdcall CompositionTextRangeProvider::RemoveFromSelection() {
311
+ // no-op
312
+ return S_OK;
313
+ }
314
+ HRESULT __stdcall CompositionTextRangeProvider::Select() {
315
+ // no-op
316
+ return S_OK;
317
+ }
318
+
319
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,59 @@
1
+ #pragma once
2
+
3
+ #include <Fabric/Composition/CompositionDynamicAutomationProvider.h>
4
+ #include <Fabric/Composition/CompositionTextProvider.h>
5
+ #include <Fabric/Composition/CompositionViewComponentView.h>
6
+ #include <Fabric/ReactTaggedView.h>
7
+ #include <UIAutomation.h>
8
+ #include <inspectable.h>
9
+ #include <uiautomationcore.h>
10
+
11
+ namespace winrt::Microsoft::ReactNative::implementation {
12
+
13
+ class CompositionTextRangeProvider : public winrt::implements<CompositionTextRangeProvider, ITextRangeProvider> {
14
+ public:
15
+ CompositionTextRangeProvider(
16
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
17
+ CompositionDynamicAutomationProvider *parentProvider) noexcept;
18
+
19
+ // inherited via ITextRangeProvider
20
+ virtual HRESULT __stdcall Clone(ITextRangeProvider **pRetVal) override;
21
+ virtual HRESULT __stdcall Compare(ITextRangeProvider *range, BOOL *pRetVal) override;
22
+ virtual HRESULT __stdcall CompareEndpoints(
23
+ TextPatternRangeEndpoint endpoint,
24
+ ITextRangeProvider *targetRange,
25
+ TextPatternRangeEndpoint targetEndpoint,
26
+ int *pRetVal) override;
27
+ virtual HRESULT __stdcall ExpandToEnclosingUnit(TextUnit unit) override;
28
+ virtual HRESULT __stdcall FindAttribute(
29
+ TEXTATTRIBUTEID attributeId,
30
+ VARIANT val,
31
+ BOOL backward,
32
+ ITextRangeProvider **pRetVal) override;
33
+ virtual HRESULT __stdcall FindText(BSTR text, BOOL backward, BOOL ignoreCase, ITextRangeProvider **pRetVal) override;
34
+ virtual HRESULT __stdcall GetAttributeValue(TEXTATTRIBUTEID attributeId, VARIANT *pRetVal) override;
35
+ virtual HRESULT __stdcall GetBoundingRectangles(SAFEARRAY **pRetVal) override;
36
+ virtual HRESULT __stdcall GetChildren(SAFEARRAY **pRetVal) override;
37
+ virtual HRESULT __stdcall GetEnclosingElement(IRawElementProviderSimple **pRetVal) override;
38
+ virtual HRESULT __stdcall GetText(int maxLength, BSTR *pRetVal) override;
39
+ virtual HRESULT __stdcall Move(TextUnit unit, int count, int *pRetVal) override;
40
+ virtual HRESULT __stdcall MoveEndpointByRange(
41
+ TextPatternRangeEndpoint endpoint,
42
+ ITextRangeProvider *targetRange,
43
+ TextPatternRangeEndpoint targetEndpoint) override;
44
+ virtual HRESULT __stdcall MoveEndpointByUnit(
45
+ TextPatternRangeEndpoint endpoint,
46
+ TextUnit unit,
47
+ int count,
48
+ int *pRetVal) override;
49
+ virtual HRESULT __stdcall ScrollIntoView(BOOL alignToTop) override;
50
+ virtual HRESULT __stdcall AddToSelection() override;
51
+ virtual HRESULT __stdcall RemoveFromSelection() override;
52
+ virtual HRESULT __stdcall Select() override;
53
+
54
+ private:
55
+ ::Microsoft::ReactNative::ReactTaggedView m_view;
56
+ winrt::com_ptr<CompositionDynamicAutomationProvider> m_parentProvider;
57
+ };
58
+
59
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -381,7 +381,7 @@ void ComponentView::onGotFocus(
381
381
  focusRect.size.height += (FOCUS_VISUAL_WIDTH * 2);
382
382
  focusVisualRoot(focusRect)->hostFocusVisual(true, get_strong());
383
383
  }
384
- if (m_uiaProvider) {
384
+ if (EnsureUiaProvider()) {
385
385
  auto spProviderSimple = m_uiaProvider.try_as<IRawElementProviderSimple>();
386
386
  if (spProviderSimple != nullptr) {
387
387
  winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
@@ -780,6 +780,53 @@ void ComponentView::updateAccessibilityProps(
780
780
  oldViewProps.accessibilityLiveRegion,
781
781
  newViewProps.accessibilityLiveRegion);
782
782
 
783
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
784
+ EnsureUiaProvider(), UIA_LevelPropertyId, oldViewProps.accessibilityLevel, newViewProps.accessibilityLevel);
785
+
786
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
787
+ EnsureUiaProvider(),
788
+ UIA_AccessKeyPropertyId,
789
+ oldViewProps.accessibilityAccessKey,
790
+ newViewProps.accessibilityAccessKey);
791
+
792
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
793
+ EnsureUiaProvider(),
794
+ UIA_ItemTypePropertyId,
795
+ oldViewProps.accessibilityItemType,
796
+ newViewProps.accessibilityItemType);
797
+
798
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
799
+ EnsureUiaProvider(),
800
+ UIA_FullDescriptionPropertyId,
801
+ oldViewProps.accessibilityDescription,
802
+ newViewProps.accessibilityDescription);
803
+
804
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
805
+ EnsureUiaProvider(),
806
+ UIA_ValueValuePropertyId,
807
+ oldViewProps.accessibilityValue.text,
808
+ newViewProps.accessibilityValue.text);
809
+
810
+ // Handle expand/collapse state changes
811
+ if (oldViewProps.accessibilityState.has_value() != newViewProps.accessibilityState.has_value() ||
812
+ (oldViewProps.accessibilityState.has_value() && newViewProps.accessibilityState.has_value() &&
813
+ oldViewProps.accessibilityState->expanded != newViewProps.accessibilityState->expanded)) {
814
+ auto oldExpanded =
815
+ oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->expanded.has_value()
816
+ ? oldViewProps.accessibilityState->expanded.value()
817
+ : false;
818
+ auto newExpanded =
819
+ newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->expanded.has_value()
820
+ ? newViewProps.accessibilityState->expanded.value()
821
+ : false;
822
+
823
+ winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
824
+ EnsureUiaProvider(),
825
+ UIA_ExpandCollapseExpandCollapseStatePropertyId,
826
+ static_cast<int>(winrt::Microsoft::ReactNative::implementation::GetExpandCollapseState(oldExpanded)),
827
+ static_cast<int>(winrt::Microsoft::ReactNative::implementation::GetExpandCollapseState(newExpanded)));
828
+ }
829
+
783
830
  if ((oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->selected.has_value()) !=
784
831
  ((newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->selected.has_value()))) {
785
832
  auto compProvider =