react-native-windows 0.84.0-preview.1 → 0.84.0-preview.11

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 (31) hide show
  1. package/Common/Common.vcxproj +1 -1
  2. package/Folly/Folly.vcxproj +1 -1
  3. package/Libraries/Core/ReactNativeVersion.js +2 -2
  4. package/Libraries/Modal/Modal.windows.js +1 -7
  5. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +58 -20
  6. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +5 -0
  7. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +285 -70
  8. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +18 -4
  9. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +14 -9
  10. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +4 -0
  11. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +1 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +4 -6
  13. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +101 -44
  14. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -2
  15. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +3 -3
  16. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h +3 -1
  17. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +0 -1
  18. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -2
  19. package/Microsoft.ReactNative/Modules/Animated/AnimatedNode.cpp +3 -3
  20. package/Microsoft.ReactNative/Modules/Animated/AnimatedNode.h +3 -2
  21. package/Microsoft.ReactNative/Modules/Timing.h +2 -1
  22. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppApp.targets +2 -2
  23. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.targets +2 -2
  24. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  25. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  26. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  27. package/PropertySheets/JSEngine.props +3 -2
  28. package/ReactCommon/ReactCommon.vcxproj +1 -1
  29. package/Scripts/Tfs/Invoke-WebRequestWithRetry.ps1 +40 -0
  30. package/Scripts/perf/compare-results.js +68 -12
  31. package/package.json +15 -15
@@ -14,6 +14,7 @@
14
14
  #include <winrt/Windows.Devices.Input.h>
15
15
  #include <optional>
16
16
  #include <set>
17
+ #include <unordered_set>
17
18
 
