LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - NotifyPaintEventBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 74 157 47.1 %
Date: 2017-07-14 16:53:18 Functions: 6 17 35.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13