LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - DataTransferItemBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 1 192 0.5 %
Date: 2017-07-14 16:53:18 Functions: 2 18 11.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13