@@ -122,8 +122,8 @@ already_AddRefed<Promise> XRSystem::IsSessionSupported(XRSessionMode aMode,
122
122
}
123
123
124
124
already_AddRefed<Promise> XRSystem::RequestSession (
125
- JSContext* aCx, XRSessionMode aMode, const XRSessionInit& aOptions,
126
- CallerType aCallerType, ErrorResult& aRv) {
125
+ XRSessionMode aMode, const XRSessionInit& aOptions, CallerType aCallerType ,
126
+ ErrorResult& aRv) {
127
127
nsCOMPtr<nsIGlobalObject> global = GetParentObject ();
128
128
NS_ENSURE_TRUE (global, nullptr );
129
129
@@ -166,49 +166,27 @@ already_AddRefed<Promise> XRSystem::RequestSession(
166
166
requiredReferenceSpaceTypes.AppendElement (XRReferenceSpaceType::Local);
167
167
}
168
168
169
- BindingCallContext callCx (aCx, " XRSystem.requestSession" );
170
-
171
169
if (aOptions.mRequiredFeatures .WasPassed ()) {
172
- const Sequence<JS::Value>& arr = (aOptions.mRequiredFeatures .Value ());
173
- for (const JS::Value& val : arr) {
174
- if (!val.isNull () && !val.isUndefined ()) {
175
- bool bFound = false ;
176
- JS::Rooted<JS::Value> v (aCx, val);
177
- int index = 0 ;
178
- if (FindEnumStringIndex<false >(
179
- callCx, v, XRReferenceSpaceTypeValues::strings,
180
- " XRReferenceSpaceType" , " Argument 2 of XR.requestSession" ,
181
- &index)) {
182
- if (index >= 0 ) {
183
- requiredReferenceSpaceTypes.AppendElement (
184
- static_cast <XRReferenceSpaceType>(index));
185
- bFound = true ;
186
- }
187
- }
188
- if (!bFound) {
189
- promise->MaybeRejectWithNotSupportedError (
190
- " A required feature for the XRSession is not available." );
191
- return promise.forget ();
192
- }
170
+ for (const nsString& val : aOptions.mRequiredFeatures .Value ()) {
171
+ int index = FindEnumStringIndexImpl (val.BeginReading (), val.Length (),
172
+ XRReferenceSpaceTypeValues::strings);
173
+ if (index < 0 ) {
174
+ promise->MaybeRejectWithNotSupportedError (
175
+ " A required feature for the XRSession is not available." );
176
+ return promise.forget ();
193
177
}
178
+ requiredReferenceSpaceTypes.AppendElement (
179
+ static_cast <XRReferenceSpaceType>(index));
194
180
}
195
181
}
196
182
197
183
if (aOptions.mOptionalFeatures .WasPassed ()) {
198
- const Sequence<JS::Value>& arr = (aOptions.mOptionalFeatures .Value ());
199
- for (const JS::Value& val : arr) {
200
- if (!val.isNull () && !val.isUndefined ()) {
201
- JS::Rooted<JS::Value> v (aCx, val);
202
- int index = 0 ;
203
- if (FindEnumStringIndex<false >(
204
- callCx, v, XRReferenceSpaceTypeValues::strings,
205
- " XRReferenceSpaceType" , " Argument 2 of XR.requestSession" ,
206
- &index)) {
207
- if (index >= 0 ) {
208
- optionalReferenceSpaceTypes.AppendElement (
209
- static_cast <XRReferenceSpaceType>(index));
210
- }
211
- }
184
+ for (const nsString& val : aOptions.mOptionalFeatures .Value ()) {
185
+ int index = FindEnumStringIndexImpl (val.BeginReading (), val.Length (),
186
+ XRReferenceSpaceTypeValues::strings);
187
+ if (index >= 0 ) {
188
+ optionalReferenceSpaceTypes.AppendElement (
189
+ static_cast <XRReferenceSpaceType>(index));
212
190
}
213
191
}
214
192
}
0 commit comments