18
19
  namespace winrt {
19
20
  using namespace Windows::UI;
@@ -79,7 +80,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
79
80
  bool releasePointerCapture(PointerId pointerId, facebook::react::Tag tag) noexcept;
80
81
 
81
82
  facebook::react::SurfaceId SurfaceId() const noexcept;
82
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView &RootComponentView() const noexcept;
83
+ winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *RootComponentView() const noexcept;
83
84
 
84
85
  enum class UITouchType {
85
86
  Mouse,
@@ -141,7 +142,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
141
142
  ReactTaggedView initialComponentView{nullptr};
142
143
  };
143
144
 
144
- static bool IsPointerWithinInitialTree(const ActiveTouch &activeTouch) noexcept;
145
+ bool IsPointerWithinInitialTree(const ActiveTouch &activeTouch) noexcept;
145
146
  static bool IsEndishEventType(TouchEventType eventType) noexcept;
146
147
  static const char *PointerTypeCStringFromUITouchType(UITouchType type) noexcept;
147
148
  static facebook::react::PointerEvent CreatePointerEventFromActiveTouch(
@@ -150,18 +151,31 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
150
151
  static void
151
152
  UpdateActiveTouch(ActiveTouch &activeTouch, facebook::react::Point ptScaled, facebook::react::Point ptLocal) noexcept;
152
153
 
154
+ void DispatchSynthesizedTouchCancelForActiveTouch(
155
+ const ActiveTouch &cancelledTouch,
156
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
157
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers);
158
+
159
+ std::vector<winrt::Microsoft::ReactNative::ComponentView> GetTouchableViewsInPathToRoot(
160
+ const winrt::Microsoft::ReactNative::ComponentView &componentView);
161
+
153
162
  void UpdateCursor() noexcept;
154
163
  void SetCursor(facebook::react::Cursor cursor, HCURSOR hcur) noexcept;
155
164
 
165
+ // Allocates a small touch identifier (0–19) that is safe to use as a JS array index.
166
+ // Windows pointer IDs can be arbitrarily large, which causes React Native to warn and
167
+ // back-fill huge arrays, corrupting touch state after scrolling.
168
+ int AllocateTouchIdentifier() noexcept;
169
+
156
170
  std::map<PointerId, ActiveTouch> m_activeTouches; // iOS is map of touch event args to ActiveTouch..?
157
- PointerId m_touchId = 0;
171
+ int m_touchId = 0; // cycling base used by AllocateTouchIdentifier
158
172
 
159
173
  std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
160
174
  winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
161
175
  winrt::Microsoft::ReactNative::ReactContext m_context;
162
176
 
163
177
  facebook::react::Tag m_pointerCapturingComponentTag{-1}; // Component that has captured input
164
- std::vector<PointerId> m_capturedPointers;
178
+ std::unordered_set<PointerId> m_capturedPointers;
165
179
  HCURSOR m_hcursor{nullptr};
166
180
  bool m_hcursorOwned{false}; // If we create the cursor, so we need to destroy it
167
181
  facebook::react::Cursor m_currentCursor{facebook::react::Cursor::Auto};
@@ -6,6 +6,8 @@
6
6
 
7
7
  #include "CompositionViewComponentView.h"
8
8
 
9
+ #include <vector>
10
+
9
11
  #include <AutoDraw.h>
10
12
  #include <Fabric/AbiState.h>
11
13
  #include <Fabric/AbiViewProps.h>
@@ -1013,15 +1015,18 @@ bool ComponentView::anyHitTestHelper(
1013
1015
  facebook::react::Tag &targetTag,
1014
1016
  facebook::react::Point &ptContent,
1015
1017
  facebook::react::Point &localPt) const noexcept {
1016
- if (auto index = m_children.Size()) {
1017
- do {
1018
- index--;
1019
- targetTag = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_children.GetAt(index))
1020
- ->hitTest(ptContent, localPt);
1021
- if (targetTag != -1) {
1022
- return true;
1023
- }
1024
- } while (index != 0);
1018
+ auto size = m_children.Size();
1019
+ if (size == 0) {
1020
+ return false;
1021
+ }
1022
+
1023
+ // m_children is backed by single_threaded_vector (std::vector), so GetAt is O(1)
1024
+ for (uint32_t i = size; i > 0; --i) {
1025
+ targetTag = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_children.GetAt(i - 1))
1026
+ ->hitTest(ptContent, localPt);
1027
+ if (targetTag != -1) {
1028
+ return true;
1029
+ }
1025
1030
  }
1026
1031
 
1027
1032
  return false;
@@ -130,6 +130,7 @@ void ImageComponentView::didReceiveImage(const std::shared_ptr<ImageResponseImag
130
130
  #endif
131
131
 
132
132
  m_imageResponseImage = imageResponseImage;
133
+ m_requiresImageRedraw = true;
133
134
  ensureDrawingSurface();
134
135
  }
135
136
 
@@ -310,6 +311,9 @@ void ImageComponentView::ensureDrawingSurface() noexcept {
310
311
  } else if (m_imageResponseImage->m_brushFactory) {
311
312
  Visual().as<Experimental::ISpriteVisual>().Brush(
312
313
  m_imageResponseImage->m_brushFactory(m_reactContext.Handle(), m_compContext));
314
+ } else if (m_requiresImageRedraw) {
315
+ m_requiresImageRedraw = false;
316
+ DrawImage();
313
317
  }
314
318
  }
315
319
 
@@ -96,6 +96,7 @@ struct ImageComponentView : ImageComponentViewT<ImageComponentView, ViewComponen
96
96
  winrt::Microsoft::ReactNative::Composition::Experimental::IDrawingSurfaceBrush m_drawingSurface;
97
97
  std::shared_ptr<ImageResponseImage> m_imageResponseImage;
98
98
  std::shared_ptr<WindowsImageResponseObserver> m_imageResponseObserver;
99
+ bool m_requiresImageRedraw{true};
99
100
  facebook::react::ImageShadowNode::ConcreteState::Shared m_state;
100
101
  };
101
102
 
@@ -981,8 +981,6 @@ void ScrollViewComponentView::OnPointerPressed(
981
981
  Super::OnPointerPressed(args);
982
982
 
983
983
  if (!args.Handled()) {
984
- auto f = args.Pointer();
985
- auto g = f.PointerDeviceType();
986
984
  m_scrollVisual.OnPointerPressed(args);
987
985
  }
988
986
  }
@@ -1023,16 +1021,16 @@ void ScrollViewComponentView::OnKeyDown(
1023
1021
  args.Handled(pageUp(true));
1024
1022
  break;
1025
1023
  case winrt::Windows::System::VirtualKey::Up:
1026
- args.Handled(lineUp(true));
1024
+ args.Handled(lineUp(false));
1027
1025
  break;
1028
1026
  case winrt::Windows::System::VirtualKey::Down:
1029
- args.Handled(lineDown(true));
1027
+ args.Handled(lineDown(false));
1030
1028
  break;
1031
1029
  case winrt::Windows::System::VirtualKey::Left:
1032
- args.Handled(lineLeft(true));
1030
+ args.Handled(lineLeft(false));
1033
1031
  break;
1034
1032
  case winrt::Windows::System::VirtualKey::Right:
1035
- args.Handled(lineRight(true));
1033
+ args.Handled(lineRight(false));
1036
1034
  break;
1037
1035
  }
1038
1036
 
