Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IRangeValueProvider #12356

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "initial rangevalueprovider changes",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
4 changes: 4 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/ComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ struct IComponentView {
bool ignorePointerEvents = false) const noexcept = 0;
virtual winrt::IInspectable EnsureUiaProvider() noexcept = 0;
virtual std::optional<std::string> getAcccessiblityValue() noexcept = 0;
virtual std::optional<int> getAcccessiblityValueNow() noexcept = 0;
virtual std::optional<int> getAcccessiblityValueMax() noexcept = 0;
virtual std::optional<int> getAcccessiblityValueMin() noexcept = 0;
virtual void setAcccessiblityValue(std::string &&value) noexcept = 0;
virtual void setAcccessiblityRangeValue(double value) noexcept = 0;
virtual bool getAcccessiblityIsReadOnly() noexcept = 0;

// Notify up the tree to bring the rect into view by scrolling as needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
AddRef();
}

if (patternId == UIA_RangeValuePatternId) {
*pRetVal = static_cast<IRangeValueProvider *>(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably only return this pattern if the role is set to something that aligns with this pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also do a role check for UIA_ValuePatternId as well (i.e if the role is not 'adjustable' or 'progressbar' since those roles correspond to RangeValuePattern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea i think we'll want roles checks for each of these!

AddRef();
}



return S_OK;
}

Expand Down Expand Up @@ -405,4 +412,70 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::get_IsReadOnly(BOOL *pRe
return S_OK;
}

HRESULT __stdcall CompositionDynamicAutomationProvider::SetValue([in] double val) {
auto strongView = m_view.view();

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

strongView->setAcccessiblityRangeValue(val);
return S_OK;
}

HRESULT __stdcall CompositionDynamicAutomationProvider::get_LargeChange(double* pRetVal) {
if (pRetVal == nullptr)
return E_POINTER;



return S_OK;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

HRESULT __stdcall CompositionDynamicAutomationProvider::get_Maximum(double *pRetVal) {
if (pRetVal == nullptr)
return E_POINTER;

auto strongView = m_view.view();

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

*pRetVal = static_cast<double>(*strongView->getAcccessiblityValueMax());

return S_OK;
}

HRESULT __stdcall CompositionDynamicAutomationProvider::get_Minimum(double *pRetVal) {
if (pRetVal == nullptr)
return E_POINTER;

auto strongView = m_view.view();

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

*pRetVal = static_cast<double>(*strongView->getAcccessiblityValueMin());

return S_OK;
}

HRESULT __stdcall CompositionDynamicAutomationProvider::get_SmallChange(double *pRetVal) {
if (pRetVal == nullptr)
return E_POINTER;
return S_OK;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should return quiet NaN

}

HRESULT __stdcall CompositionDynamicAutomationProvider::get_Value(double *pRetVal) {
if (pRetVal == nullptr)
return E_POINTER;
auto strongView = m_view.view();

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

*pRetVal = static_cast<double>(*strongView->getAcccessiblityValueNow());

return S_OK;
}

} // namespace winrt::Microsoft::ReactNative::implementation
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class CompositionDynamicAutomationProvider : public winrt::implements<
IRawElementProviderSimple,
IInvokeProvider,
IScrollItemProvider,
IValueProvider> {
IValueProvider,
IRangeValueProvider> {
public:
CompositionDynamicAutomationProvider(
const std::shared_ptr<::Microsoft::ReactNative::CompositionBaseComponentView> &componentView) noexcept;
Expand Down Expand Up @@ -46,6 +47,20 @@ class CompositionDynamicAutomationProvider : public winrt::implements<
virtual HRESULT __stdcall get_Value(BSTR *pRetVal) override;
virtual HRESULT __stdcall get_IsReadOnly(BOOL *pRetVal) override;

// inherited via IRangeValueProvider
virtual HRESULT __stdcall SetValue([in] double val) override;
virtual HRESULT __stdcall get_IsReadOnly(BOOL *pRetVal) override;
virtual HRESULT __stdcall get_LargeChange(double *pRetVal) override;
virtual HRESULT __stdcall get_Maximum(double *pRetVal) override;
virtual HRESULT __stdcall get_Minimum(double *pRetVal) override;
virtual HRESULT __stdcall get_SmallChange(double *pRetVal) override;
virtual HRESULT __stdcall get_Value(double *pRetVal) override;






private:
::Microsoft::ReactNative::ReactTaggedView m_view;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1302,10 +1302,28 @@ std::optional<std::string> CompositionBaseComponentView::getAcccessiblityValue()
return std::static_pointer_cast<const facebook::react::ViewProps>(props())->accessibilityValue.text;
}

std::optional<int> CompositionBaseComponentView::getAcccessiblityValueNow() noexcept {
return std::static_pointer_cast<const facebook::react::ViewProps>(props())->accessibilityValue.now;
}

std::optional<int> CompositionBaseComponentView::getAcccessiblityValueMax() noexcept {
return std::static_pointer_cast<const facebook::react::ViewProps>(props())->accessibilityValue.max;
}

std::optional<int> CompositionBaseComponentView::getAcccessiblityValueMin() noexcept {
return std::static_pointer_cast<const facebook::react::ViewProps>(props())->accessibilityValue.min;
}



void CompositionBaseComponentView::setAcccessiblityValue(std::string &&value) noexcept {
// no-op
}

void CompositionBaseComponentView::setAcccessiblityRangeValue(double value) noexcept {
// no-op
}

bool CompositionBaseComponentView::getAcccessiblityIsReadOnly() noexcept {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ struct CompositionBaseComponentView : public IComponentView,

winrt::IInspectable EnsureUiaProvider() noexcept override;
std::optional<std::string> getAcccessiblityValue() noexcept override;
std::optional<int> getAcccessiblityValueNow() noexcept;
std::optional<int> getAcccessiblityValueMax() noexcept;
std::optional<int> getAcccessiblityValueMin() noexcept;
void setAcccessiblityValue(std::string &&value) noexcept override;
void setAcccessiblityRangeValue(double value) noexcept override;
bool getAcccessiblityIsReadOnly() noexcept override;
ClipState getClipState() noexcept override;

Expand Down
Loading