LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - DominatorTreeBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 155 15.5 %
Date: 2017-07-14 16:53:18 Functions: 4 15 26.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM DominatorTree.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DominatorTreeBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/devtools/DominatorTree.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/Nullable.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/XrayExpandoClass.h"
      13             : #include "nsContentUtils.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace DominatorTreeBinding {
      19             : 
      20             : static bool
      21           0 : get_root(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::devtools::DominatorTree* self, JSJitGetterCallArgs args)
      22             : {
      23           0 :   uint64_t result(self->Root());
      24           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      25           0 :   args.rval().set(JS_NumberValue(double(result)));
      26           0 :   return true;
      27             : }
      28             : 
      29             : static const JSJitInfo root_getterinfo = {
      30             :   { (JSJitGetterOp)get_root },
      31             :   { prototypes::id::DominatorTree },
      32             :   { PrototypeTraits<prototypes::id::DominatorTree>::Depth },
      33             :   JSJitInfo::Getter,
      34             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      35             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      36             :   true,  /* isInfallible. False in setters. */
      37             :   false,  /* isMovable.  Not relevant for setters. */
      38             :   false, /* isEliminatable.  Not relevant for setters. */
      39             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      40             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      41             :   false,  /* isTypedMethod.  Only relevant for methods. */
      42             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      43             : };
      44             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      45             : static_assert(0 < 1, "There is no slot for us");
      46             : 
      47             : static bool
      48           0 : getRetainedSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::devtools::DominatorTree* self, const JSJitMethodCallArgs& args)
      49             : {
      50           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      51           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DominatorTree.getRetainedSize");
      52             :   }
      53             :   uint64_t arg0;
      54           0 :   if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
      55           0 :     return false;
      56             :   }
      57           0 :   binding_detail::FastErrorResult rv;
      58           0 :   Nullable<uint64_t> result(self->GetRetainedSize(arg0, rv));
      59           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      60           0 :     return false;
      61             :   }
      62           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      63           0 :   if (result.IsNull()) {
      64           0 :     args.rval().setNull();
      65           0 :     return true;
      66             :   }
      67           0 :   args.rval().set(JS_NumberValue(double(result.Value())));
      68           0 :   return true;
      69             : }
      70             : 
      71             : static const JSJitInfo getRetainedSize_methodinfo = {
      72             :   { (JSJitGetterOp)getRetainedSize },
      73             :   { prototypes::id::DominatorTree },
      74             :   { PrototypeTraits<prototypes::id::DominatorTree>::Depth },
      75             :   JSJitInfo::Method,
      76             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      77             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      78             :   false,  /* isInfallible. False in setters. */
      79             :   false,  /* isMovable.  Not relevant for setters. */
      80             :   false, /* isEliminatable.  Not relevant for setters. */
      81             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      82             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      83             :   false,  /* isTypedMethod.  Only relevant for methods. */
      84             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      85             : };
      86             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      87             : static_assert(0 < 1, "There is no slot for us");
      88             : 
      89             : static bool
      90           0 : getImmediatelyDominated(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::devtools::DominatorTree* self, const JSJitMethodCallArgs& args)
      91             : {
      92           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      93           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DominatorTree.getImmediatelyDominated");
      94             :   }
      95             :   uint64_t arg0;
      96           0 :   if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
      97           0 :     return false;
      98             :   }
      99           0 :   binding_detail::FastErrorResult rv;
     100           0 :   Nullable<nsTArray<uint64_t>> result;
     101           0 :   self->GetImmediatelyDominated(arg0, result, rv);
     102           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     103           0 :     return false;
     104             :   }
     105           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     106             : 
     107           0 :   if (result.IsNull()) {
     108           0 :     args.rval().setNull();
     109           0 :     return true;
     110             :   }
     111             : 
     112           0 :   uint32_t length = result.Value().Length();
     113           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     114           0 :   if (!returnArray) {
     115           0 :     return false;
     116             :   }
     117             :   // Scope for 'tmp'
     118             :   {
     119           0 :     JS::Rooted<JS::Value> tmp(cx);
     120           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     121             :       // Control block to let us common up the JS_DefineElement calls when there
     122             :       // are different ways to succeed at wrapping the object.
     123             :       do {
     124           0 :         tmp.set(JS_NumberValue(double(result.Value()[sequenceIdx0])));
     125           0 :         break;
     126             :       } while (0);
     127           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     128             :                             JSPROP_ENUMERATE)) {
     129           0 :         return false;
     130             :       }
     131             :     }
     132             :   }
     133           0 :   args.rval().setObject(*returnArray);
     134           0 :   return true;
     135             : }
     136             : 
     137             : static const JSJitInfo getImmediatelyDominated_methodinfo = {
     138             :   { (JSJitGetterOp)getImmediatelyDominated },
     139             :   { prototypes::id::DominatorTree },
     140             :   { PrototypeTraits<prototypes::id::DominatorTree>::Depth },
     141             :   JSJitInfo::Method,
     142             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     143             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     144             :   false,  /* isInfallible. False in setters. */
     145             :   false,  /* isMovable.  Not relevant for setters. */
     146             :   false, /* isEliminatable.  Not relevant for setters. */
     147             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     148             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     149             :   false,  /* isTypedMethod.  Only relevant for methods. */
     150             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     151             : };
     152             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     153             : static_assert(0 < 1, "There is no slot for us");
     154             : 
     155             : static bool
     156           0 : getImmediateDominator(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::devtools::DominatorTree* self, const JSJitMethodCallArgs& args)
     157             : {
     158           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     159           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DominatorTree.getImmediateDominator");
     160             :   }
     161             :   uint64_t arg0;
     162           0 :   if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
     163           0 :     return false;
     164             :   }
     165           0 :   Nullable<uint64_t> result(self->GetImmediateDominator(arg0));
     166           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     167           0 :   if (result.IsNull()) {
     168           0 :     args.rval().setNull();
     169           0 :     return true;
     170             :   }
     171           0 :   args.rval().set(JS_NumberValue(double(result.Value())));
     172           0 :   return true;
     173             : }
     174             : 
     175             : static const JSJitInfo getImmediateDominator_methodinfo = {
     176             :   { (JSJitGetterOp)getImmediateDominator },
     177             :   { prototypes::id::DominatorTree },
     178             :   { PrototypeTraits<prototypes::id::DominatorTree>::Depth },
     179             :   JSJitInfo::Method,
     180             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     181             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     182             :   false,  /* isInfallible. False in setters. */
     183             :   false,  /* isMovable.  Not relevant for setters. */
     184             :   false, /* isEliminatable.  Not relevant for setters. */
     185             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     186             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     187             :   false,  /* isTypedMethod.  Only relevant for methods. */
     188             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     189             : };
     190             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     191             : static_assert(0 < 1, "There is no slot for us");
     192             : 
     193             : static bool
     194           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     195             : {
     196           0 :   mozilla::devtools::DominatorTree* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::devtools::DominatorTree>(obj);
     197             :   // We don't want to preserve if we don't have a wrapper, and we
     198             :   // obviously can't preserve if we're not initialized.
     199           0 :   if (self && self->GetWrapperPreserveColor()) {
     200           0 :     PreserveWrapper(self);
     201             :   }
     202           0 :   return true;
     203             : }
     204             : 
     205             : static void
     206           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     207             : {
     208           0 :   mozilla::devtools::DominatorTree* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::devtools::DominatorTree>(obj);
     209           0 :   if (self) {
     210           0 :     ClearWrapper(self, self, obj);
     211           0 :     AddForDeferredFinalization<mozilla::devtools::DominatorTree>(self);
     212             :   }
     213           0 : }
     214             : 
     215             : static void
     216           0 : _objectMoved(JSObject* obj, const JSObject* old)
     217             : {
     218           0 :   mozilla::devtools::DominatorTree* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::devtools::DominatorTree>(obj);
     219           0 :   if (self) {
     220           0 :     UpdateWrapper(self, self, obj, old);
     221             :   }
     222           0 : }
     223             : 
     224             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     225             : #if defined(__clang__)
     226             : #pragma clang diagnostic push
     227             : #pragma clang diagnostic ignored "-Wmissing-braces"
     228             : #endif
     229             : static const JSFunctionSpec sMethods_specs[] = {
     230             :   JS_FNSPEC("getRetainedSize", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getRetainedSize_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     231             :   JS_FNSPEC("getImmediatelyDominated", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getImmediatelyDominated_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     232             :   JS_FNSPEC("getImmediateDominator", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getImmediateDominator_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     233             :   JS_FS_END
     234             : };
     235             : #if defined(__clang__)
     236             : #pragma clang diagnostic pop
     237             : #endif
     238             : 
     239             : 
     240             : // Can't be const because the pref-enabled boolean needs to be writable
     241             : static Prefable<const JSFunctionSpec> sMethods[] = {
     242             :   { nullptr, &sMethods_specs[0] },
     243             :   { nullptr, nullptr }
     244             : };
     245             : 
     246             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     247             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     248             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     249             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     250             : 
     251             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     252             : #if defined(__clang__)
     253             : #pragma clang diagnostic push
     254             : #pragma clang diagnostic ignored "-Wmissing-braces"
     255             : #endif
     256             : static const JSPropertySpec sAttributes_specs[] = {
     257             :   { "root", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &root_getterinfo, nullptr, nullptr },
     258             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     259             : };
     260             : #if defined(__clang__)
     261             : #pragma clang diagnostic pop
     262             : #endif
     263             : 
     264             : 
     265             : // Can't be const because the pref-enabled boolean needs to be writable
     266             : static Prefable<const JSPropertySpec> sAttributes[] = {
     267             :   { nullptr, &sAttributes_specs[0] },
     268             :   { nullptr, nullptr }
     269             : };
     270             : 
     271             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     272             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     273             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     274             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     275             : 
     276             : 
     277             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
     278             : static PropertyInfo sNativeProperties_propertyInfos[4];
     279             : 
     280             : static const NativePropertiesN<2> sNativeProperties = {
     281             :   false, 0,
     282             :   false, 0,
     283             :   true,  0 /* sMethods */,
     284             :   true,  1 /* sAttributes */,
     285             :   false, 0,
     286             :   false, 0,
     287             :   false, 0,
     288             :   -1,
     289             :   4,
     290             :   sNativeProperties_sortedPropertyIndices,
     291             :   {
     292             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     293             :     { sAttributes, &sNativeProperties_propertyInfos[3] }
     294             :   }
     295             : };
     296             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     297             :     "We have a property info count that is oversized");
     298             : 
     299             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     300             :   {
     301             :     "Function",
     302             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     303             :     &sBoringInterfaceObjectClassClassOps,
     304             :     JS_NULL_CLASS_SPEC,
     305             :     JS_NULL_CLASS_EXT,
     306             :     &sInterfaceObjectClassObjectOps
     307             :   },
     308             :   eInterface,
     309             :   true,
     310             :   prototypes::id::DominatorTree,
     311             :   PrototypeTraits<prototypes::id::DominatorTree>::Depth,
     312             :   sNativePropertyHooks,
     313             :   "function DominatorTree() {\n    [native code]\n}",
     314             :   JS::GetRealmFunctionPrototype
     315             : };
     316             : 
     317             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     318             :   {
     319             :     "DominatorTreePrototype",
     320             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     321             :     JS_NULL_CLASS_OPS,
     322             :     JS_NULL_CLASS_SPEC,
     323             :     JS_NULL_CLASS_EXT,
     324             :     JS_NULL_OBJECT_OPS
     325             :   },
     326             :   eInterfacePrototype,
     327             :   false,
     328             :   prototypes::id::DominatorTree,
     329             :   PrototypeTraits<prototypes::id::DominatorTree>::Depth,
     330             :   sNativePropertyHooks,
     331             :   "[object DominatorTreePrototype]",
     332             :   JS::GetRealmObjectPrototype
     333             : };
     334             : 
     335             : bool
     336           1 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     337             : {
     338           1 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     339             : }
     340             : 
     341             : JSObject*
     342           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     343             : {
     344           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     345             : }
     346             : 
     347             : static const js::ClassOps sClassOps = {
     348             :   _addProperty, /* addProperty */
     349             :   nullptr,               /* delProperty */
     350             :   nullptr,               /* getProperty */
     351             :   nullptr,               /* setProperty */
     352             :   nullptr,               /* enumerate */
     353             :   nullptr, /* newEnumerate */
     354             :   nullptr, /* resolve */
     355             :   nullptr, /* mayResolve */
     356             :   _finalize, /* finalize */
     357             :   nullptr, /* call */
     358             :   nullptr,               /* hasInstance */
     359             :   nullptr,               /* construct */
     360             :   nullptr, /* trace */
     361             : };
     362             : 
     363             : static const js::ClassExtension sClassExtension = {
     364             :   nullptr, /* weakmapKeyDelegateOp */
     365             :   _objectMoved /* objectMovedOp */
     366             : };
     367             : 
     368             : static const DOMJSClass sClass = {
     369             :   { "DominatorTree",
     370             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     371             :     &sClassOps,
     372             :     JS_NULL_CLASS_SPEC,
     373             :     &sClassExtension,
     374             :     JS_NULL_OBJECT_OPS
     375             :   },
     376             :   { prototypes::id::DominatorTree, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     377             :   IsBaseOf<nsISupports, mozilla::devtools::DominatorTree >::value,
     378             :   sNativePropertyHooks,
     379             :   FindAssociatedGlobalForNative<mozilla::devtools::DominatorTree>::Get,
     380             :   GetProtoObjectHandle,
     381             :   GetCCParticipant<mozilla::devtools::DominatorTree>::Get()
     382             : };
     383             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     384             :               "Must have the right minimal number of reserved slots.");
     385             : static_assert(1 >= 1,
     386             :               "Must have enough reserved slots.");
     387             : 
     388             : const JSClass*
     389           0 : GetJSClass()
     390             : {
     391           0 :   return sClass.ToJSClass();
     392             : }
     393             : 
     394             : bool
     395           0 : Wrap(JSContext* aCx, mozilla::devtools::DominatorTree* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     396             : {
     397             :   MOZ_ASSERT(static_cast<mozilla::devtools::DominatorTree*>(aObject) ==
     398             :              reinterpret_cast<mozilla::devtools::DominatorTree*>(aObject),
     399             :              "Multiple inheritance for mozilla::devtools::DominatorTree is broken.");
     400           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     401           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     402           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     403             :              "You should probably not be using Wrap() directly; use "
     404             :              "GetOrCreateDOMReflector instead");
     405             : 
     406           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     407             :              "nsISupports must be on our primary inheritance chain");
     408             : 
     409           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     410           0 :   if (!global) {
     411           0 :     return false;
     412             :   }
     413           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     414           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     415             : 
     416             :   // That might have ended up wrapping us already, due to the wonders
     417             :   // of XBL.  Check for that, and bail out as needed.
     418           0 :   aReflector.set(aCache->GetWrapper());
     419           0 :   if (aReflector) {
     420             : #ifdef DEBUG
     421           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     422             : #endif // DEBUG
     423           0 :     return true;
     424             :   }
     425             : 
     426           0 :   JSAutoCompartment ac(aCx, global);
     427           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     428           0 :   if (!canonicalProto) {
     429           0 :     return false;
     430             :   }
     431           0 :   JS::Rooted<JSObject*> proto(aCx);
     432           0 :   if (aGivenProto) {
     433           0 :     proto = aGivenProto;
     434             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     435             :     // coming in, we changed compartments to that of "parent" so may need
     436             :     // to wrap the proto here.
     437           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     438           0 :       if (!JS_WrapObject(aCx, &proto)) {
     439           0 :         return false;
     440             :       }
     441             :     }
     442             :   } else {
     443           0 :     proto = canonicalProto;
     444             :   }
     445             : 
     446           0 :   BindingJSObjectCreator<mozilla::devtools::DominatorTree> creator(aCx);
     447           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     448           0 :   if (!aReflector) {
     449           0 :     return false;
     450             :   }
     451             : 
     452           0 :   aCache->SetWrapper(aReflector);
     453           0 :   creator.InitializationSucceeded();
     454             : 
     455           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     456             :              aCache->GetWrapperPreserveColor() == aReflector);
     457             :   // If proto != canonicalProto, we have to preserve our wrapper;
     458             :   // otherwise we won't be able to properly recreate it later, since
     459             :   // we won't know what proto to use.  Note that we don't check
     460             :   // aGivenProto here, since it's entirely possible (and even
     461             :   // somewhat common) to have a non-null aGivenProto which is the
     462             :   // same as canonicalProto.
     463           0 :   if (proto != canonicalProto) {
     464           0 :     PreserveWrapper(aObject);
     465             :   }
     466             : 
     467           0 :   return true;
     468             : }
     469             : 
     470             : const NativePropertyHooks sNativePropertyHooks[] = { {
     471             :   nullptr,
     472             :   nullptr,
     473             :   nullptr,
     474             :   { sNativeProperties.Upcast(), nullptr },
     475             :   prototypes::id::DominatorTree,
     476             :   constructors::id::DominatorTree,
     477             :   nullptr,
     478             :   &DefaultXrayExpandoObjectClass
     479             : } };
     480             : 
     481             : void
     482           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     483             : {
     484           2 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     485           1 :   if (!parentProto) {
     486           0 :     return;
     487             :   }
     488             : 
     489           2 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     490           1 :   if (!constructorProto) {
     491           0 :     return;
     492             :   }
     493             : 
     494             :   static bool sIdsInited = false;
     495           1 :   if (!sIdsInited && NS_IsMainThread()) {
     496           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     497           0 :       return;
     498             :     }
     499           0 :     sIdsInited = true;
     500             :   }
     501             : 
     502           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DominatorTree);
     503           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DominatorTree);
     504           2 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     505             :                               &sPrototypeClass.mBase, protoCache,
     506             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     507             :                               interfaceCache,
     508             :                               sNativeProperties.Upcast(),
     509             :                               nullptr,
     510             :                               "DominatorTree", aDefineOnGlobal,
     511             :                               nullptr,
     512           1 :                               false);
     513             : }
     514             : 
     515             : JS::Handle<JSObject*>
     516           0 : GetProtoObjectHandle(JSContext* aCx)
     517             : {
     518             :   /* Get the interface prototype object for this class.  This will create the
     519             :      object as needed. */
     520           0 :   bool aDefineOnGlobal = true;
     521             : 
     522             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     523           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     524           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     525           0 :     return nullptr;
     526             :   }
     527             : 
     528             :   /* Check to see whether the interface objects are already installed */
     529           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     530           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DominatorTree)) {
     531           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     532           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     533             :   }
     534             : 
     535             :   /*
     536             :    * The object might _still_ be null, but that's OK.
     537             :    *
     538             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     539             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     540             :    * changed after they have been set.
     541             :    *
     542             :    * Calling address() avoids the read read barrier that does gray
     543             :    * unmarking, but it's not possible for the object to be gray here.
     544             :    */
     545             : 
     546           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DominatorTree);
     547           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     548           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     549             : }
     550             : 
     551             : JS::Handle<JSObject*>
     552           1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     553             : {
     554             :   /* Get the interface object for this class.  This will create the object as
     555             :      needed. */
     556             : 
     557             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     558           1 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     559           1 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     560           0 :     return nullptr;
     561             :   }
     562             : 
     563             :   /* Check to see whether the interface objects are already installed */
     564           1 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     565           1 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DominatorTree)) {
     566           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     567           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     568             :   }
     569             : 
     570             :   /*
     571             :    * The object might _still_ be null, but that's OK.
     572             :    *
     573             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     574             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     575             :    * changed after they have been set.
     576             :    *
     577             :    * Calling address() avoids the read read barrier that does gray
     578             :    * unmarking, but it's not possible for the object to be gray here.
     579             :    */
     580             : 
     581           1 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DominatorTree);
     582           1 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     583           1 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     584             : }
     585             : 
     586             : JSObject*
     587           1 : GetConstructorObject(JSContext* aCx)
     588             : {
     589           1 :   return GetConstructorObjectHandle(aCx);
     590             : }
     591             : 
     592             : } // namespace DominatorTreeBinding
     593             : 
     594             : 
     595             : 
     596             : } // namespace dom
     597             : } // namespace mozilla

Generated by: LCOV version 1.13