LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - SpeechRecognitionEventBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 331 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 22 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM SpeechRecognitionEvent.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventBinding.h"
       5             : #include "SpeechRecognition.h"
       6             : #include "SpeechRecognitionEventBinding.h"
       7             : #include "WrapperFactory.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/Preferences.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/Nullable.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/ScriptSettings.h"
      16             : #include "mozilla/dom/SpeechRecognitionEvent.h"
      17             : #include "mozilla/dom/SpeechRecognitionResultList.h"
      18             : #include "mozilla/dom/XrayExpandoClass.h"
      19             : #include "nsIDocument.h"
      20             : 
      21             : namespace mozilla {
      22             : namespace dom {
      23             : 
      24             : 
      25           0 : SpeechRecognitionEventInit::SpeechRecognitionEventInit()
      26           0 :   : EventInit(FastDictionaryInitializer()),
      27           0 :     mInterpretation(JS::UndefinedValue())
      28             : {
      29             :   // Safe to pass a null context if we pass a null value
      30           0 :   Init(nullptr, JS::NullHandleValue);
      31           0 : }
      32             : 
      33             : 
      34             : bool
      35           0 : SpeechRecognitionEventInit::InitIds(JSContext* cx, SpeechRecognitionEventInitAtoms* atomsCache)
      36             : {
      37           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      38             : 
      39             :   // Initialize these in reverse order so that any failure leaves the first one
      40             :   // uninitialized.
      41           0 :   if (!atomsCache->results_id.init(cx, "results") ||
      42           0 :       !atomsCache->resultIndex_id.init(cx, "resultIndex") ||
      43           0 :       !atomsCache->interpretation_id.init(cx, "interpretation") ||
      44           0 :       !atomsCache->emma_id.init(cx, "emma")) {
      45           0 :     return false;
      46             :   }
      47           0 :   return true;
      48             : }
      49             : 
      50             : bool
      51           0 : SpeechRecognitionEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      52             : {
      53             :   // Passing a null JSContext is OK only if we're initing from null,
      54             :   // Since in that case we will not have to do any property gets
      55             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      56             :   // checkers by static analysis tools
      57           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      58           0 :   SpeechRecognitionEventInitAtoms* atomsCache = nullptr;
      59           0 :   if (cx) {
      60           0 :     atomsCache = GetAtomCache<SpeechRecognitionEventInitAtoms>(cx);
      61           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      62           0 :       return false;
      63             :     }
      64             :   }
      65             : 
      66             :   // Per spec, we init the parent's members first
      67           0 :   if (!EventInit::Init(cx, val)) {
      68           0 :     return false;
      69             :   }
      70             : 
      71           0 :   bool isNull = val.isNullOrUndefined();
      72             :   // We only need these if !isNull, in which case we have |cx|.
      73           0 :   Maybe<JS::Rooted<JSObject *> > object;
      74           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      75           0 :   if (!isNull) {
      76           0 :     MOZ_ASSERT(cx);
      77           0 :     object.emplace(cx, &val.toObject());
      78           0 :     temp.emplace(cx);
      79             :   }
      80           0 :   if (!isNull) {
      81           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->emma_id, temp.ptr())) {
      82           0 :       return false;
      83             :     }
      84             :   }
      85           0 :   if (!isNull && !temp->isUndefined()) {
      86           0 :     if (temp.ref().isObject()) {
      87             :       static_assert(IsRefcounted<nsIDocument>::value, "We can only store refcounted classes.");{
      88           0 :         nsresult rv = UnwrapObject<prototypes::id::Document, nsIDocument>(temp.ptr(), mEmma);
      89           0 :         if (NS_FAILED(rv)) {
      90           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'emma' member of SpeechRecognitionEventInit", "Document");
      91           0 :           return false;
      92             :         }
      93             :       }
      94           0 :     } else if (temp.ref().isNullOrUndefined()) {
      95           0 :       mEmma = nullptr;
      96             :     } else {
      97           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'emma' member of SpeechRecognitionEventInit");
      98           0 :       return false;
      99             :     }
     100             :   } else {
     101           0 :     mEmma = nullptr;
     102             :   }
     103           0 :   mIsAnyMemberPresent = true;
     104             : 
     105           0 :   if (!isNull) {
     106           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->interpretation_id, temp.ptr())) {
     107           0 :       return false;
     108             :     }
     109             :   }
     110           0 :   if (!isNull && !temp->isUndefined()) {
     111             : #ifdef __clang__
     112             : #pragma clang diagnostic push
     113             : #pragma clang diagnostic ignored "-Wunreachable-code"
     114             : #pragma clang diagnostic ignored "-Wunreachable-code-return"
     115             : #endif // __clang__
     116           0 :     if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
     117           0 :       ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'interpretation' member of SpeechRecognitionEventInit");
     118           0 :       return false;
     119             :     }
     120             : #ifdef __clang__
     121             : #pragma clang diagnostic pop
     122             : #endif // __clang__
     123           0 :     mInterpretation = temp.ref();
     124             :   } else {
     125           0 :     mInterpretation = JS::NullValue();
     126             :   }
     127           0 :   mIsAnyMemberPresent = true;
     128             : 
     129           0 :   if (!isNull) {
     130           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->resultIndex_id, temp.ptr())) {
     131           0 :       return false;
     132             :     }
     133             :   }
     134           0 :   if (!isNull && !temp->isUndefined()) {
     135           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mResultIndex)) {
     136           0 :       return false;
     137             :     }
     138             :   } else {
     139           0 :     mResultIndex = 0U;
     140             :   }
     141           0 :   mIsAnyMemberPresent = true;
     142             : 
     143           0 :   if (!isNull) {
     144           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->results_id, temp.ptr())) {
     145           0 :       return false;
     146             :     }
     147             :   }
     148           0 :   if (!isNull && !temp->isUndefined()) {
     149           0 :     if (temp.ref().isObject()) {
     150             :       static_assert(IsRefcounted<mozilla::dom::SpeechRecognitionResultList>::value, "We can only store refcounted classes.");{
     151           0 :         nsresult rv = UnwrapObject<prototypes::id::SpeechRecognitionResultList, mozilla::dom::SpeechRecognitionResultList>(temp.ptr(), mResults);
     152           0 :         if (NS_FAILED(rv)) {
     153           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'results' member of SpeechRecognitionEventInit", "SpeechRecognitionResultList");
     154           0 :           return false;
     155             :         }
     156             :       }
     157           0 :     } else if (temp.ref().isNullOrUndefined()) {
     158           0 :       mResults = nullptr;
     159             :     } else {
     160           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'results' member of SpeechRecognitionEventInit");
     161           0 :       return false;
     162             :     }
     163             :   } else {
     164           0 :     mResults = nullptr;
     165             :   }
     166           0 :   mIsAnyMemberPresent = true;
     167           0 :   return true;
     168             : }
     169             : 
     170             : bool
     171           0 : SpeechRecognitionEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     172             : {
     173           0 :   SpeechRecognitionEventInitAtoms* atomsCache = GetAtomCache<SpeechRecognitionEventInitAtoms>(cx);
     174           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     175           0 :     return false;
     176             :   }
     177             : 
     178             :   // Per spec, we define the parent's members first
     179           0 :   if (!EventInit::ToObjectInternal(cx, rval)) {
     180           0 :     return false;
     181             :   }
     182           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     183             : 
     184             :   do {
     185             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     186           0 :     JS::Rooted<JS::Value> temp(cx);
     187           0 :     RefPtr<nsIDocument> const & currentValue = mEmma;
     188           0 :     if (!currentValue) {
     189           0 :       temp.setNull();
     190           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->emma_id, temp, JSPROP_ENUMERATE)) {
     191           0 :         return false;
     192             :       }
     193           0 :       break;
     194             :     }
     195           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     196           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     197           0 :       return false;
     198             :     }
     199           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->emma_id, temp, JSPROP_ENUMERATE)) {
     200           0 :       return false;
     201             :     }
     202           0 :     break;
     203             :   } while(0);
     204             : 
     205             :   do {
     206             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     207           0 :     JS::Rooted<JS::Value> temp(cx);
     208           0 :     JS::Value const & currentValue = mInterpretation;
     209           0 :     JS::ExposeValueToActiveJS(currentValue);
     210           0 :     temp.set(currentValue);
     211           0 :     if (!MaybeWrapValue(cx, &temp)) {
     212           0 :       return false;
     213             :     }
     214           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->interpretation_id, temp, JSPROP_ENUMERATE)) {
     215           0 :       return false;
     216             :     }
     217           0 :     break;
     218             :   } while(0);
     219             : 
     220             :   do {
     221             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     222           0 :     JS::Rooted<JS::Value> temp(cx);
     223           0 :     uint32_t const & currentValue = mResultIndex;
     224           0 :     temp.setNumber(currentValue);
     225           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->resultIndex_id, temp, JSPROP_ENUMERATE)) {
     226           0 :       return false;
     227             :     }
     228           0 :     break;
     229             :   } while(0);
     230             : 
     231             :   do {
     232             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     233           0 :     JS::Rooted<JS::Value> temp(cx);
     234           0 :     RefPtr<mozilla::dom::SpeechRecognitionResultList> const & currentValue = mResults;
     235           0 :     if (!currentValue) {
     236           0 :       temp.setNull();
     237           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->results_id, temp, JSPROP_ENUMERATE)) {
     238           0 :         return false;
     239             :       }
     240           0 :       break;
     241             :     }
     242           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     243           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     244           0 :       return false;
     245             :     }
     246           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->results_id, temp, JSPROP_ENUMERATE)) {
     247           0 :       return false;
     248             :     }
     249           0 :     break;
     250             :   } while(0);
     251             : 
     252           0 :   return true;
     253             : }
     254             : 
     255             : void
     256           0 : SpeechRecognitionEventInit::TraceDictionary(JSTracer* trc)
     257             : {
     258           0 :   EventInit::TraceDictionary(trc);
     259           0 :   JS::UnsafeTraceRoot(trc, &mInterpretation, "SpeechRecognitionEventInit.mInterpretation");
     260           0 : }
     261             : 
     262             : namespace binding_detail {
     263             : } // namespace binding_detail
     264             : 
     265             : 
     266             : namespace SpeechRecognitionEventBinding {
     267             : 
     268             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventBinding::NativeType>::value,
     269             :               "Can't inherit from an interface with a different ownership model.");
     270             : 
     271             : static bool
     272           0 : get_resultIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognitionEvent* self, JSJitGetterCallArgs args)
     273             : {
     274           0 :   uint32_t result(self->ResultIndex());
     275           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     276           0 :   args.rval().setNumber(result);
     277           0 :   return true;
     278             : }
     279             : 
     280             : static const JSJitInfo resultIndex_getterinfo = {
     281             :   { (JSJitGetterOp)get_resultIndex },
     282             :   { prototypes::id::SpeechRecognitionEvent },
     283             :   { PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth },
     284             :   JSJitInfo::Getter,
     285             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     286             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     287             :   true,  /* isInfallible. False in setters. */
     288             :   false,  /* isMovable.  Not relevant for setters. */
     289             :   false, /* isEliminatable.  Not relevant for setters. */
     290             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     291             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     292             :   false,  /* isTypedMethod.  Only relevant for methods. */
     293             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     294             : };
     295             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     296             : static_assert(0 < 1, "There is no slot for us");
     297             : 
     298             : static bool
     299           0 : get_results(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognitionEvent* self, JSJitGetterCallArgs args)
     300             : {
     301           0 :   auto result(StrongOrRawPtr<mozilla::dom::SpeechRecognitionResultList>(self->GetResults()));
     302           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     303           0 :   if (!result) {
     304           0 :     args.rval().setNull();
     305           0 :     return true;
     306             :   }
     307           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     308           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     309           0 :     return false;
     310             :   }
     311           0 :   return true;
     312             : }
     313             : 
     314             : static const JSJitInfo results_getterinfo = {
     315             :   { (JSJitGetterOp)get_results },
     316             :   { prototypes::id::SpeechRecognitionEvent },
     317             :   { PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth },
     318             :   JSJitInfo::Getter,
     319             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     320             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     321             :   false,  /* isInfallible. False in setters. */
     322             :   false,  /* isMovable.  Not relevant for setters. */
     323             :   false, /* isEliminatable.  Not relevant for setters. */
     324             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     325             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     326             :   false,  /* isTypedMethod.  Only relevant for methods. */
     327             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     328             : };
     329             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     330             : static_assert(0 < 1, "There is no slot for us");
     331             : 
     332             : static bool
     333           0 : get_interpretation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognitionEvent* self, JSJitGetterCallArgs args)
     334             : {
     335           0 :   JS::Rooted<JS::Value> result(cx);
     336           0 :   self->GetInterpretation(cx, &result);
     337           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     338           0 :   JS::ExposeValueToActiveJS(result);
     339           0 :   args.rval().set(result);
     340           0 :   if (!MaybeWrapValue(cx, args.rval())) {
     341           0 :     return false;
     342             :   }
     343           0 :   return true;
     344             : }
     345             : 
     346             : static const JSJitInfo interpretation_getterinfo = {
     347             :   { (JSJitGetterOp)get_interpretation },
     348             :   { prototypes::id::SpeechRecognitionEvent },
     349             :   { PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth },
     350             :   JSJitInfo::Getter,
     351             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     352             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     353             :   false,  /* isInfallible. False in setters. */
     354             :   false,  /* isMovable.  Not relevant for setters. */
     355             :   false, /* isEliminatable.  Not relevant for setters. */
     356             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     357             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     358             :   false,  /* isTypedMethod.  Only relevant for methods. */
     359             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     360             : };
     361             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     362             : static_assert(0 < 1, "There is no slot for us");
     363             : 
     364             : static bool
     365           0 : get_emma(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognitionEvent* self, JSJitGetterCallArgs args)
     366             : {
     367           0 :   auto result(StrongOrRawPtr<nsIDocument>(self->GetEmma()));
     368           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     369           0 :   if (!result) {
     370           0 :     args.rval().setNull();
     371           0 :     return true;
     372             :   }
     373           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     374           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     375           0 :     return false;
     376             :   }
     377           0 :   return true;
     378             : }
     379             : 
     380             : static const JSJitInfo emma_getterinfo = {
     381             :   { (JSJitGetterOp)get_emma },
     382             :   { prototypes::id::SpeechRecognitionEvent },
     383             :   { PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth },
     384             :   JSJitInfo::Getter,
     385             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     386             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     387             :   false,  /* isInfallible. False in setters. */
     388             :   false,  /* isMovable.  Not relevant for setters. */
     389             :   false, /* isEliminatable.  Not relevant for setters. */
     390             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     391             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     392             :   false,  /* isTypedMethod.  Only relevant for methods. */
     393             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     394             : };
     395             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     396             : static_assert(0 < 1, "There is no slot for us");
     397             : 
     398             : static bool
     399           0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognitionEvent* self, JSJitGetterCallArgs args)
     400             : {
     401           0 :   bool result(self->IsTrusted());
     402           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     403           0 :   args.rval().setBoolean(result);
     404           0 :   return true;
     405             : }
     406             : 
     407             : static const JSJitInfo isTrusted_getterinfo = {
     408             :   { (JSJitGetterOp)get_isTrusted },
     409             :   { prototypes::id::SpeechRecognitionEvent },
     410             :   { PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth },
     411             :   JSJitInfo::Getter,
     412             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     413             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     414             :   true,  /* isInfallible. False in setters. */
     415             :   true,  /* isMovable.  Not relevant for setters. */
     416             :   true, /* isEliminatable.  Not relevant for setters. */
     417             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     418             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     419             :   false,  /* isTypedMethod.  Only relevant for methods. */
     420             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     421             : };
     422             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     423             : static_assert(0 < 1, "There is no slot for us");
     424             : 
     425             : static bool
     426           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     427             : {
     428           0 :   mozilla::dom::SpeechRecognitionEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognitionEvent>(obj);
     429             :   // We don't want to preserve if we don't have a wrapper, and we
     430             :   // obviously can't preserve if we're not initialized.
     431           0 :   if (self && self->GetWrapperPreserveColor()) {
     432           0 :     PreserveWrapper(self);
     433             :   }
     434           0 :   return true;
     435             : }
     436             : 
     437             : static void
     438           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     439             : {
     440           0 :   mozilla::dom::SpeechRecognitionEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognitionEvent>(obj);
     441           0 :   if (self) {
     442           0 :     ClearWrapper(self, self, obj);
     443           0 :     AddForDeferredFinalization<mozilla::dom::SpeechRecognitionEvent>(self);
     444             :   }
     445           0 : }
     446             : 
     447             : static void
     448           0 : _objectMoved(JSObject* obj, const JSObject* old)
     449             : {
     450           0 :   mozilla::dom::SpeechRecognitionEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognitionEvent>(obj);
     451           0 :   if (self) {
     452           0 :     UpdateWrapper(self, self, obj, old);
     453             :   }
     454           0 : }
     455             : 
     456             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     457             : #if defined(__clang__)
     458             : #pragma clang diagnostic push
     459             : #pragma clang diagnostic ignored "-Wmissing-braces"
     460             : #endif
     461             : static const JSPropertySpec sAttributes_specs[] = {
     462             :   { "resultIndex", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &resultIndex_getterinfo, nullptr, nullptr },
     463             :   { "results", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &results_getterinfo, nullptr, nullptr },
     464             :   { "interpretation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &interpretation_getterinfo, nullptr, nullptr },
     465             :   { "emma", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &emma_getterinfo, nullptr, nullptr },
     466             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     467             : };
     468             : #if defined(__clang__)
     469             : #pragma clang diagnostic pop
     470             : #endif
     471             : 
     472             : 
     473             : // Can't be const because the pref-enabled boolean needs to be writable
     474             : static Prefable<const JSPropertySpec> sAttributes[] = {
     475             :   { nullptr, &sAttributes_specs[0] },
     476             :   { nullptr, nullptr }
     477             : };
     478             : 
     479             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     480             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     481             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     482             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     483             : 
     484             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     485             : #if defined(__clang__)
     486             : #pragma clang diagnostic push
     487             : #pragma clang diagnostic ignored "-Wmissing-braces"
     488             : #endif
     489             : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
     490             :   { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
     491             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     492             : };
     493             : #if defined(__clang__)
     494             : #pragma clang diagnostic pop
     495             : #endif
     496             : 
     497             : 
     498             : // Can't be const because the pref-enabled boolean needs to be writable
     499             : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
     500             :   { nullptr, &sUnforgeableAttributes_specs[0] },
     501             :   { nullptr, nullptr }
     502             : };
     503             : 
     504             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     505             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     506             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     507             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     508             : 
     509             : 
     510             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
     511             : static PropertyInfo sNativeProperties_propertyInfos[5];
     512             : 
     513             : static const NativePropertiesN<2> sNativeProperties = {
     514             :   false, 0,
     515             :   false, 0,
     516             :   false, 0,
     517             :   true,  0 /* sAttributes */,
     518             :   false, 0,
     519             :   true,  1 /* sUnforgeableAttributes */,
     520             :   false, 0,
     521             :   -1,
     522             :   5,
     523             :   sNativeProperties_sortedPropertyIndices,
     524             :   {
     525             :     { sAttributes, &sNativeProperties_propertyInfos[0] },
     526             :     { sUnforgeableAttributes, &sNativeProperties_propertyInfos[4] }
     527             :   }
     528             : };
     529             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     530             :     "We have a property info count that is oversized");
     531             : 
     532             : static bool
     533           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     534             : {
     535           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     536           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     537           0 :   if (!args.isConstructing()) {
     538             :     // XXXbz wish I could get the name from the callee instead of
     539             :     // Adding more relocations
     540           0 :     return ThrowConstructorWithoutNew(cx, "SpeechRecognitionEvent");
     541             :   }
     542             : 
     543           0 :   GlobalObject global(cx, obj);
     544           0 :   if (global.Failed()) {
     545           0 :     return false;
     546             :   }
     547             : 
     548           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     549           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     550           0 :     return false;
     551             :   }
     552             : 
     553           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     554           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SpeechRecognitionEvent");
     555             :   }
     556           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     557           0 :   binding_detail::FakeString arg0;
     558           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     559           0 :     return false;
     560             :   }
     561           0 :   RootedDictionary<binding_detail::FastSpeechRecognitionEventInit> arg1(cx);
     562           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of SpeechRecognitionEvent.constructor", false)) {
     563           0 :     return false;
     564             :   }
     565           0 :   Maybe<JSAutoCompartment> ac;
     566           0 :   if (objIsXray) {
     567           0 :     obj = js::CheckedUnwrap(obj);
     568           0 :     if (!obj) {
     569           0 :       return false;
     570             :     }
     571           0 :     ac.emplace(cx, obj);
     572           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     573           0 :       return false;
     574             :     }
     575           0 :     if (!JS_WrapValue(cx, JS::MutableHandle<JS::Value>::fromMarkedLocation(&arg1.mInterpretation))) {
     576           0 :       return false;
     577             :     }
     578             :   }
     579           0 :   binding_detail::FastErrorResult rv;
     580           0 :   auto result(StrongOrRawPtr<mozilla::dom::SpeechRecognitionEvent>(mozilla::dom::SpeechRecognitionEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
     581           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     582           0 :     return false;
     583             :   }
     584           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     585             :   static_assert(!IsPointer<decltype(result)>::value,
     586             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     587           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     588           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     589           0 :     return false;
     590             :   }
     591           0 :   return true;
     592             : }
     593             : 
     594             : static const js::ClassOps sInterfaceObjectClassOps = {
     595             :     nullptr,               /* addProperty */
     596             :     nullptr,               /* delProperty */
     597             :     nullptr,               /* getProperty */
     598             :     nullptr,               /* setProperty */
     599             :     nullptr,               /* enumerate */
     600             :     nullptr,               /* newEnumerate */
     601             :     nullptr,               /* resolve */
     602             :     nullptr,               /* mayResolve */
     603             :     nullptr,               /* finalize */
     604             :     _constructor, /* call */
     605             :     nullptr,               /* hasInstance */
     606             :     _constructor, /* construct */
     607             :     nullptr,               /* trace */
     608             : };
     609             : 
     610             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     611             :   {
     612             :     "Function",
     613             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     614             :     &sInterfaceObjectClassOps,
     615             :     JS_NULL_CLASS_SPEC,
     616             :     JS_NULL_CLASS_EXT,
     617             :     &sInterfaceObjectClassObjectOps
     618             :   },
     619             :   eInterface,
     620             :   true,
     621             :   prototypes::id::SpeechRecognitionEvent,
     622             :   PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth,
     623             :   sNativePropertyHooks,
     624             :   "function SpeechRecognitionEvent() {\n    [native code]\n}",
     625             :   EventBinding::GetConstructorObject
     626             : };
     627             : 
     628             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     629             :   {
     630             :     "SpeechRecognitionEventPrototype",
     631             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
     632             :     JS_NULL_CLASS_OPS,
     633             :     JS_NULL_CLASS_SPEC,
     634             :     JS_NULL_CLASS_EXT,
     635             :     JS_NULL_OBJECT_OPS
     636             :   },
     637             :   eInterfacePrototype,
     638             :   false,
     639             :   prototypes::id::SpeechRecognitionEvent,
     640             :   PrototypeTraits<prototypes::id::SpeechRecognitionEvent>::Depth,
     641             :   sNativePropertyHooks,
     642             :   "[object SpeechRecognitionEventPrototype]",
     643             :   EventBinding::GetProtoObject
     644             : };
     645             : 
     646             : bool
     647           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     648             : {
     649             :   static bool sPrefValue;
     650             :   static bool sPrefCacheSetUp = false;
     651           0 :   if (!sPrefCacheSetUp) {
     652           0 :     sPrefCacheSetUp = true;
     653           0 :     Preferences::AddBoolVarCache(&sPrefValue, "media.webspeech.recognition.enable");
     654             :   }
     655             : 
     656           0 :   return sPrefValue &&
     657           0 :          SpeechRecognition::IsAuthorized(aCx, aObj);
     658             : }
     659             : 
     660             : JSObject*
     661           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     662             : {
     663           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     664             : }
     665             : 
     666             : static const js::ClassOps sClassOps = {
     667             :   _addProperty, /* addProperty */
     668             :   nullptr,               /* delProperty */
     669             :   nullptr,               /* getProperty */
     670             :   nullptr,               /* setProperty */
     671             :   nullptr,               /* enumerate */
     672             :   nullptr, /* newEnumerate */
     673             :   nullptr, /* resolve */
     674             :   nullptr, /* mayResolve */
     675             :   _finalize, /* finalize */
     676             :   nullptr, /* call */
     677             :   nullptr,               /* hasInstance */
     678             :   nullptr,               /* construct */
     679             :   nullptr, /* trace */
     680             : };
     681             : 
     682             : static const js::ClassExtension sClassExtension = {
     683             :   nullptr, /* weakmapKeyDelegateOp */
     684             :   _objectMoved /* objectMovedOp */
     685             : };
     686             : 
     687             : static const DOMJSClass sClass = {
     688             :   { "SpeechRecognitionEvent",
     689             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
     690             :     &sClassOps,
     691             :     JS_NULL_CLASS_SPEC,
     692             :     &sClassExtension,
     693             :     JS_NULL_OBJECT_OPS
     694             :   },
     695             :   { prototypes::id::Event, prototypes::id::SpeechRecognitionEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     696             :   IsBaseOf<nsISupports, mozilla::dom::SpeechRecognitionEvent >::value,
     697             :   sNativePropertyHooks,
     698             :   FindAssociatedGlobalForNative<mozilla::dom::SpeechRecognitionEvent>::Get,
     699             :   GetProtoObjectHandle,
     700             :   GetCCParticipant<mozilla::dom::SpeechRecognitionEvent>::Get()
     701             : };
     702             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     703             :               "Must have the right minimal number of reserved slots.");
     704             : static_assert(1 >= 1,
     705             :               "Must have enough reserved slots.");
     706             : 
     707             : const JSClass*
     708           0 : GetJSClass()
     709             : {
     710           0 :   return sClass.ToJSClass();
     711             : }
     712             : 
     713             : bool
     714           0 : Wrap(JSContext* aCx, mozilla::dom::SpeechRecognitionEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     715             : {
     716             :   MOZ_ASSERT(static_cast<mozilla::dom::SpeechRecognitionEvent*>(aObject) ==
     717             :              reinterpret_cast<mozilla::dom::SpeechRecognitionEvent*>(aObject),
     718             :              "Multiple inheritance for mozilla::dom::SpeechRecognitionEvent is broken.");
     719             :   MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
     720             :              reinterpret_cast<mozilla::dom::Event*>(aObject),
     721             :              "Multiple inheritance for mozilla::dom::Event is broken.");
     722           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     723           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     724           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     725             :              "You should probably not be using Wrap() directly; use "
     726             :              "GetOrCreateDOMReflector instead");
     727             : 
     728           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     729             :              "nsISupports must be on our primary inheritance chain");
     730             : 
     731           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     732           0 :   if (!global) {
     733           0 :     return false;
     734             :   }
     735           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     736           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     737             : 
     738             :   // That might have ended up wrapping us already, due to the wonders
     739             :   // of XBL.  Check for that, and bail out as needed.
     740           0 :   aReflector.set(aCache->GetWrapper());
     741           0 :   if (aReflector) {
     742             : #ifdef DEBUG
     743           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     744             : #endif // DEBUG
     745           0 :     return true;
     746             :   }
     747             : 
     748           0 :   JSAutoCompartment ac(aCx, global);
     749           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     750           0 :   if (!canonicalProto) {
     751           0 :     return false;
     752             :   }
     753           0 :   JS::Rooted<JSObject*> proto(aCx);
     754           0 :   if (aGivenProto) {
     755           0 :     proto = aGivenProto;
     756             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     757             :     // coming in, we changed compartments to that of "parent" so may need
     758             :     // to wrap the proto here.
     759           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     760           0 :       if (!JS_WrapObject(aCx, &proto)) {
     761           0 :         return false;
     762             :       }
     763             :     }
     764             :   } else {
     765           0 :     proto = canonicalProto;
     766             :   }
     767             : 
     768           0 :   BindingJSObjectCreator<mozilla::dom::SpeechRecognitionEvent> creator(aCx);
     769           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     770           0 :   if (!aReflector) {
     771           0 :     return false;
     772             :   }
     773             : 
     774           0 :   aCache->SetWrapper(aReflector);
     775             : 
     776             :   // Important: do unforgeable property setup after we have handed
     777             :   // over ownership of the C++ object to obj as needed, so that if
     778             :   // we fail and it ends up GCed it won't have problems in the
     779             :   // finalizer trying to drop its ownership of the C++ object.
     780             :   JS::Rooted<JSObject*> unforgeableHolder(aCx,
     781           0 :     &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
     782           0 :   if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
     783           0 :     aCache->ReleaseWrapper(aObject);
     784           0 :     aCache->ClearWrapper();
     785           0 :     return false;
     786             :   }
     787           0 :   creator.InitializationSucceeded();
     788             : 
     789           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     790             :              aCache->GetWrapperPreserveColor() == aReflector);
     791             :   // If proto != canonicalProto, we have to preserve our wrapper;
     792             :   // otherwise we won't be able to properly recreate it later, since
     793             :   // we won't know what proto to use.  Note that we don't check
     794             :   // aGivenProto here, since it's entirely possible (and even
     795             :   // somewhat common) to have a non-null aGivenProto which is the
     796             :   // same as canonicalProto.
     797           0 :   if (proto != canonicalProto) {
     798           0 :     PreserveWrapper(aObject);
     799             :   }
     800             : 
     801           0 :   return true;
     802             : }
     803             : 
     804             : const NativePropertyHooks sNativePropertyHooks[] = { {
     805             :   nullptr,
     806             :   nullptr,
     807             :   nullptr,
     808             :   { sNativeProperties.Upcast(), nullptr },
     809             :   prototypes::id::SpeechRecognitionEvent,
     810             :   constructors::id::SpeechRecognitionEvent,
     811             :   EventBinding::sNativePropertyHooks,
     812             :   &DefaultXrayExpandoObjectClass
     813             : } };
     814             : 
     815             : void
     816           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     817             : {
     818           0 :   JS::Handle<JSObject*> parentProto(EventBinding::GetProtoObjectHandle(aCx));
     819           0 :   if (!parentProto) {
     820           0 :     return;
     821             :   }
     822             : 
     823           0 :   JS::Handle<JSObject*> constructorProto(EventBinding::GetConstructorObjectHandle(aCx));
     824           0 :   if (!constructorProto) {
     825           0 :     return;
     826             :   }
     827             : 
     828             :   static bool sIdsInited = false;
     829           0 :   if (!sIdsInited && NS_IsMainThread()) {
     830           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     831           0 :       return;
     832             :     }
     833           0 :     sIdsInited = true;
     834             :   }
     835             : 
     836           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SpeechRecognitionEvent);
     837           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SpeechRecognitionEvent);
     838           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     839             :                               &sPrototypeClass.mBase, protoCache,
     840             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     841             :                               interfaceCache,
     842             :                               sNativeProperties.Upcast(),
     843             :                               nullptr,
     844             :                               "SpeechRecognitionEvent", aDefineOnGlobal,
     845             :                               nullptr,
     846           0 :                               false);
     847             : 
     848           0 :   JS::Rooted<JSObject*> unforgeableHolder(aCx);
     849             :   {
     850           0 :     JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
     851           0 :     unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
     852           0 :     if (!unforgeableHolder) {
     853           0 :       *protoCache = nullptr;
     854           0 :       if (interfaceCache) {
     855           0 :         *interfaceCache = nullptr;
     856             :       }
     857           0 :       return;
     858             :     }
     859             :   }
     860             : 
     861           0 :   if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
     862           0 :     *protoCache = nullptr;
     863           0 :     if (interfaceCache) {
     864           0 :       *interfaceCache = nullptr;
     865             :     }
     866           0 :     return;
     867             :   }
     868             : 
     869           0 :   if (*protoCache) {
     870           0 :     js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
     871           0 :                         JS::ObjectValue(*unforgeableHolder));
     872             :   }
     873             : }
     874             : 
     875             : JS::Handle<JSObject*>
     876           0 : GetProtoObjectHandle(JSContext* aCx)
     877             : {
     878             :   /* Get the interface prototype object for this class.  This will create the
     879             :      object as needed. */
     880           0 :   bool aDefineOnGlobal = true;
     881             : 
     882             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     883           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     884           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     885           0 :     return nullptr;
     886             :   }
     887             : 
     888             :   /* Check to see whether the interface objects are already installed */
     889           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     890           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SpeechRecognitionEvent)) {
     891           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     892           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     893             :   }
     894             : 
     895             :   /*
     896             :    * The object might _still_ be null, but that's OK.
     897             :    *
     898             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     899             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     900             :    * changed after they have been set.
     901             :    *
     902             :    * Calling address() avoids the read read barrier that does gray
     903             :    * unmarking, but it's not possible for the object to be gray here.
     904             :    */
     905             : 
     906           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SpeechRecognitionEvent);
     907           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     908           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     909             : }
     910             : 
     911             : JS::Handle<JSObject*>
     912           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     913             : {
     914             :   /* Get the interface object for this class.  This will create the object as
     915             :      needed. */
     916             : 
     917             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     918           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     919           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     920           0 :     return nullptr;
     921             :   }
     922             : 
     923             :   /* Check to see whether the interface objects are already installed */
     924           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     925           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SpeechRecognitionEvent)) {
     926           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     927           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     928             :   }
     929             : 
     930             :   /*
     931             :    * The object might _still_ be null, but that's OK.
     932             :    *
     933             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     934             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     935             :    * changed after they have been set.
     936             :    *
     937             :    * Calling address() avoids the read read barrier that does gray
     938             :    * unmarking, but it's not possible for the object to be gray here.
     939             :    */
     940             : 
     941           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SpeechRecognitionEvent);
     942           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     943           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     944             : }
     945             : 
     946             : JSObject*
     947           0 : GetConstructorObject(JSContext* aCx)
     948             : {
     949           0 :   return GetConstructorObjectHandle(aCx);
     950             : }
     951             : 
     952             : } // namespace SpeechRecognitionEventBinding
     953             : 
     954             : 
     955             : 
     956             : } // namespace dom
     957             : } // namespace mozilla

Generated by: LCOV version 1.13