LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - MenuBoxObjectBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 48 149 32.2 %
Date: 2017-07-14 16:53:18 Functions: 3 16 18.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13