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

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

Generated by: LCOV version 1.13