react-native-windows 0.74.4 → 0.74.5

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 (37) hide show
  1. package/Libraries/Components/TextInput/TextInput.windows.js +6 -2
  2. package/Libraries/Components/View/View.windows.js +3 -0
  3. package/Microsoft.ReactNative/CompositionComponentView.idl +17 -7
  4. package/Microsoft.ReactNative/CompositionRootView.idl +1 -0
  5. package/Microsoft.ReactNative/CompositionUIService.idl +4 -0
  6. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +2 -1
  7. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +106 -19
  8. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +45 -13
  9. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +28 -64
  10. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +7 -11
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +4 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +2 -0
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +4 -0
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +12 -0
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +4 -0
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +6 -0
  17. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +27 -16
  18. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +13 -4
  19. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +49 -95
  21. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +11 -15
  22. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +16 -31
  23. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -8
  24. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +24 -81
  25. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -13
  26. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +1 -0
  27. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +53 -68
  28. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -7
  29. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +38 -84
  30. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -10
  31. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +52 -104
  32. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -13
  33. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -0
  34. package/Microsoft.ReactNative/ViewProps.idl +37 -3
  35. package/Microsoft.ReactNative.Cxx/JSValueComposition.h +4 -0
  36. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  37. package/package.json +1 -1
@@ -13,8 +13,9 @@
13
13
 
14
14
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
15
15
 
