From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/vr/XRSystem.cpp | 54 +++++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) (limited to 'dom/vr/XRSystem.cpp') diff --git a/dom/vr/XRSystem.cpp b/dom/vr/XRSystem.cpp index 09b9e07476..2dd66e41f4 100644 --- a/dom/vr/XRSystem.cpp +++ b/dom/vr/XRSystem.cpp @@ -122,8 +122,8 @@ already_AddRefed XRSystem::IsSessionSupported(XRSessionMode aMode, } already_AddRefed XRSystem::RequestSession( - JSContext* aCx, XRSessionMode aMode, const XRSessionInit& aOptions, - CallerType aCallerType, ErrorResult& aRv) { + XRSessionMode aMode, const XRSessionInit& aOptions, CallerType aCallerType, + ErrorResult& aRv) { nsCOMPtr global = GetParentObject(); NS_ENSURE_TRUE(global, nullptr); @@ -166,49 +166,25 @@ already_AddRefed XRSystem::RequestSession( requiredReferenceSpaceTypes.AppendElement(XRReferenceSpaceType::Local); } - BindingCallContext callCx(aCx, "XRSystem.requestSession"); - if (aOptions.mRequiredFeatures.WasPassed()) { - const Sequence& arr = (aOptions.mRequiredFeatures.Value()); - for (const JS::Value& val : arr) { - if (!val.isNull() && !val.isUndefined()) { - bool bFound = false; - JS::Rooted v(aCx, val); - int index = 0; - if (FindEnumStringIndex( - callCx, v, XRReferenceSpaceTypeValues::strings, - "XRReferenceSpaceType", "Argument 2 of XR.requestSession", - &index)) { - if (index >= 0) { - requiredReferenceSpaceTypes.AppendElement( - static_cast(index)); - bFound = true; - } - } - if (!bFound) { - promise->MaybeRejectWithNotSupportedError( - "A required feature for the XRSession is not available."); - return promise.forget(); - } + for (const nsString& val : aOptions.mRequiredFeatures.Value()) { + Maybe type = + StringToEnum(val); + if (type.isNothing()) { + promise->MaybeRejectWithNotSupportedError( + "A required feature for the XRSession is not available."); + return promise.forget(); } + requiredReferenceSpaceTypes.AppendElement(type.value()); } } if (aOptions.mOptionalFeatures.WasPassed()) { - const Sequence& arr = (aOptions.mOptionalFeatures.Value()); - for (const JS::Value& val : arr) { - if (!val.isNull() && !val.isUndefined()) { - JS::Rooted v(aCx, val); - int index = 0; - if (FindEnumStringIndex( - callCx, v, XRReferenceSpaceTypeValues::strings, - "XRReferenceSpaceType", "Argument 2 of XR.requestSession", - &index)) { - if (index >= 0) { - optionalReferenceSpaceTypes.AppendElement( - static_cast(index)); - } - } + for (const nsString& val : aOptions.mOptionalFeatures.Value()) { + Maybe type = + StringToEnum(val); + if (type.isSome()) { + optionalReferenceSpaceTypes.AppendElement(type.value()); } } } -- cgit v1.2.3