@@ -18,6 +18,7 @@
18
18
  #include <winrt/Microsoft.UI.Input.h>
19
19
  #include <winrt/Windows.System.h>
20
20
  #include <winrt/Windows.UI.h>
21
+ #include <mutex>
21
22
  #include "../Composition.Input.h"
22
23
  #include "../CompositionHelpers.h"
23
24
  #include "../RootComponentView.h"
@@ -75,37 +76,38 @@ WindowsTextInputComponentView::DrawBlock::~DrawBlock() {
75
76
 
76
77
  // Msftedit.dll vs "Riched20.dll"?
77
78
 
79
+ static std::once_flag g_richEditLoadedFlag;
78
80
  static HINSTANCE g_hInstRichEdit = nullptr;
79
81
  static PCreateTextServices g_pfnCreateTextServices;
80
82
 
81
83
  HRESULT HrEnsureRichEd20Loaded() noexcept {
82
- if (g_hInstRichEdit == nullptr) {
84
+ HRESULT hr = S_OK;
85
+ std::call_once(g_richEditLoadedFlag, [&hr]() {
83
86
  g_hInstRichEdit = LoadLibrary(L"Msftedit.dll");
84
- if (!g_hInstRichEdit)
85
- return E_FAIL;
87
+ if (!g_hInstRichEdit) {
88
+ hr = E_FAIL;
89
+ return;
90
+ }
86
91
 
87
92
  // Create the windowless control (text services object)
88
93
  g_pfnCreateTextServices = (PCreateTextServices)GetProcAddress(g_hInstRichEdit, "CreateTextServices");
89
- if (!g_pfnCreateTextServices)
90
- return E_FAIL;
91
-
92
- /*
93
- // Calling the REExtendedRegisterClass() function is required for
94
- // registering the REComboboxW and REListBoxW window classes.
95
- PFNREGISTER pfnRegister = (PFNREGISTER)GetProcAddress(g_hInstRichEdit, "REExtendedRegisterClass");
96
- if (pfnRegister) {
97
- pfnRegister();
98
- return S_OK;
99
- } else
100
- return E_FAIL;
101
- */
102
- }
103
- return NOERROR;
94
+ if (!g_pfnCreateTextServices) {
95
+ hr = E_FAIL;
96
+ return;
97
+ }
98
+ });
99
+ if (!g_hInstRichEdit || !g_pfnCreateTextServices)
100
+ return E_FAIL;
101
+ return hr;
104
102
  }
105
103
 
106
104
  struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
107
105
  CompTextHost(WindowsTextInputComponentView *outer) : m_outer(outer) {}
108
106
 
107
+ void Detach() {
108
+ m_outer = nullptr;
109
+ }
110
+
109
111
  //@cmember Get the DC for the host
110
112
  HDC TxGetDC() override {
111
113
  assert(false);
@@ -144,6 +146,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
144
146
 
145
147
  //@cmember InvalidateRect
146
148
  void TxInvalidateRect(LPCRECT prc, BOOL fMode) override {
149
+ if (!m_outer)
150
+ return;
147
151
  if (m_outer->m_drawing)
148
152
  return;
149
153
  m_outer->DrawText();
@@ -151,6 +155,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
151
155
 
152
156
  //@cmember Send a WM_PAINT to the window
153
157
  void TxViewChange(BOOL fUpdate) override {
158
+ if (!m_outer)
159
+ return;
154
160
  // When keyboard scrolling without scrollbar, TxInvalidateRect is not called.
155
161
  // Instead TxViewChange is called with fUpdate = true
156
162
  // if (fUpdate && !OnInnerViewerExtentChanged())
@@ -163,12 +169,16 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
163
169
 
164
170
  //@cmember Create the caret
165
171
  BOOL TxCreateCaret(HBITMAP hbmp, INT xWidth, INT yHeight) override {
172
+ if (!m_outer)
173
+ return false;
166
174
  m_outer->m_caretVisual.Size({static_cast<float>(xWidth), static_cast<float>(yHeight)});
167
175
  return true;
168
176
  }
169
177
 
170
178
  //@cmember Show the caret
171
179
  BOOL TxShowCaret(BOOL fShow) override {
180
+ if (!m_outer)
181
+ return false;
172
182
  // Only show the caret if we have focus
173
183
  if (fShow && !m_outer->m_hasFocus) {
174
184
  return false;
@@ -179,6 +189,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
179
189
 
180
190
  //@cmember Set the caret position
181
191
  BOOL TxSetCaretPos(INT x, INT y) override {
192
+ if (!m_outer)
193
+ return false;
182
194
  if (x < 0 && y < 0) {
183
195
  // RichEdit sends (-32000,-32000) when the caret is not currently visible.
184
196
  return false;
@@ -217,6 +229,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
217
229
 
218
230
  //@cmember Get mouse capture
219
231
  void TxSetCapture(BOOL fCapture) override {
232
+ if (!m_outer)
233
+ return;
220
234
  auto mousePointer = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::Pointer>(
221
235
  winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse, 1 /* 1 is Mouse PointerId*/);
222
236
 
@@ -229,6 +243,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
229
243
 
230
244
  //@cmember Set the focus to the text window
231
245
  void TxSetFocus() override {
246
+ if (!m_outer)
247
+ return;
232
248
  winrt::Microsoft::ReactNative::ComponentView view{nullptr};
233
249
  winrt::check_hresult(
234
250
  m_outer->QueryInterface(winrt::guid_of<winrt::Microsoft::ReactNative::ComponentView>(), winrt::put_abi(view)));
@@ -242,11 +258,15 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
242
258
 
243
259
  //@cmember Establish a new cursor shape
244
260
  void TxSetCursor(HCURSOR hcur, BOOL fText) override {
261
+ if (!m_outer)
262
+ return;
245
263
  m_outer->m_hcursor = hcur;
246
264
  }
247
265
 
248
266
  //@cmember Converts screen coordinates of a specified point to the client coordinates
249
267
  BOOL TxScreenToClient(LPPOINT lppt) override {
268
+ if (!m_outer)
269
+ return false;
250
270
  winrt::Windows::Foundation::Point pt{static_cast<float>(lppt->x), static_cast<float>(lppt->y)};
251
271
  pt.X -= m_outer->m_contentOffsetPx.x;
252
272
  pt.Y -= m_outer->m_contentOffsetPx.y;
@@ -258,6 +278,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
258
278
 
259
279
  //@cmember Converts the client coordinates of a specified point to screen coordinates
260
280
  BOOL TxClientToScreen(LPPOINT lppt) override {
281
+ if (!m_outer)
282
+ return false;
261
283
  winrt::Windows::Foundation::Point pt{static_cast<float>(lppt->x), static_cast<float>(lppt->y)};
262
284
 
263
285
  if (!m_outer->m_parent) {
@@ -284,6 +306,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
284
306
 
285
307
  //@cmember Retrieves the coordinates of a window's client area
286
308
  HRESULT TxGetClientRect(LPRECT prc) override {
309
+ if (!m_outer)
310
+ return E_FAIL;
287
311
  *prc = m_outer->getClientRect();
288
312
 
289
313
  prc->top += m_outer->m_contentOffsetPx.y;
@@ -310,6 +334,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
310
334
 
311
335
  //@cmember Get the default character format for the text
312
336
  HRESULT TxGetCharFormat(const CHARFORMATW **ppCF) override {
337
+ if (!m_outer)
338
+ return E_FAIL;
313
339
  m_outer->UpdateCharFormat();
314
340
 
315
341
  *ppCF = &(m_outer->m_cf);
@@ -318,6 +344,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
318
344
 
319
345
  //@cmember Get the default paragraph format for the text
320
346
  HRESULT TxGetParaFormat(const PARAFORMAT **ppPF) override {
347
+ if (!m_outer)
348
+ return E_FAIL;
321
349
  m_outer->UpdateParaFormat();
322
350
 
323
351
  *ppPF = &(m_outer->m_pf);
@@ -326,6 +354,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
326
354
 
327
355
  //@cmember Get the background color for the window
328
356
  COLORREF TxGetSysColor(int nIndex) override {
357
+ if (!m_outer)
358
+ return GetSysColor(nIndex);
329
359
  // if (/* !m_isDisabled || */ nIndex != COLOR_WINDOW && nIndex != COLOR_WINDOWTEXT && nIndex != COLOR_GRAYTEXT) {
330
360
  // This window is either not disabled or the color isn't interesting
331
361
  // in the disabled case.
@@ -400,6 +430,10 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
400
430
 
401
431
  //@cmember Get the maximum length for the text
402
432
  HRESULT TxGetMaxLength(DWORD *plength) override {
433
+ if (!m_outer) {
434
+ *plength = std::numeric_limits<DWORD>::max();
435
+ return S_OK;
436
+ }
403
437
  auto length = m_outer->windowsTextInputProps().maxLength;
404
438
  if (length > static_cast<decltype(m_outer->windowsTextInputProps().maxLength)>(std::numeric_limits<DWORD>::max())) {
405
439
  length = std::numeric_limits<DWORD>::max();
@@ -410,6 +444,10 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
410
444
 
411
445
  //@cmember Get the bits representing requested scroll bars for the window
412
446
  HRESULT TxGetScrollBars(DWORD *pdwScrollBar) override {
447
+ if (!m_outer) {
448
+ *pdwScrollBar = WS_HSCROLL | ES_AUTOHSCROLL;
449
+ return S_OK;
450
+ }
413
451
  if (m_outer->m_multiline) {
414
452
  *pdwScrollBar = WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL;
415
453
  } else {
@@ -457,7 +495,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
457
495
 
458
496
  //@cmember Notify host of events
459
497
  HRESULT TxNotify(DWORD iNotify, void *pv) override {
460
- // TODO
498
+ if (!m_outer)
499
+ return S_OK;
461
500
 
462
501
  switch (iNotify) {
463
502
  case EN_UPDATE:
@@ -542,6 +581,16 @@ WindowsTextInputComponentView::WindowsTextInputComponentView(
542
581
  reactContext,
543
582
  ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {}
544
583
 
584
+ WindowsTextInputComponentView::~WindowsTextInputComponentView() {
585
+ // Release text services first to prevent further callbacks into CompTextHost.
586
+ m_textServices = nullptr;
587
+
588
+ // Detach the CompTextHost so any lingering references cannot use a dangling pointer.
589
+ if (m_textHost) {
590
+ winrt::get_self<CompTextHost>(m_textHost)->Detach();
591
+ }
592
+ }
593
+
545
594
  void WindowsTextInputComponentView::HandleCommand(
546
595
  const winrt::Microsoft::ReactNative::HandleCommandArgs &args) noexcept {
547
596
  Super::HandleCommand(args);
@@ -649,17 +698,22 @@ WPARAM PointerRoutedEventArgsToMouseWParam(
649
698
  return wParam;
650
699
  }
651
700
 
652
- bool WindowsTextInputComponentView::IsDoubleClick() {
701
+ bool WindowsTextInputComponentView::IsDoubleClick(uint32_t pointerId) {
653
702
  using namespace std::chrono;
654
703
 
655
704
  auto now = steady_clock::now();
656
- auto duration = duration_cast<milliseconds>(now - m_lastClickTime).count();
705
+ auto it = m_lastClickTimeByPointer.find(pointerId);
706
+ bool isDouble = false;
657
707
 
658
- const int DOUBLE_CLICK_TIME_MS = ::GetDoubleClickTime();
659
-
660
- m_lastClickTime = now;
708
+ if (it != m_lastClickTimeByPointer.end()) {
709
+ auto duration = duration_cast<milliseconds>(now - it->second).count();
710
+ isDouble = (duration < ::GetDoubleClickTime());
711
+ it->second = now;
712
+ } else {
713
+ m_lastClickTimeByPointer[pointerId] = now;
714
+ }
661
715
 
662
- return (duration < DOUBLE_CLICK_TIME_MS);
716
+ return isDouble;
663
717
  }
664
718
 
665
719
  void WindowsTextInputComponentView::OnPointerPressed(
@@ -678,7 +732,7 @@ void WindowsTextInputComponentView::OnPointerPressed(
678
732
  if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
679
733
  switch (pp.Properties().PointerUpdateKind()) {
680
734
  case winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonPressed:
681
- if (IsDoubleClick()) {
735
+ if (IsDoubleClick(pp.PointerId())) {
682
736
  msg = WM_LBUTTONDBLCLK;
683
737
  } else {
684
738
  msg = WM_LBUTTONDOWN;
@@ -699,10 +753,14 @@ void WindowsTextInputComponentView::OnPointerPressed(
699
753
  wParam |= (XBUTTON2 << 16);
700
754
  break;
701
755
  }
702
- wParam = PointerRoutedEventArgsToMouseWParam(args);
756
+ wParam |= PointerRoutedEventArgsToMouseWParam(args);
703
757
  } else {
704
- msg = WM_POINTERDOWN;
705
- wParam = PointerPointToPointerWParam(pp);
758
+ if (IsDoubleClick(pp.PointerId())) {
759
+ msg = WM_LBUTTONDBLCLK;
760
+ } else {
761
+ msg = WM_LBUTTONDOWN;
762
+ }
763
+ wParam = PointerRoutedEventArgsToMouseWParam(args);
706
764
  }
707
765
 
708
766
  if (m_textServices && msg) {
@@ -764,10 +822,10 @@ void WindowsTextInputComponentView::OnPointerReleased(
764
822
  wParam |= (XBUTTON2 << 16);
765
823
  break;
766
824
  }
767
- wParam = PointerRoutedEventArgsToMouseWParam(args);
825
+ wParam |= PointerRoutedEventArgsToMouseWParam(args);
768
826
  } else {
769
- msg = WM_POINTERUP;
770
- wParam = PointerPointToPointerWParam(pp);
827
+ msg = WM_LBUTTONUP;
828
+ wParam = PointerRoutedEventArgsToMouseWParam(args);
771
829
  }
772
830
 
773
831
  if (m_textServices && msg) {
@@ -817,23 +875,18 @@ void WindowsTextInputComponentView::OnPointerMoved(
817
875
  static_cast<LONG>(position.Y * m_layoutMetrics.pointScaleFactor)};
818
876
  lParam = static_cast<LPARAM>(POINTTOPOINTS(ptContainer));
819
877
 
820
- if (pp.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
821
- msg = WM_MOUSEMOVE;
822
- wParam = PointerRoutedEventArgsToMouseWParam(args);
823
- } else {
824
- msg = WM_POINTERUPDATE;
825
- wParam = PointerPointToPointerWParam(pp);
826
- }
878
+ msg = WM_MOUSEMOVE;
879
+ wParam = PointerRoutedEventArgsToMouseWParam(args);
827
880
 
828
881
  if (m_textServices) {
829
882
  LRESULT lresult;
830
883
  DrawBlock db(*this);
831
884
  auto hr = m_textServices->TxSendMessage(msg, static_cast<WPARAM>(wParam), static_cast<LPARAM>(lParam), &lresult);
832
885
  args.Handled(hr != S_FALSE);
833
- }
834
886
 
835
- m_textServices->OnTxSetCursor(
836
- DVASPECT_CONTENT, -1, nullptr, nullptr, nullptr, nullptr, nullptr, ptContainer.x, ptContainer.y);
887
+ m_textServices->OnTxSetCursor(
888
+ DVASPECT_CONTENT, -1, nullptr, nullptr, nullptr, nullptr, nullptr, ptContainer.x, ptContainer.y);
889
+ }
837
890
  }
838
891
 
839
892
  void WindowsTextInputComponentView::OnPointerWheelChanged(
@@ -935,7 +988,7 @@ bool WindowsTextInputComponentView::ShouldSubmit(
935
988
  bool ctrlDown = (args.KeyboardSource().GetKeyState(winrt::Windows::System::VirtualKey::Control) &
936
989
  winrt::Microsoft::UI::Input::VirtualKeyStates::Down) ==
937
990
  winrt::Microsoft::UI::Input::VirtualKeyStates::Down;
938
- bool altDown = (args.KeyboardSource().GetKeyState(winrt::Windows::System::VirtualKey::Control) &
991
+ bool altDown = (args.KeyboardSource().GetKeyState(winrt::Windows::System::VirtualKey::Menu) &
939
992
  winrt::Microsoft::UI::Input::VirtualKeyStates::Down) ==
940
993
  winrt::Microsoft::UI::Input::VirtualKeyStates::Down;
941
994
  bool metaDown = (args.KeyboardSource().GetKeyState(winrt::Windows::System::VirtualKey::LeftWindows) &
@@ -946,7 +999,7 @@ bool WindowsTextInputComponentView::ShouldSubmit(
946
999
  winrt::Microsoft::UI::Input::VirtualKeyStates::Down;
947
1000
  return (submitKeyEvent.shiftKey && shiftDown) || (submitKeyEvent.ctrlKey && ctrlDown) ||
948
1001
  (submitKeyEvent.altKey && altDown) || (submitKeyEvent.metaKey && metaDown) ||
949
- (!submitKeyEvent.shiftKey && !submitKeyEvent.altKey && !submitKeyEvent.metaKey && !submitKeyEvent.altKey &&
1002
+ (!submitKeyEvent.shiftKey && !submitKeyEvent.ctrlKey && !submitKeyEvent.altKey && !submitKeyEvent.metaKey &&
950
1003
  !shiftDown && !ctrlDown && !altDown && !metaDown);
951
1004
  } else {
952
1005
  shouldSubmit = false;
@@ -1780,7 +1833,10 @@ void WindowsTextInputComponentView::DrawText() noexcept {
1780
1833
  }
1781
1834
 
1782
1835
  // TODO keep track of proper invalid rect
1836
+ // Prevent reentrancy: TxDrawD2D may call TxViewChange -> DrawText
1837
+ m_cDrawBlock++;
1783
1838
  auto hrDraw = m_textServices->TxDrawD2D(d2dDeviceContext, &rc, nullptr, TXTVIEW_ACTIVE);
1839
+ m_cDrawBlock--;
1784
1840
  winrt::check_hresult(hrDraw);
1785
1841
 
1786
1842
  // draw placeholder text if needed
@@ -1833,6 +1889,7 @@ WindowsTextInputComponentView::createVisual() noexcept {
1833
1889
  winrt::com_ptr<::IUnknown> spUnk;
1834
1890
  winrt::check_hresult(g_pfnCreateTextServices(nullptr, m_textHost.get(), spUnk.put()));
1835
1891
  spUnk.as(m_textServices);
1892
+ winrt::check_bool(m_textServices != nullptr);
1836
1893
 
1837
1894
  LRESULT res;
1838
1895
  winrt::check_hresult(m_textServices->TxSendMessage(EM_SETTEXTMODE, TM_PLAINTEXT, 0, &res));
@@ -11,6 +11,7 @@
11
11
  #include <textserv.h>
12
12
  #include <windows.ui.composition.interop.h>
13
13
  #include <winrt/Windows.UI.Composition.h>
14
+ #include <unordered_map>
14
15
  #include "../ComponentView.h"
15
16
  #include "../CompositionHelpers.h"
16
17
  #include "../CompositionViewComponentView.h"
@@ -74,12 +75,13 @@ struct WindowsTextInputComponentView
74
75
  std::optional<std::string> getAccessiblityValue() noexcept override;
75
76
  void setAcccessiblityValue(std::string &&value) noexcept override;
76
77
  bool getAcccessiblityIsReadOnly() noexcept override;
77
- bool IsDoubleClick();
78
+ bool IsDoubleClick(uint32_t pointerId);
78
79
 
79
80
  WindowsTextInputComponentView(
80
81
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
81
82
  facebook::react::Tag tag,
82
83
  winrt::Microsoft::ReactNative::ReactContext const &reactContext);
84
+ ~WindowsTextInputComponentView();
83
85
 
84
86
  winrt::Microsoft::ReactNative::Composition::Experimental::IVisual createVisual() noexcept;
85
87
 
@@ -152,7 +154,7 @@ struct WindowsTextInputComponentView
152
154
  DWORD m_propBits{0};
153
155
  HCURSOR m_hcursor{nullptr};
154
156
  POINT m_caretPosition{0, 0};
155
- std::chrono::steady_clock::time_point m_lastClickTime{};
157
+ std::unordered_map<uint32_t, std::chrono::steady_clock::time_point> m_lastClickTimeByPointer;
156
158
  std::vector<facebook::react::CompWindowsTextInputSubmitKeyEventsStruct> m_submitKeyEvents;
157
159
  };
158
160
 
@@ -46,12 +46,12 @@ WindowsComponentDescriptorRegistry::WindowsComponentDescriptorRegistry()
46
46
  }
47
47
 
48
48
  void WindowsComponentDescriptorRegistry::add(const facebook::react::ComponentDescriptorProvider &provider) noexcept {
49
- m_componentNames.push_back(provider.name);
49
+ m_componentNames.insert(provider.name);
50
50
  m_componentDescriptorRegistry->add(provider);
51
51
  }
52
52
 
53
53
  bool WindowsComponentDescriptorRegistry::hasComponentProvider(const std::string &name) noexcept {
54
- return std::find(m_componentNames.begin(), m_componentNames.end(), name) != m_componentNames.end();
54
+ return m_componentNames.count(name) != 0;
55
55
  }
56
56
 
57
57
  bool WindowsComponentDescriptorRegistry::isXamlSupportRequired() const noexcept {
@@ -68,7 +68,7 @@ void WindowsComponentDescriptorRegistry::Add(
68
68
  auto builder = winrt::make<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>();
69
69
  provider(builder);
70
70
 
71
- m_componentNames.push_back(winrt::to_string(componentName));
71
+ m_componentNames.insert(winrt::to_string(componentName));
72
72
  m_descriptorFlavors.emplace_back(std::make_shared<std::string>(winrt::to_string(componentName)));
73
73
  auto handle = reinterpret_cast<facebook::react::ComponentHandle>(
74
74
  facebook::react::ComponentName(m_descriptorFlavors.back()->c_str()));
@@ -10,6 +10,8 @@
10
10
  #include <ReactPropertyBag.h>
11
11
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
12
12
 
13
+ #include <unordered_set>
14
+
13
15
  namespace Microsoft::ReactNative {
14
16
 
15
17
  struct WindowsComponentDescriptorRegistry {
@@ -41,7 +43,7 @@ struct WindowsComponentDescriptorRegistry {
41
43
  void add(const facebook::react::ComponentDescriptorProvider &provider) noexcept;
42
44
 
43
45
  std::vector<std::shared_ptr<const std::string>> m_descriptorFlavors;
44
- std::vector<std::string> m_componentNames;
46
+ std::unordered_set<std::string> m_componentNames;
45
47
  std::shared_ptr<facebook::react::ComponentDescriptorProviderRegistry> m_componentDescriptorRegistry;
46
48
 
47
49
  std::map<std::shared_ptr<const std::string>, winrt::Microsoft::ReactNative::IReactViewComponentBuilder const>
@@ -72,7 +72,6 @@ wicBitmapSourceFromStream(const winrt::Windows::Storage::Streams::IRandomAccessS
72
72
  return {decodedFrame, imagingFactory, nullptr};
73
73
  } catch (winrt::hresult_error const &ex) {
74
74
  auto errorInfo = std::make_shared<facebook::react::ImageErrorInfo>();
75
- errorInfo = std::make_shared<facebook::react::ImageErrorInfo>();
76
75
  errorInfo->error = ::Microsoft::ReactNative::FormatHResultError(winrt::hresult_error(ex));
77
76
  return {nullptr, nullptr, errorInfo};
78
77
  }
@@ -426,9 +426,9 @@
426
426
  </ProjectReference>
427
427
  </ItemGroup>
428
428
  <ItemGroup>
429
- <PackageReference Include="boost" Version="1.83.0.0" />
429
+ <PackageReference Include="boost" Version="1.84.0.0" />
430
430
  <PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" PrivateAssets="all" />
431
- <PackageReference Include="Microsoft.JavaScript.Hermes" Version="$(HermesVersion)" />
431
+ <PackageReference Include="$(HermesPackageName)" Version="$(HermesVersion)" />
432
432
  <PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" Condition="'$(OverrideWinUIPackage)'!='true'" />
433
433
  <PackageReference Include="$(V8PackageName)" Version="$(V8Version)" Condition="'$(UseV8)' == 'true'" />
434
434
  </ItemGroup>
@@ -22,19 +22,19 @@ int64_t AnimatedNode::Tag() {
22
22
  }
23
23
 
24
24
  void AnimatedNode::AddChild(const int64_t animatedNodeTag) {
25
- m_children.push_back(animatedNodeTag);
25
+ m_children.insert(animatedNodeTag);
26
26
  GetChildNode(animatedNodeTag)->OnAttachToNode(m_tag);
27
27
  }
28
28
 
29
29
  void AnimatedNode::RemoveChild(const int64_t tag) {
30
30
  if (const auto childNode = GetChildNode(tag)) {
31
31
  childNode->OnDetachedFromNode(m_tag);
32
- m_children.erase(std::find(m_children.begin(), m_children.end(), tag));
32
+ m_children.erase(tag);
33
33
  }
34
34
  }
35
35
 
36
36
  AnimatedNode *AnimatedNode::GetChildNode(int64_t tag) {
37
- if (std::find(m_children.begin(), m_children.end(), tag) != m_children.end()) {
37
+ if (m_children.count(tag)) {
38
38
  if (const auto manager = m_manager.lock()) {
39
39
  return manager->GetAnimatedNode(tag);
40
40
  }
@@ -6,6 +6,7 @@
6
6
  #include <JSValue.h>
7
7
  #include <cstdint>
8
8
  #include <memory>
9
+ #include <unordered_set>
9
10
  #include <vector>
10
11
 
11
12
  namespace Microsoft::ReactNative {
@@ -20,7 +21,7 @@ class AnimatedNode {
20
21
  void AddChild(int64_t animatedNode);
21
22
  void RemoveChild(int64_t animatedNode);
22
23
 
23
- std::vector<int64_t> &Children() {
24
+ std::unordered_set<int64_t> &Children() {
24
25
  return m_children;
25
26
  }
26
27
 
@@ -37,7 +38,7 @@ class AnimatedNode {
37
38
  AnimatedNode *GetChildNode(int64_t tag);
38
39
  int64_t m_tag{0};
39
40
  const std::weak_ptr<NativeAnimatedNodeManager> m_manager;
40
- std::vector<int64_t> m_children{};
41
+ std::unordered_set<int64_t> m_children{};
41
42
  bool m_useComposition{false};
42
43
 
43
44
  bool HasCompatibleAnimationDriver(int64_t tag);