16
- struct WindowsModalHostComponentView : WindowsModalHostComponentViewT<WindowsModalHostComponentView, ComponentView> {
17
- using Super = WindowsModalHostComponentViewT<WindowsModalHostComponentView, ComponentView>;
16
+ struct WindowsModalHostComponentView
17
+ : WindowsModalHostComponentViewT<WindowsModalHostComponentView, ViewComponentView> {
18
+ using Super = WindowsModalHostComponentViewT<WindowsModalHostComponentView, ViewComponentView>;
18
19
 
19
20
  [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
20
21
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -37,13 +38,11 @@ struct WindowsModalHostComponentView : WindowsModalHostComponentViewT<WindowsMod
37
38
  void updateLayoutMetrics(
38
39
  facebook::react::LayoutMetrics const &layoutMetrics,
39
40
  facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
40
- void prepareForRecycle() noexcept override;
41
- facebook::react::SharedViewProps viewProps() noexcept override;
41
+ static facebook::react::SharedViewProps defaultProps() noexcept;
42
+ const facebook::react::ModalHostViewProps &modalHostViewProps() const noexcept;
42
43
  bool focusable() const noexcept override;
43
44
  facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
44
45
  const noexcept override;
45
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
46
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual OuterVisual() const noexcept override;
47
46
  virtual std::string DefaultControlType() const noexcept;
48
47
 
49
48
  WindowsModalHostComponentView(
@@ -58,8 +57,6 @@ struct WindowsModalHostComponentView : WindowsModalHostComponentViewT<WindowsMod
58
57
  static void RegisterWndClass() noexcept;
59
58
 
60
59
  private:
61
- std::shared_ptr<facebook::react::ModalHostViewProps const> m_props;
62
- winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
63
60
  HWND m_hwnd{nullptr};
64
61
  winrt::Microsoft::ReactNative::ReactContext m_context;
65
62
  };
@@ -23,14 +23,12 @@ ParagraphComponentView::ParagraphComponentView(
23
23
  facebook::react::Tag tag,
24
24
  winrt::Microsoft::ReactNative::ReactContext const &reactContext)
25
25
  : Super(
26
+ ParagraphComponentView::defaultProps(),
26
27
  compContext,
27
28
  tag,
28
29
  reactContext,
29
30
  ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
30
- false) {
31
- static auto const defaultProps = std::make_shared<facebook::react::ParagraphProps const>();
32
- m_props = defaultProps;
33
- }
31
+ false) {}
34
32
 
35
33
  void ParagraphComponentView::MountChildComponentView(
36
34
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
@@ -49,7 +47,8 @@ void ParagraphComponentView::UnmountChildComponentView(
49
47
  void ParagraphComponentView::updateProps(
50
48
  facebook::react::Props::Shared const &props,
51
49
  facebook::react::Props::Shared const &oldProps) noexcept {
52
- const auto &oldViewProps = *std::static_pointer_cast<const facebook::react::ParagraphProps>(m_props);
50
+ const auto &oldViewProps =
51
+ *std::static_pointer_cast<const facebook::react::ParagraphProps>(oldProps ? oldProps : viewProps());
53
52
  const auto &newViewProps = *std::static_pointer_cast<const facebook::react::ParagraphProps>(props);
54
53
 
55
54
  ensureVisual();
@@ -57,23 +56,16 @@ void ParagraphComponentView::updateProps(
57
56
  if (oldViewProps.textAttributes.foregroundColor != newViewProps.textAttributes.foregroundColor) {
58
57
  m_requireRedraw = true;
59
58
  }
59
+
60
60
  if (oldViewProps.textAttributes.opacity != newViewProps.textAttributes.opacity) {
61
61
  m_requireRedraw = true;
62
62
  }
63
- if (oldViewProps.testId != newViewProps.testId) {
64
- m_visual.Comment(winrt::to_hstring(newViewProps.testId));
65
- }
66
63
 
67
64
  if (oldViewProps.textAttributes.alignment != newViewProps.textAttributes.alignment) {
68
65
  updateTextAlignment(newViewProps.textAttributes.alignment);
69
66
  }
70
67
 
71
- // update BaseComponentView props
72
- updateAccessibilityProps(oldViewProps, newViewProps);
73
- updateTransformProps(oldViewProps, newViewProps, m_visual);
74
68
  Super::updateProps(props, oldProps);
75
-
76
- m_props = std::static_pointer_cast<facebook::react::ParagraphProps const>(props);
77
69
  }
78
70
 
79
71
  void ParagraphComponentView::updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept {
@@ -90,60 +82,13 @@ void ParagraphComponentView::updateState(
90
82
 
91
83
  m_textLayout = nullptr;
92
84
  }
93
- void ParagraphComponentView::updateLayoutMetrics(
94
- facebook::react::LayoutMetrics const &layoutMetrics,
95
- facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
96
- // Set Position & Size Properties
97
-
98
- if ((layoutMetrics.displayType != m_layoutMetrics.displayType)) {
99
- OuterVisual().IsVisible(layoutMetrics.displayType != facebook::react::DisplayType::None);
100
- }
101
85
 
102
- Super::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
103
- m_visual.Size(
104
- {layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
105
- layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
106
- }
107
86
  void ParagraphComponentView::FinalizeUpdates(
108
87
  winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept {
109
88
  ensureVisual();
110
89
  updateVisualBrush();
111
90
  Super::FinalizeUpdates(updateMask);
112
91
  }
113
- void ParagraphComponentView::prepareForRecycle() noexcept {}
114
-
115
- facebook::react::SharedViewProps ParagraphComponentView::viewProps() noexcept {
116
- return m_props;
117
- }
118
-
119
- facebook::react::Tag ParagraphComponentView::hitTest(
120
- facebook::react::Point pt,
121
- facebook::react::Point &localPt,
122
- bool ignorePointerEvents) const noexcept {
123
- facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y};
124
-
125
- facebook::react::Tag targetTag;
126
-
127
- /*
128
- if ((m_props.pointerEvents == facebook::react::PointerEventsMode::Auto ||
129
- m_props.pointerEvents == facebook::react::PointerEventsMode::BoxNone) && std::any_of(m_children.rbegin(),
130
- m_children.rend(), [&targetTag, &ptLocal, &localPt](auto child) { targetTag = static_cast<const
131
- ComponentView
132
- *>(child)->hitTest(ptLocal, localPt); return targetTag != -1;
133
- }))
134
- return targetTag;
135
- */
136
-
137
- if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
138
- m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
139
- ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
140
- ptLocal.y <= m_layoutMetrics.frame.size.height) {
141
- localPt = ptLocal;
142
- return Tag();
143
- }
144
-
145
- return -1;
146
- }
147
92
 
148
93
  facebook::react::SharedViewEventEmitter ParagraphComponentView::eventEmitterAtPoint(
149
94
  facebook::react::Point pt) noexcept {
@@ -168,13 +113,6 @@ facebook::react::SharedViewEventEmitter ParagraphComponentView::eventEmitterAtPo
168
113
  return m_eventEmitter;
169
114
  }
170
115
 
171
- void ParagraphComponentView::ensureVisual() noexcept {
172
- if (!m_visual) {
173
- m_visual = m_compContext.CreateSpriteVisual();
174
- OuterVisual().InsertAt(m_visual, 0);
175
- }
176
- }
177
-
178
116
  void ParagraphComponentView::updateTextAlignment(
179
117
  const std::optional<facebook::react::TextAlignment> &fbAlignment) noexcept {
180
118
  m_textLayout = nullptr;
@@ -255,11 +193,11 @@ void ParagraphComponentView::updateVisualBrush() noexcept {
255
193
 
256
194
  // The surfaceBrush's size is based on the size the text takes up, which maybe smaller than the total visual
257
195
  // So we need to align the brush within the visual to match the text alignment.
258
- const auto &paragraphProps = *std::static_pointer_cast<const facebook::react::ParagraphProps>(m_props);
259
196
  float horizAlignment{0.f};
260
197
  /*
261
- if (paragraphProps.textAttributes.alignment) {
262
- switch (*paragraphProps.textAttributes.alignment) {
198
+ const auto &props = paragraphProps()
199
+ if (props.textAttributes.alignment) {
200
+ switch (*props.textAttributes.alignment) {
263
201
  case facebook::react::TextAlignment::Center:
264
202
  horizAlignment = 0.5f;
265
203
  break;
@@ -287,7 +225,7 @@ void ParagraphComponentView::updateVisualBrush() noexcept {
287
225
  m_drawingSurface.VerticalAlignmentRatio(0.f);
288
226
  m_drawingSurface.Stretch(winrt::Microsoft::ReactNative::Composition::Experimental::CompositionStretch::None);
289
227
  }
290
- m_visual.Brush(m_drawingSurface);
228
+ Visual().as<Experimental::ISpriteVisual>().Brush(m_drawingSurface);
291
229
  }
292
230
 
293
231
  if (m_requireRedraw) {
@@ -295,6 +233,15 @@ void ParagraphComponentView::updateVisualBrush() noexcept {
295
233
  }
296
234
  }
297
235
 
236
+ facebook::react::SharedViewProps ParagraphComponentView::defaultProps() noexcept {
237
+ static auto const defaultProps = std::make_shared<facebook::react::ParagraphProps const>();
238
+ return defaultProps;
239
+ }
240
+
241
+ const facebook::react::ParagraphProps &ParagraphComponentView::paragraphProps() const noexcept {
242
+ return *std::static_pointer_cast<const facebook::react::ParagraphProps>(viewProps());
243
+ }
244
+
298
245
  void ParagraphComponentView::onThemeChanged() noexcept {
299
246
  DrawText();
300
247
  Super::onThemeChanged();
@@ -316,23 +263,23 @@ void ParagraphComponentView::DrawText() noexcept {
316
263
  m_drawingSurface, m_layoutMetrics.pointScaleFactor, &offset);
317
264
  if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
318
265
  d2dDeviceContext->Clear(
319
- m_props->backgroundColor ? theme()->D2DColor(*m_props->backgroundColor)
320
- : D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
266
+ viewProps()->backgroundColor ? theme()->D2DColor(*viewProps()->backgroundColor)
267
+ : D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
321
268
 
322
- const auto &paragraphProps = *std::static_pointer_cast<const facebook::react::ParagraphProps>(m_props);
269
+ const auto &props = paragraphProps();
323
270
 
324
271
  RenderText(
325
272
  *d2dDeviceContext,
326
273
  *m_textLayout,
327
274
  m_attributedStringBox.getValue(),
328
- paragraphProps.textAttributes,
275
+ props.textAttributes,
329
276
  {static_cast<float>(offset.x) + m_layoutMetrics.contentInsets.left,
330
277
  static_cast<float>(offset.y) + m_layoutMetrics.contentInsets.top},
331
278
  m_layoutMetrics.pointScaleFactor,
332
279
  *theme());
333
280
 
334
- if (!isnan(paragraphProps.opacity)) {
335
- m_visual.Opacity(paragraphProps.opacity);
281
+ if (!isnan(props.opacity)) {
282
+ Visual().Opacity(props.opacity);
336
283
  }
337
284
  }
338
285
  m_requireRedraw = false;
@@ -347,10 +294,6 @@ std::string ParagraphComponentView::DefaultAccessibleName() const noexcept {
347
294
  return m_attributedStringBox.getValue().getString();
348
295
  }
349
296
 
350
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ParagraphComponentView::Visual() const noexcept {
351
- return m_visual;
352
- }
353
-
354
297
  winrt::Microsoft::ReactNative::ComponentView ParagraphComponentView::Create(
355
298
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
356
299
  facebook::react::Tag tag,
@@ -17,8 +17,8 @@
17
17
 
18
18
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
19
19
 
20
- struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView, ComponentView> {
21
- using Super = ParagraphComponentViewT<ParagraphComponentView, ComponentView>;
20
+ struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView, ViewComponentView> {
21
+ using Super = ParagraphComponentViewT<ParagraphComponentView, ViewComponentView>;
22
22
 
23
23
  [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
24
24
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -36,21 +36,15 @@ struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView,
36
36
  void updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept override;
37
37
  void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept
38
38
  override;
39
- void updateLayoutMetrics(
40
- facebook::react::LayoutMetrics const &layoutMetrics,
41
- facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
42
39
  void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
43
- void prepareForRecycle() noexcept override;
44
- facebook::react::SharedViewProps viewProps() noexcept override;
45
- facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
46
- const noexcept override;
47
40
  void OnRenderingDeviceLost() noexcept override;
48
41
  void onThemeChanged() noexcept override;
49
42
  facebook::react::SharedViewEventEmitter eventEmitterAtPoint(facebook::react::Point pt) noexcept override;
50
43
 
51
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
52
44
  virtual std::string DefaultControlType() const noexcept override;
53
45
  virtual std::string DefaultAccessibleName() const noexcept override;
46
+ static facebook::react::SharedViewProps defaultProps() noexcept;
47
+ const facebook::react::ParagraphProps &paragraphProps() const noexcept;
54
48
 
55
49
  ParagraphComponentView(
56
50
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -58,13 +52,10 @@ struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView,
58
52
  winrt::Microsoft::ReactNative::ReactContext const &reactContext);
59
53
 
60
54
  private:
61
- void ensureVisual() noexcept;
62
55
  void updateVisualBrush() noexcept;
63
56
  void DrawText() noexcept;
64
57
  void updateTextAlignment(const std::optional<facebook::react::TextAlignment> &fbAlignment) noexcept;
65
58
 
66
- std::shared_ptr<facebook::react::ParagraphProps const> m_props;
67
- winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
68
59
  winrt::com_ptr<::IDWriteTextLayout> m_textLayout;
69
60
  facebook::react::AttributedStringBox m_attributedStringBox;
70
61
  facebook::react::ParagraphAttributes m_paragraphAttributes;
@@ -18,6 +18,7 @@ RootComponentView::RootComponentView(
18
18
  facebook::react::Tag tag,
19
19
  winrt::Microsoft::ReactNative::ReactContext const &reactContext)
20
20
  : base_type(
21
+ {}, // default viewProps
21
22
  compContext,
22
23
  tag,
23
24
  reactContext,
@@ -578,19 +578,22 @@ winrt::Microsoft::ReactNative::ComponentView ScrollViewComponentView::Create(
578
578
  return winrt::make<ScrollViewComponentView>(compContext, tag, reactContext);
579
579
  }
580
580
 
581
+ facebook::react::SharedViewProps ScrollViewComponentView::defaultProps() noexcept {
582
+ static auto const defaultViewProps = std::make_shared<facebook::react::ScrollViewProps const>();
583
+ return defaultViewProps;
584
+ }
585
+
581
586
  ScrollViewComponentView::ScrollViewComponentView(
582
587
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
583
588
  facebook::react::Tag tag,
584
589
  winrt::Microsoft::ReactNative::ReactContext const &reactContext)
585
590
  : Super(
591
+ ScrollViewComponentView::defaultProps(),
586
592
  compContext,
587
593
  tag,
588
594
  reactContext,
589
595
  ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
590
596
  false) {
591
- static auto const defaultProps = std::make_shared<facebook::react::ScrollViewProps const>();
592
- m_props = defaultProps;
593
-
594
597
  // m_element.Content(m_contentPanel);
595
598
 
596
599
  /*
@@ -683,7 +686,8 @@ ScrollViewComponentView::ScrollViewComponentView(
683
686
  void ScrollViewComponentView::MountChildComponentView(
684
687
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
685
688
  uint32_t index) noexcept {
686
- base_type::MountChildComponentView(childComponentView, index);
689
+ // Call ComponentView::UnmountChildComponentView instead of base to handle out own Visual hosting
690
+ ComponentView::MountChildComponentView(childComponentView, index);
687
691
 
688
692
  ensureVisual();
689
693
  m_scrollVisual.InsertAt(
@@ -694,7 +698,8 @@ void ScrollViewComponentView::MountChildComponentView(
694
698
  void ScrollViewComponentView::UnmountChildComponentView(
695
699
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
696
700
  uint32_t index) noexcept {
697
- base_type::UnmountChildComponentView(childComponentView, index);
701
+ // Call ComponentView::UnmountChildComponentView instead of base to handle out own Visual hosting
702
+ ComponentView::UnmountChildComponentView(childComponentView, index);
698
703
  m_scrollVisual.Remove(childComponentView.as<ComponentView>()->OuterVisual());
699
704
  }
700
705
 
@@ -710,22 +715,17 @@ void ScrollViewComponentView::updateProps(
710
715
  facebook::react::Props::Shared const &props,
711
716
  facebook::react::Props::Shared const &oldProps) noexcept {
712
717
  const auto &newViewProps = *std::static_pointer_cast<const facebook::react::ScrollViewProps>(props);
713
- const auto &oldViewProps = *std::static_pointer_cast<const facebook::react::ScrollViewProps>(m_props);
718
+ const auto &oldViewProps =
719
+ *std::static_pointer_cast<const facebook::react::ScrollViewProps>(oldProps ? oldProps : viewProps());
714
720
 
715
721
  ensureVisual();
716
722
 
717
723
  if (!oldProps || oldViewProps.backgroundColor != newViewProps.backgroundColor) {
718
724
  updateBackgroundColor(newViewProps.backgroundColor);
719
725
  }
720
- if (oldViewProps.testId != newViewProps.testId) {
721
- m_visual.Comment(winrt::to_hstring(newViewProps.testId));
722
- }
723
726
 
724
727
  // update BaseComponentView props
725
- updateTransformProps(oldViewProps, newViewProps, m_visual);
726
- Super::updateProps(props, oldProps);
727
-
728
- m_props = std::static_pointer_cast<facebook::react::ViewProps const>(props);
728
+ base_type::updateProps(props, oldProps);
729
729
  }
730
730
 
731
731
  void ScrollViewComponentView::updateState(
@@ -758,16 +758,9 @@ void ScrollViewComponentView::updateLayoutMetrics(
758
758
  // Set Position & Size Properties
759
759
  ensureVisual();
760
760
 
761
- if ((layoutMetrics.displayType != m_layoutMetrics.displayType)) {
762
- OuterVisual().IsVisible(layoutMetrics.displayType != facebook::react::DisplayType::None);
763
- }
764
-
765
761
  m_verticalScrollbarComponent->updateLayoutMetrics(layoutMetrics);
766
762
  m_horizontalScrollbarComponent->updateLayoutMetrics(layoutMetrics);
767
- Super::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
768
- m_visual.Size(
769
- {layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
770
- layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
763
+ base_type::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
771
764
  m_scrollVisual.Size(
772
765
  {layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
773
766
  layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
@@ -785,10 +778,6 @@ void ScrollViewComponentView::updateContentVisualSize() noexcept {
785
778
 
786
779
  void ScrollViewComponentView::prepareForRecycle() noexcept {}
787
780
 
788
- facebook::react::SharedViewProps ScrollViewComponentView::viewProps() noexcept {
789
- return m_props;
790
- }
791
-
792
781
  /*
793
782
  ScrollViewComponentView::ScrollInteractionTrackerOwner::ScrollInteractionTrackerOwner(
794
783
  ScrollViewComponentView *outer)
@@ -835,7 +824,7 @@ void ScrollViewComponentView::OnPointerDown(const winrt::Windows::UI::Input::Poi
835
824
  */
836
825
 
837
826
  void ScrollViewComponentView::onThemeChanged() noexcept {
838
- updateBackgroundColor(std::static_pointer_cast<const facebook::react::ScrollViewProps>(m_props)->backgroundColor);
827
+ updateBackgroundColor(std::static_pointer_cast<const facebook::react::ScrollViewProps>(viewProps())->backgroundColor);
839
828
  m_verticalScrollbarComponent->OnThemeChanged();
840
829
  m_horizontalScrollbarComponent->OnThemeChanged();
841
830
  Super::onThemeChanged();
@@ -925,6 +914,8 @@ void ScrollViewComponentView::OnKeyDown(
925
914
  args.Handled(lineRight(true));
926
915
  break;
927
916
  }
917
+
918
+ base_type::OnKeyDown(source, args);
928
919
  }
929
920
 
930
921
  bool ScrollViewComponentView::scrollToEnd(bool animate) noexcept {
@@ -1131,37 +1122,35 @@ void ScrollViewComponentView::StartBringIntoView(
1131
1122
  }
1132
1123
  }
1133
1124
 
1134
- void ScrollViewComponentView::ensureVisual() noexcept {
1135
- if (!m_visual) {
1136
- m_visual = m_compContext.CreateSpriteVisual();
1137
- m_scrollVisual = m_compContext.CreateScrollerVisual();
1138
- m_verticalScrollbarComponent = std::make_shared<ScrollBarComponent>(*this, m_compContext, m_reactContext, true);
1139
- m_horizontalScrollbarComponent = std::make_shared<ScrollBarComponent>(*this, m_compContext, m_reactContext, false);
1140
- m_visual.InsertAt(m_scrollVisual, 0);
1141
- m_visual.InsertAt(m_verticalScrollbarComponent->Visual(), 1);
1142
- m_visual.InsertAt(m_horizontalScrollbarComponent->Visual(), 2);
1143
- m_scrollPositionChangedRevoker = m_scrollVisual.ScrollPositionChanged(
1144
- winrt::auto_revoke,
1145
- [this](
1146
- winrt::IInspectable const & /*sender*/,
1147
- winrt::Microsoft::ReactNative::Composition::Experimental::IScrollPositionChangedArgs const &args) {
1148
- updateStateWithContentOffset();
1149
- auto eventEmitter = GetEventEmitter();
1150
- if (eventEmitter) {
1151
- facebook::react::ScrollViewMetrics scrollMetrics;
1152
- scrollMetrics.containerSize.height = m_layoutMetrics.frame.size.height;
1153
- scrollMetrics.containerSize.width = m_layoutMetrics.frame.size.width;
1154
- scrollMetrics.contentOffset.x = args.Position().x / m_layoutMetrics.pointScaleFactor;
1155
- scrollMetrics.contentOffset.y = args.Position().y / m_layoutMetrics.pointScaleFactor;
1156
- scrollMetrics.zoomScale = 1.0;
1157
- scrollMetrics.contentSize.height = std::max(m_contentSize.height, m_layoutMetrics.frame.size.height);
1158
- scrollMetrics.contentSize.width = std::max(m_contentSize.width, m_layoutMetrics.frame.size.width);
1159
- std::static_pointer_cast<facebook::react::ScrollViewEventEmitter const>(eventEmitter)
1160
- ->onScroll(scrollMetrics);
1161
- }
1162
- });
1163
- OuterVisual().InsertAt(m_visual, 0);
1164
- }
1125
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ScrollViewComponentView::createVisual() noexcept {
1126
+ auto visual = m_compContext.CreateSpriteVisual();
1127
+ m_scrollVisual = m_compContext.CreateScrollerVisual();
1128
+ m_verticalScrollbarComponent = std::make_shared<ScrollBarComponent>(*this, m_compContext, m_reactContext, true);
1129
+ m_horizontalScrollbarComponent = std::make_shared<ScrollBarComponent>(*this, m_compContext, m_reactContext, false);
1130
+ visual.InsertAt(m_scrollVisual, 0);
1131
+ visual.InsertAt(m_verticalScrollbarComponent->Visual(), 1);
1132
+ visual.InsertAt(m_horizontalScrollbarComponent->Visual(), 2);
1133
+ m_scrollPositionChangedRevoker = m_scrollVisual.ScrollPositionChanged(
1134
+ winrt::auto_revoke,
1135
+ [this](
1136
+ winrt::IInspectable const & /*sender*/,
1137
+ winrt::Microsoft::ReactNative::Composition::Experimental::IScrollPositionChangedArgs const &args) {
1138
+ updateStateWithContentOffset();
1139
+ auto eventEmitter = GetEventEmitter();
1140
+ if (eventEmitter) {
1141
+ facebook::react::ScrollViewMetrics scrollMetrics;
1142
+ scrollMetrics.containerSize.height = m_layoutMetrics.frame.size.height;
1143
+ scrollMetrics.containerSize.width = m_layoutMetrics.frame.size.width;
1144
+ scrollMetrics.contentOffset.x = args.Position().x / m_layoutMetrics.pointScaleFactor;
1145
+ scrollMetrics.contentOffset.y = args.Position().y / m_layoutMetrics.pointScaleFactor;
1146
+ scrollMetrics.zoomScale = 1.0;
1147
+ scrollMetrics.contentSize.height = std::max(m_contentSize.height, m_layoutMetrics.frame.size.height);
1148
+ scrollMetrics.contentSize.width = std::max(m_contentSize.width, m_layoutMetrics.frame.size.width);
1149
+ std::static_pointer_cast<facebook::react::ScrollViewEventEmitter const>(eventEmitter)
1150
+ ->onScroll(scrollMetrics);
1151
+ }
1152
+ });
1153
+ return visual;
1165
1154
  }
1166
1155
 
1167
1156
  facebook::react::Tag ScrollViewComponentView::hitTest(
@@ -1174,19 +1163,19 @@ facebook::react::Tag ScrollViewComponentView::hitTest(
1174
1163
  ptViewport.x + m_scrollVisual.ScrollPosition().x / m_layoutMetrics.pointScaleFactor,
1175
1164
  ptViewport.y + m_scrollVisual.ScrollPosition().y / m_layoutMetrics.pointScaleFactor};
1176
1165
 
1177
- facebook::react::Tag targetTag;
1166
+ facebook::react::Tag targetTag = -1;
1178
1167
 
1179
- if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1180
- m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
1168
+ if ((ignorePointerEvents || viewProps()->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1169
+ viewProps()->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
1181
1170
  ptViewport.x >= 0 && ptViewport.x <= m_layoutMetrics.frame.size.width && ptViewport.y >= 0 &&
1182
1171
  ptViewport.y <= m_layoutMetrics.frame.size.height) {
1183
- if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1184
- m_props->pointerEvents == facebook::react::PointerEventsMode::BoxNone) &&
1172
+ if ((ignorePointerEvents || viewProps()->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1173
+ viewProps()->pointerEvents == facebook::react::PointerEventsMode::BoxNone) &&
1185
1174
  anyHitTestHelper(targetTag, ptContent, localPt))
1186
1175
  return targetTag;
1187
1176
 
1188
- if (ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1189
- m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) {
1177
+ if (ignorePointerEvents || viewProps()->pointerEvents == facebook::react::PointerEventsMode::Auto ||
1178
+ viewProps()->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) {
1190
1179
  return this->Tag();
1191
1180
  }
1192
1181
  }
@@ -1208,10 +1197,6 @@ facebook::react::Point ScrollViewComponentView::getClientOffset() const noexcept
1208
1197
  parentOffset.y};
1209
1198
  }
1210
1199
 
1211
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ScrollViewComponentView::Visual() const noexcept {
1212
- return m_visual;
1213
- }
1214
-
1215
1200
  std::string ScrollViewComponentView::DefaultControlType() const noexcept {
1216
1201
  return "scrollbar";
1217
1202
  }
@@ -20,7 +20,7 @@ namespace winrt::Microsoft::ReactNative::Composition::implementation {
20
20
 
21
21
  struct ScrollBarComponent;
22
22
 
23
- struct ScrollViewComponentView : ScrollViewComponentViewT<ScrollViewComponentView, ComponentView> {
23
+ struct ScrollViewComponentView : ScrollViewComponentViewT<ScrollViewComponentView, ViewComponentView> {
24
24
  /*
25
25
  struct ScrollInteractionTrackerOwner : public winrt::implements<
26
26
  ScrollInteractionTrackerOwner,
@@ -51,7 +51,7 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
51
51
  };
52
52
 
53
53
  */
54
- using Super = ScrollViewComponentViewT<ScrollViewComponentView, ComponentView>;
54
+ using Super = ScrollViewComponentViewT<ScrollViewComponentView, ViewComponentView>;
55
55
 
56
56
  [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
57
57
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -72,7 +72,6 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
72
72
  facebook::react::LayoutMetrics const &layoutMetrics,
73
73
  facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
74
74
  void prepareForRecycle() noexcept override;
75
- facebook::react::SharedViewProps viewProps() noexcept override;
76
75
  void OnKeyDown(
77
76
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
78
77
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
@@ -82,7 +81,6 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
82
81
  facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
83
82
  const noexcept override;
84
83
  facebook::react::Point getClientOffset() const noexcept override;
85
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
86
84
 
87
85
  void onThemeChanged() noexcept override;
88
86
  void OnPointerReleased(
@@ -100,6 +98,8 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
100
98
 
101
99
  void scrollTo(winrt::Windows::Foundation::Numerics::float3 offset, bool animate) noexcept;
102
100
 
101
+ static facebook::react::SharedViewProps defaultProps() noexcept;
102
+
103
103
  ScrollViewComponentView(
104
104
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
105
105
  facebook::react::Tag tag,
@@ -111,9 +111,9 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
111
111
  bool lineDown(bool animate) noexcept;
112
112
  bool lineLeft(bool animate) noexcept;
113
113
  bool lineRight(bool animate) noexcept;
114
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual createVisual() noexcept override;
114
115
 
115
116
  private:
116
- void ensureVisual() noexcept;
117
117
  void updateContentVisualSize() noexcept;
118
118
  bool scrollToEnd(bool animate) noexcept;
119
119
  bool scrollToStart(bool animate) noexcept;
@@ -125,14 +125,12 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
125
125
  void updateStateWithContentOffset() noexcept;
126
126
 
127
127
  facebook::react::Size m_contentSize;
128
- winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
129
128
  winrt::Microsoft::ReactNative::Composition::Experimental::IScrollVisual m_scrollVisual{nullptr};
130
129
  std::shared_ptr<ScrollBarComponent> m_horizontalScrollbarComponent{nullptr};
131
130
  std::shared_ptr<ScrollBarComponent> m_verticalScrollbarComponent{nullptr};
132
131
  winrt::Microsoft::ReactNative::Composition::Experimental::IScrollVisual::ScrollPositionChanged_revoker
133
132
  m_scrollPositionChangedRevoker{};
134
133
 
135
- facebook::react::SharedViewProps m_props;
136
134
  float m_zoomFactor{1.0f};
137
135
  bool m_isScrollingFromInertia = false;
138
136
  bool m_isScrolling = false;