summaryrefslogtreecommitdiffstats
path: root/dom/vr/XRSystem.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /dom/vr/XRSystem.cpp
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/vr/XRSystem.cpp')
-rw-r--r--dom/vr/XRSystem.cpp54
1 files changed, 15 insertions, 39 deletions
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<Promise> XRSystem::IsSessionSupported(XRSessionMode aMode,
}
already_AddRefed<Promise> XRSystem::RequestSession(
- JSContext* aCx, XRSessionMode aMode, const XRSessionInit& aOptions,
- CallerType aCallerType, ErrorResult& aRv) {
+ XRSessionMode aMode, const XRSessionInit& aOptions, CallerType aCallerType,
+ ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> global = GetParentObject();
NS_ENSURE_TRUE(global, nullptr);
@@ -166,49 +166,25 @@ already_AddRefed<Promise> XRSystem::RequestSession(
requiredReferenceSpaceTypes.AppendElement(XRReferenceSpaceType::Local);
}
- BindingCallContext callCx(aCx, "XRSystem.requestSession");
-
if (aOptions.mRequiredFeatures.WasPassed()) {
- const Sequence<JS::Value>& arr = (aOptions.mRequiredFeatures.Value());
- for (const JS::Value& val : arr) {
- if (!val.isNull() && !val.isUndefined()) {
- bool bFound = false;
- JS::Rooted<JS::Value> v(aCx, val);
- int index = 0;
- if (FindEnumStringIndex<false>(
- callCx, v, XRReferenceSpaceTypeValues::strings,
- "XRReferenceSpaceType", "Argument 2 of XR.requestSession",
- &index)) {
- if (index >= 0) {
- requiredReferenceSpaceTypes.AppendElement(
- static_cast<XRReferenceSpaceType>(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<XRReferenceSpaceType> type =
+ StringToEnum<XRReferenceSpaceType>(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<JS::Value>& arr = (aOptions.mOptionalFeatures.Value());
- for (const JS::Value& val : arr) {
- if (!val.isNull() && !val.isUndefined()) {
- JS::Rooted<JS::Value> v(aCx, val);
- int index = 0;
- if (FindEnumStringIndex<false>(
- callCx, v, XRReferenceSpaceTypeValues::strings,
- "XRReferenceSpaceType", "Argument 2 of XR.requestSession",
- &index)) {
- if (index >= 0) {
- optionalReferenceSpaceTypes.AppendElement(
- static_cast<XRReferenceSpaceType>(index));
- }
- }
+ for (const nsString& val : aOptions.mOptionalFeatures.Value()) {
+ Maybe<XRReferenceSpaceType> type =
+ StringToEnum<XRReferenceSpaceType>(val);
+ if (type.isSome()) {
+ optionalReferenceSpaceTypes.AppendElement(type.value());
}
}
}