react-native-windows 0.77.4 → 0.77.6

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.
@@ -3,6 +3,7 @@
3
3
  #include <Fabric/ComponentView.h>
4
4
  #include <Fabric/Composition/CompositionTextRangeProvider.h>
5
5
  #include <Fabric/Composition/ParagraphComponentView.h>
6
+ #include <Fabric/Composition/ScrollViewComponentView.h>
6
7
  #include <Fabric/Composition/SwitchComponentView.h>
7
8
  #include <Fabric/Composition/TextInput/WindowsTextInputComponentView.h>
8
9
  #include <Unicode.h>
@@ -215,6 +216,12 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
215
216
  AddRef();
216
217
  }
217
218
 
219
+ if (patternId == UIA_ScrollPatternId &&
220
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>()) {
221
+ *pRetVal = static_cast<IScrollProvider *>(this);
222
+ AddRef();
223
+ }
224
+
218
225
  if (patternId == UIA_ValuePatternId &&
219
226
  ((strongView
220
227
  .try_as<winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView>() &&
@@ -325,6 +332,8 @@ long GetControlTypeFromString(const std::string &role) noexcept {
325
332
  return UIA_TreeControlTypeId;
326
333
  } else if (role == "treeitem") {
327
334
  return UIA_TreeItemControlTypeId;
335
+ } else if (role == "pane") {
336
+ return UIA_PaneControlTypeId;
328
337
  }
329
338
  assert(false);
330
339
  return UIA_GroupControlTypeId;
@@ -590,6 +599,156 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::ScrollIntoView() {
590
599
  return S_OK;
591
600
  }
592
601
 
602
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_HorizontalScrollPercent(double *pRetVal) {
603
+ BOOL horizontallyScrollable;
604
+ auto hr = get_HorizontallyScrollable(&horizontallyScrollable);
605
+ if (!SUCCEEDED(hr)) {
606
+ return hr;
607
+ }
608
+ if (!horizontallyScrollable) {
609
+ *pRetVal = UIA_ScrollPatternNoScroll;
610
+ } else {
611
+ auto strongView = m_view.view();
612
+ auto scrollComponentView =
613
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>();
614
+ *pRetVal = scrollComponentView->getScrollPositionX();
615
+ }
616
+ return S_OK;
617
+ }
618
+
619
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_VerticalScrollPercent(double *pRetVal) {
620
+ BOOL verticallyScrollable;
621
+ auto hr = get_VerticallyScrollable(&verticallyScrollable);
622
+ if (!SUCCEEDED(hr)) {
623
+ return hr;
624
+ }
625
+ if (!verticallyScrollable) {
626
+ *pRetVal = UIA_ScrollPatternNoScroll;
627
+ } else {
628
+ auto strongView = m_view.view();
629
+ auto scrollComponentView =
630
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>();
631
+ *pRetVal = scrollComponentView->getScrollPositionY();
632
+ }
633
+ return S_OK;
634
+ }
635
+
636
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_HorizontalViewSize(double *pRetVal) {
637
+ BOOL horizontallyScrollable;
638
+ auto hr = get_HorizontallyScrollable(&horizontallyScrollable);
639
+ if (!SUCCEEDED(hr)) {
640
+ return hr;
641
+ }
642
+ if (!horizontallyScrollable) {
643
+ *pRetVal = 100;
644
+ } else {
645
+ auto strongView = m_view.view();
646
+ auto scrollComponentView =
647
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>();
648
+ *pRetVal = scrollComponentView->getHorizontalSize();
649
+ }
650
+ return S_OK;
651
+ }
652
+
653
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_VerticalViewSize(double *pRetVal) {
654
+ BOOL verticallyScrollable;
655
+ auto hr = get_VerticallyScrollable(&verticallyScrollable);
656
+ if (!SUCCEEDED(hr)) {
657
+ return hr;
658
+ }
659
+ if (!verticallyScrollable) {
660
+ *pRetVal = 100;
661
+ } else {
662
+ auto strongView = m_view.view();
663
+ auto scrollComponentView =
664
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>();
665
+ *pRetVal = scrollComponentView->getVerticalSize();
666
+ }
667
+ return S_OK;
668
+ }
669
+
670
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_HorizontallyScrollable(BOOL *pRetVal) {
671
+ if (pRetVal == nullptr)
672
+ return E_POINTER;
673
+ auto strongView = m_view.view();
674
+
675
+ if (!strongView)
676
+ return UIA_E_ELEMENTNOTAVAILABLE;
677
+
678
+ auto props = std::static_pointer_cast<const facebook::react::ScrollViewProps>(
679
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
680
+ if (props == nullptr)
681
+ return UIA_E_ELEMENTNOTAVAILABLE;
682
+ *pRetVal = (props->horizontal && props->scrollEnabled);
683
+ return S_OK;
684
+ }
685
+
686
+ HRESULT __stdcall CompositionDynamicAutomationProvider::get_VerticallyScrollable(BOOL *pRetVal) {
687
+ if (pRetVal == nullptr)
688
+ return E_POINTER;
689
+ auto strongView = m_view.view();
690
+
691
+ if (!strongView)
692
+ return UIA_E_ELEMENTNOTAVAILABLE;
693
+
694
+ auto props = std::static_pointer_cast<const facebook::react::ScrollViewProps>(
695
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
696
+ if (props == nullptr)
697
+ return UIA_E_ELEMENTNOTAVAILABLE;
698
+ *pRetVal = (!props->horizontal && props->scrollEnabled);
699
+ return S_OK;
700
+ }
701
+
702
+ HRESULT __stdcall CompositionDynamicAutomationProvider::Scroll(
703
+ ScrollAmount horizontalAmount,
704
+ ScrollAmount verticalAmount) {
705
+ DispatchAccessibilityAction(m_view, "scroll");
706
+ auto strongView = m_view.view();
707
+ auto scrollComponentView =
708
+ strongView.try_as<winrt::Microsoft::ReactNative::Composition::implementation::ScrollViewComponentView>();
709
+ BOOL verticallyScrollable;
710
+ BOOL horizontallyScrollable;
711
+ float vertical = 0.0f;
712
+ float horizontal = 0.0f;
713
+ auto hr = get_VerticallyScrollable(&verticallyScrollable);
714
+ if (!SUCCEEDED(hr)) {
715
+ return hr;
716
+ }
717
+ if (verticallyScrollable) {
718
+ if (verticalAmount == ScrollAmount_LargeIncrement) {
719
+ scrollComponentView->pageDown(true);
720
+ } else if (verticalAmount == ScrollAmount_LargeDecrement) {
721
+ scrollComponentView->pageUp(true);
722
+ } else if (verticalAmount == ScrollAmount_SmallIncrement) {
723
+ scrollComponentView->lineDown(true);
724
+ } else if (verticalAmount == ScrollAmount_SmallDecrement) {
725
+ scrollComponentView->lineUp(true);
726
+ }
727
+ }
728
+ hr = get_HorizontallyScrollable(&horizontallyScrollable);
729
+ if (!SUCCEEDED(hr)) {
730
+ return hr;
731
+ }
732
+ if (horizontallyScrollable) {
733
+ if (horizontalAmount == ScrollAmount_LargeIncrement) {
734
+ scrollComponentView->pageDown(true);
735
+ } else if (horizontalAmount == ScrollAmount_LargeDecrement) {
736
+ scrollComponentView->pageUp(true);
737
+ } else if (horizontalAmount == ScrollAmount_SmallIncrement) {
738
+ scrollComponentView->lineRight(true);
739
+ } else if (horizontalAmount == ScrollAmount_SmallDecrement) {
740
+ scrollComponentView->lineLeft(true);
741
+ }
742
+ }
743
+ return S_OK;
744
+ }
745
+
746
+ HRESULT __stdcall CompositionDynamicAutomationProvider::SetScrollPercent(
747
+ double horiztonalPercent,
748
+ double verticalPercent) {
749
+ return S_OK;
750
+ }
751
+
593
752
  BSTR StringToBSTR(const std::string &str) {
594
753
  // Calculate the required BSTR size in bytes
595
754
  int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0);
@@ -15,6 +15,7 @@ class CompositionDynamicAutomationProvider : public winrt::implements<
15
15
  IRawElementProviderSimple,
16
16
  IInvokeProvider,
17
17
  IScrollItemProvider,
18
+ IScrollProvider,
18
19
  IValueProvider,
19
20
  IRangeValueProvider,
20
21
  IToggleProvider,
@@ -46,6 +47,16 @@ class CompositionDynamicAutomationProvider : public winrt::implements<
46
47
  // inherited via IScrollItemProvider
47
48
  HRESULT __stdcall ScrollIntoView() override;
48
49
 
50
+ // inherited via IScrollProvider
51
+ HRESULT __stdcall get_HorizontalScrollPercent(double *pRetVal) override;
52
+ HRESULT __stdcall get_VerticalScrollPercent(double *pRetVal) override;
53
+ HRESULT __stdcall get_HorizontalViewSize(double *pRetVal) override;
54
+ HRESULT __stdcall get_VerticalViewSize(double *pRetVal) override;
55
+ HRESULT __stdcall get_HorizontallyScrollable(BOOL *pRetVal) override;
56
+ HRESULT __stdcall get_VerticallyScrollable(BOOL *pRetVal) override;
57
+ HRESULT __stdcall Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount) override;
58
+ HRESULT __stdcall SetScrollPercent(double horiztonalPercent, double verticalPercent) override;
59
+
49
60
  // inherited via IValueProvider
50
61
  virtual HRESULT __stdcall SetValue(LPCWSTR val) override;
51
62
  virtual HRESULT __stdcall get_Value(BSTR *pRetVal) override;
@@ -976,10 +976,16 @@ bool ScrollViewComponentView::scrollToStart(bool animate) noexcept {
976
976
  }
977
977
 
978
978
  bool ScrollViewComponentView::pageUp(bool animate) noexcept {
979
+ if (std::static_pointer_cast<const facebook::react::ScrollViewProps>(viewProps())->horizontal) {
980
+ return scrollLeft(m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor, animate);
981
+ }
979
982
  return scrollUp(m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor, animate);
980
983
  }
981
984
 
982
985
  bool ScrollViewComponentView::pageDown(bool animate) noexcept {
986
+ if (std::static_pointer_cast<const facebook::react::ScrollViewProps>(viewProps())->horizontal) {
987
+ return scrollRight(m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor, animate);
988
+ }
983
989
  return scrollDown(m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor, animate);
984
990
  }
985
991
 
@@ -1036,7 +1042,7 @@ bool ScrollViewComponentView::scrollLeft(float delta, bool animate) noexcept {
1036
1042
  return false;
1037
1043
  }
1038
1044
 
1039
- m_scrollVisual.ScrollBy({delta, 0, 0}, animate);
1045
+ m_scrollVisual.ScrollBy({-delta, 0, 0}, animate);
1040
1046
  return true;
1041
1047
  }
1042
1048
 
@@ -1259,7 +1265,7 @@ facebook::react::Point ScrollViewComponentView::getClientOffset() const noexcept
1259
1265
  }
1260
1266
 
1261
1267
  std::string ScrollViewComponentView::DefaultControlType() const noexcept {
1262
- return "scrollbar";
1268
+ return "pane";
1263
1269
  }
1264
1270
 
1265
1271
  winrt::com_ptr<ComponentView> ScrollViewComponentView::focusVisualRoot(
@@ -1272,4 +1278,20 @@ ScrollViewComponentView::visualToHostFocus() noexcept {
1272
1278
  return m_scrollVisual;
1273
1279
  }
1274
1280
 
1281
+ int ScrollViewComponentView::getScrollPositionX() noexcept {
1282
+ return int((m_scrollVisual.ScrollPosition().x / m_horizontalScrollbarComponent->getScrollRange()) * 100);
1283
+ }
1284
+
1285
+ int ScrollViewComponentView::getScrollPositionY() noexcept {
1286
+ return int((m_scrollVisual.ScrollPosition().y / m_verticalScrollbarComponent->getScrollRange()) * 100);
1287
+ }
1288
+
1289
+ double ScrollViewComponentView::getVerticalSize() noexcept {
1290
+ return std::min((m_layoutMetrics.frame.size.height / m_contentSize.height * 100.0), 100.0);
1291
+ }
1292
+
1293
+ double ScrollViewComponentView::getHorizontalSize() noexcept {
1294
+ return std::min((m_layoutMetrics.frame.size.width / m_contentSize.width * 100.0), 100.0);
1295
+ }
1296
+
1275
1297
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -113,6 +113,11 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
113
113
  winrt::Microsoft::ReactNative::Composition::Experimental::IVisual visualToHostFocus() noexcept override;
114
114
  winrt::com_ptr<ComponentView> focusVisualRoot(const facebook::react::Rect &focusRect) noexcept override;
115
115
 
116
+ int getScrollPositionX() noexcept;
117
+ int getScrollPositionY() noexcept;
118
+ double getVerticalSize() noexcept;
119
+ double getHorizontalSize() noexcept;
120
+
116
121
  private:
117
122
  void updateContentVisualSize() noexcept;
118
123
  bool scrollToEnd(bool animate) noexcept;
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.77.4</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.77.6</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>77</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>4</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>6</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>657f0d9a8915223e83f1ef043045b0da2f049af3</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>faf22821e34fd9786923c6241e445b2f9fb530bd</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.77.4",
3
+ "version": "0.77.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",