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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM TreeColumns.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "TreeColumnsBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/DOMJSClass.h"
       8             : #include "mozilla/dom/DOMJSProxyHandler.h"
       9             : #include "mozilla/dom/Element.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/TreeBoxObject.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : #include "nsISupports.h"
      16             : #include "nsTreeColumns.h"
      17             : #include "xpcjsid.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace TreeColumnsBinding {
      23             : 
      24             : static bool
      25           0 : get_tree(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
      26             : {
      27           0 :   auto result(StrongOrRawPtr<mozilla::dom::TreeBoxObject>(self->GetTree()));
      28           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      29           0 :   if (!result) {
      30           0 :     args.rval().setNull();
      31           0 :     return true;
      32             :   }
      33           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      34           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      35           0 :     return false;
      36             :   }
      37           0 :   return true;
      38             : }
      39             : 
      40             : static const JSJitInfo tree_getterinfo = {
      41             :   { (JSJitGetterOp)get_tree },
      42             :   { prototypes::id::TreeColumns },
      43             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
      44             :   JSJitInfo::Getter,
      45             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      46             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      47             :   false,  /* isInfallible. False in setters. */
      48             :   false,  /* isMovable.  Not relevant for setters. */
      49             :   false, /* isEliminatable.  Not relevant for setters. */
      50             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      51             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      52             :   false,  /* isTypedMethod.  Only relevant for methods. */
      53             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      54             : };
      55             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      56             : static_assert(0 < 1, "There is no slot for us");
      57             : 
      58             : static bool
      59           0 : get_count(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
      60             : {
      61           0 :   uint32_t result(self->Count());
      62           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      63           0 :   args.rval().setNumber(result);
      64           0 :   return true;
      65             : }
      66             : 
      67             : static const JSJitInfo count_getterinfo = {
      68             :   { (JSJitGetterOp)get_count },
      69             :   { prototypes::id::TreeColumns },
      70             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
      71             :   JSJitInfo::Getter,
      72             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      73             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      74             :   true,  /* 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_length(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
      87             : {
      88           0 :   uint32_t result(self->Length());
      89           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      90           0 :   args.rval().setNumber(result);
      91           0 :   return true;
      92             : }
      93             : 
      94             : static const JSJitInfo length_getterinfo = {
      95             :   { (JSJitGetterOp)get_length },
      96             :   { prototypes::id::TreeColumns },
      97             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
      98             :   JSJitInfo::Getter,
      99             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     100             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     101             :   true,  /* isInfallible. False in setters. */
     102             :   false,  /* isMovable.  Not relevant for setters. */
     103             :   false, /* isEliminatable.  Not relevant for setters. */
     104             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     105             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     106             :   false,  /* isTypedMethod.  Only relevant for methods. */
     107             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     108             : };
     109             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     110             : static_assert(0 < 1, "There is no slot for us");
     111             : 
     112             : static bool
     113           0 : getFirstColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     114             : {
     115           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetFirstColumn()));
     116           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     117           0 :   if (!result) {
     118           0 :     args.rval().setNull();
     119           0 :     return true;
     120             :   }
     121           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     122           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     123           0 :     return false;
     124             :   }
     125           0 :   return true;
     126             : }
     127             : 
     128             : static const JSJitInfo getFirstColumn_methodinfo = {
     129             :   { (JSJitGetterOp)getFirstColumn },
     130             :   { prototypes::id::TreeColumns },
     131             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     132             :   JSJitInfo::Method,
     133             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     134             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     135             :   false,  /* isInfallible. False in setters. */
     136             :   false,  /* isMovable.  Not relevant for setters. */
     137             :   false, /* isEliminatable.  Not relevant for setters. */
     138             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     139             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     140             :   false,  /* isTypedMethod.  Only relevant for methods. */
     141             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     142             : };
     143             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     144             : static_assert(0 < 1, "There is no slot for us");
     145             : 
     146             : static bool
     147           0 : getLastColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     148             : {
     149           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetLastColumn()));
     150           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     151           0 :   if (!result) {
     152           0 :     args.rval().setNull();
     153           0 :     return true;
     154             :   }
     155           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     156           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     157           0 :     return false;
     158             :   }
     159           0 :   return true;
     160             : }
     161             : 
     162             : static const JSJitInfo getLastColumn_methodinfo = {
     163             :   { (JSJitGetterOp)getLastColumn },
     164             :   { prototypes::id::TreeColumns },
     165             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     166             :   JSJitInfo::Method,
     167             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     168             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     169             :   false,  /* isInfallible. False in setters. */
     170             :   false,  /* isMovable.  Not relevant for setters. */
     171             :   false, /* isEliminatable.  Not relevant for setters. */
     172             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     173             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     174             :   false,  /* isTypedMethod.  Only relevant for methods. */
     175             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     176             : };
     177             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     178             : static_assert(0 < 1, "There is no slot for us");
     179             : 
     180             : static bool
     181           0 : getPrimaryColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     182             : {
     183           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetPrimaryColumn()));
     184           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     185           0 :   if (!result) {
     186           0 :     args.rval().setNull();
     187           0 :     return true;
     188             :   }
     189           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     190           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     191           0 :     return false;
     192             :   }
     193           0 :   return true;
     194             : }
     195             : 
     196             : static const JSJitInfo getPrimaryColumn_methodinfo = {
     197             :   { (JSJitGetterOp)getPrimaryColumn },
     198             :   { prototypes::id::TreeColumns },
     199             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     200             :   JSJitInfo::Method,
     201             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     202             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     203             :   false,  /* isInfallible. False in setters. */
     204             :   false,  /* isMovable.  Not relevant for setters. */
     205             :   false, /* isEliminatable.  Not relevant for setters. */
     206             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     207             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     208             :   false,  /* isTypedMethod.  Only relevant for methods. */
     209             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     210             : };
     211             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     212             : static_assert(0 < 1, "There is no slot for us");
     213             : 
     214             : static bool
     215           0 : getSortedColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     216             : {
     217           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetSortedColumn()));
     218           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     219           0 :   if (!result) {
     220           0 :     args.rval().setNull();
     221           0 :     return true;
     222             :   }
     223           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     224           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     225           0 :     return false;
     226             :   }
     227           0 :   return true;
     228             : }
     229             : 
     230             : static const JSJitInfo getSortedColumn_methodinfo = {
     231             :   { (JSJitGetterOp)getSortedColumn },
     232             :   { prototypes::id::TreeColumns },
     233             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     234             :   JSJitInfo::Method,
     235             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     236             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     237             :   false,  /* isInfallible. False in setters. */
     238             :   false,  /* isMovable.  Not relevant for setters. */
     239             :   false, /* isEliminatable.  Not relevant for setters. */
     240             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     241             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     242             :   false,  /* isTypedMethod.  Only relevant for methods. */
     243             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     244             : };
     245             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     246             : static_assert(0 < 1, "There is no slot for us");
     247             : 
     248             : static bool
     249           0 : getKeyColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     250             : {
     251           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetKeyColumn()));
     252           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     253           0 :   if (!result) {
     254           0 :     args.rval().setNull();
     255           0 :     return true;
     256             :   }
     257           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     258           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     259           0 :     return false;
     260             :   }
     261           0 :   return true;
     262             : }
     263             : 
     264             : static const JSJitInfo getKeyColumn_methodinfo = {
     265             :   { (JSJitGetterOp)getKeyColumn },
     266             :   { prototypes::id::TreeColumns },
     267             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     268             :   JSJitInfo::Method,
     269             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     270             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     271             :   false,  /* isInfallible. False in setters. */
     272             :   false,  /* isMovable.  Not relevant for setters. */
     273             :   false, /* isEliminatable.  Not relevant for setters. */
     274             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     275             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     276             :   false,  /* isTypedMethod.  Only relevant for methods. */
     277             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     278             : };
     279             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     280             : static_assert(0 < 1, "There is no slot for us");
     281             : 
     282             : static bool
     283           0 : getColumnFor(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     284             : {
     285           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     286           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getColumnFor");
     287             :   }
     288             :   mozilla::dom::Element* arg0;
     289           0 :   if (args[0].isObject()) {
     290             :     {
     291           0 :       nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
     292           0 :       if (NS_FAILED(rv)) {
     293           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of TreeColumns.getColumnFor", "Element");
     294           0 :         return false;
     295             :       }
     296             :     }
     297           0 :   } else if (args[0].isNullOrUndefined()) {
     298           0 :     arg0 = nullptr;
     299             :   } else {
     300           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of TreeColumns.getColumnFor");
     301           0 :     return false;
     302             :   }
     303           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetColumnFor(Constify(arg0))));
     304           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     305           0 :   if (!result) {
     306           0 :     args.rval().setNull();
     307           0 :     return true;
     308             :   }
     309           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     310           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     311           0 :     return false;
     312             :   }
     313           0 :   return true;
     314             : }
     315             : 
     316             : static const JSJitInfo getColumnFor_methodinfo = {
     317             :   { (JSJitGetterOp)getColumnFor },
     318             :   { prototypes::id::TreeColumns },
     319             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     320             :   JSJitInfo::Method,
     321             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     322             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     323             :   false,  /* isInfallible. False in setters. */
     324             :   false,  /* isMovable.  Not relevant for setters. */
     325             :   false, /* isEliminatable.  Not relevant for setters. */
     326             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     327             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     328             :   false,  /* isTypedMethod.  Only relevant for methods. */
     329             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     330             : };
     331             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     332             : static_assert(0 < 1, "There is no slot for us");
     333             : 
     334             : static bool
     335           0 : getNamedColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     336             : {
     337           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     338           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getNamedColumn");
     339             :   }
     340           0 :   binding_detail::FakeString arg0;
     341           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     342           0 :     return false;
     343             :   }
     344           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetNamedColumn(NonNullHelper(Constify(arg0)))));
     345           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     346           0 :   if (!result) {
     347           0 :     args.rval().setNull();
     348           0 :     return true;
     349             :   }
     350           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     351           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     352           0 :     return false;
     353             :   }
     354           0 :   return true;
     355             : }
     356             : 
     357             : static const JSJitInfo getNamedColumn_methodinfo = {
     358             :   { (JSJitGetterOp)getNamedColumn },
     359             :   { prototypes::id::TreeColumns },
     360             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     361             :   JSJitInfo::Method,
     362             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     363             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     364             :   false,  /* isInfallible. False in setters. */
     365             :   false,  /* isMovable.  Not relevant for setters. */
     366             :   false, /* isEliminatable.  Not relevant for setters. */
     367             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     368             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     369             :   false,  /* isTypedMethod.  Only relevant for methods. */
     370             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     371             : };
     372             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     373             : static_assert(0 < 1, "There is no slot for us");
     374             : 
     375             : static bool
     376           0 : getColumnAt(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     377             : {
     378           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     379           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getColumnAt");
     380             :   }
     381             :   uint32_t arg0;
     382           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
     383           0 :     return false;
     384             :   }
     385           0 :   auto result(StrongOrRawPtr<nsTreeColumn>(self->GetColumnAt(arg0)));
     386           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     387           0 :   if (!result) {
     388           0 :     args.rval().setNull();
     389           0 :     return true;
     390             :   }
     391           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     392           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     393           0 :     return false;
     394             :   }
     395           0 :   return true;
     396             : }
     397             : 
     398             : static const JSJitInfo getColumnAt_methodinfo = {
     399             :   { (JSJitGetterOp)getColumnAt },
     400             :   { prototypes::id::TreeColumns },
     401             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     402             :   JSJitInfo::Method,
     403             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     404             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     405             :   false,  /* isInfallible. False in setters. */
     406             :   false,  /* isMovable.  Not relevant for setters. */
     407             :   false, /* isEliminatable.  Not relevant for setters. */
     408             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     409             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     410             :   false,  /* isTypedMethod.  Only relevant for methods. */
     411             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     412             : };
     413             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     414             : static_assert(0 < 1, "There is no slot for us");
     415             : 
     416             : static bool
     417           0 : invalidateColumns(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     418             : {
     419           0 :   self->InvalidateColumns();
     420           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     421           0 :   args.rval().setUndefined();
     422           0 :   return true;
     423             : }
     424             : 
     425             : static const JSJitInfo invalidateColumns_methodinfo = {
     426             :   { (JSJitGetterOp)invalidateColumns },
     427             :   { prototypes::id::TreeColumns },
     428             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     429             :   JSJitInfo::Method,
     430             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     431             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     432             :   true,  /* isInfallible. False in setters. */
     433             :   false,  /* isMovable.  Not relevant for setters. */
     434             :   false, /* isEliminatable.  Not relevant for setters. */
     435             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     436             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     437             :   false,  /* isTypedMethod.  Only relevant for methods. */
     438             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     439             : };
     440             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     441             : static_assert(0 < 1, "There is no slot for us");
     442             : 
     443             : static bool
     444           0 : restoreNaturalOrder(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
     445             : {
     446           0 :   self->RestoreNaturalOrder();
     447           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     448           0 :   args.rval().setUndefined();
     449           0 :   return true;
     450             : }
     451             : 
     452             : static const JSJitInfo restoreNaturalOrder_methodinfo = {
     453             :   { (JSJitGetterOp)restoreNaturalOrder },
     454             :   { prototypes::id::TreeColumns },
     455             :   { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
     456             :   JSJitInfo::Method,
     457             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     458             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     459             :   true,  /* isInfallible. False in setters. */
     460             :   false,  /* isMovable.  Not relevant for setters. */
     461             :   false, /* isEliminatable.  Not relevant for setters. */
     462             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     463             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     464             :   false,  /* isTypedMethod.  Only relevant for methods. */
     465             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     466             : };
     467             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     468             : static_assert(0 < 1, "There is no slot for us");
     469             : 
     470             : static void
     471           0 : _objectMoved(JSObject* obj, const JSObject* old)
     472             : {
     473           0 :   nsTreeColumns* self = UnwrapPossiblyNotInitializedDOMObject<nsTreeColumns>(obj);
     474           0 :   if (self) {
     475           0 :     UpdateWrapper(self, self, obj, old);
     476             :   }
     477           0 : }
     478             : 
     479             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     480             : #if defined(__clang__)
     481             : #pragma clang diagnostic push
     482             : #pragma clang diagnostic ignored "-Wmissing-braces"
     483             : #endif
     484             : static const JSFunctionSpec sMethods_specs[] = {
     485             :   JS_FNSPEC("getFirstColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getFirstColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     486             :   JS_FNSPEC("getLastColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getLastColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     487             :   JS_FNSPEC("getPrimaryColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getPrimaryColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     488             :   JS_FNSPEC("getSortedColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getSortedColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     489             :   JS_FNSPEC("getKeyColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getKeyColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     490             :   JS_FNSPEC("getColumnFor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getColumnFor_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     491             :   JS_FNSPEC("getNamedColumn", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getNamedColumn_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     492             :   JS_FNSPEC("getColumnAt", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getColumnAt_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     493             :   JS_FNSPEC("invalidateColumns", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&invalidateColumns_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     494             :   JS_FNSPEC("restoreNaturalOrder", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&restoreNaturalOrder_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     495             :   JS_FS_END,
     496             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
     497             :   JS_FS_END,
     498             :   JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
     499             :   JS_FS_END
     500             : };
     501             : #if defined(__clang__)
     502             : #pragma clang diagnostic pop
     503             : #endif
     504             : 
     505             : static PrefableDisablers sMethods_disablers11 = {
     506             :   true, false, 0, &WantsQueryInterface<nsTreeColumns>::Enabled
     507             : };
     508             : 
     509             : // Can't be const because the pref-enabled boolean needs to be writable
     510             : static Prefable<const JSFunctionSpec> sMethods[] = {
     511             :   { nullptr, &sMethods_specs[0] },
     512             :   { &sMethods_disablers11, &sMethods_specs[11] },
     513             :   { nullptr, &sMethods_specs[13] },
     514             :   { nullptr, nullptr }
     515             : };
     516             : 
     517             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     518             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     519             : static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     520             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     521             : 
     522             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     523             : #if defined(__clang__)
     524             : #pragma clang diagnostic push
     525             : #pragma clang diagnostic ignored "-Wmissing-braces"
     526             : #endif
     527             : static const JSPropertySpec sAttributes_specs[] = {
     528             :   { "tree", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &tree_getterinfo, nullptr, nullptr },
     529             :   { "count", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &count_getterinfo, nullptr, nullptr },
     530             :   { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
     531             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     532             : };
     533             : #if defined(__clang__)
     534             : #pragma clang diagnostic pop
     535             : #endif
     536             : 
     537             : 
     538             : // Can't be const because the pref-enabled boolean needs to be writable
     539             : static Prefable<const JSPropertySpec> sAttributes[] = {
     540             :   { nullptr, &sAttributes_specs[0] },
     541             :   { nullptr, nullptr }
     542             : };
     543             : 
     544             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     545             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     546             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     547             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     548             : 
     549             : 
     550             : static uint16_t sNativeProperties_sortedPropertyIndices[15];
     551             : static PropertyInfo sNativeProperties_propertyInfos[15];
     552             : 
     553             : static const NativePropertiesN<2> sNativeProperties = {
     554             :   false, 0,
     555             :   false, 0,
     556             :   true,  0 /* sMethods */,
     557             :   true,  1 /* sAttributes */,
     558             :   false, 0,
     559             :   false, 0,
     560             :   false, 0,
     561             :   -1,
     562             :   15,
     563             :   sNativeProperties_sortedPropertyIndices,
     564             :   {
     565             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     566             :     { sAttributes, &sNativeProperties_propertyInfos[12] }
     567             :   }
     568             : };
     569             : static_assert(15 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     570             :     "We have a property info count that is oversized");
     571             : 
     572             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     573             :   {
     574             :     "Function",
     575             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     576             :     &sBoringInterfaceObjectClassClassOps,
     577             :     JS_NULL_CLASS_SPEC,
     578             :     JS_NULL_CLASS_EXT,
     579             :     &sInterfaceObjectClassObjectOps
     580             :   },
     581             :   eInterface,
     582             :   true,
     583             :   prototypes::id::TreeColumns,
     584             :   PrototypeTraits<prototypes::id::TreeColumns>::Depth,
     585             :   sNativePropertyHooks,
     586             :   "function TreeColumns() {\n    [native code]\n}",
     587             :   JS::GetRealmFunctionPrototype
     588             : };
     589             : 
     590             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     591             :   {
     592             :     "TreeColumnsPrototype",
     593             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     594             :     JS_NULL_CLASS_OPS,
     595             :     JS_NULL_CLASS_SPEC,
     596             :     JS_NULL_CLASS_EXT,
     597             :     JS_NULL_OBJECT_OPS
     598             :   },
     599             :   eInterfacePrototype,
     600             :   false,
     601             :   prototypes::id::TreeColumns,
     602             :   PrototypeTraits<prototypes::id::TreeColumns>::Depth,
     603             :   sNativePropertyHooks,
     604             :   "[object TreeColumnsPrototype]",
     605             :   JS::GetRealmObjectPrototype
     606             : };
     607             : 
     608             : bool
     609           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     610             : {
     611           0 :   return IsChromeOrXBL(aCx, aObj);
     612             : }
     613             : 
     614             : JSObject*
     615           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     616             : {
     617           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     618             : }
     619             : 
     620             : static_assert(IsBaseOf<nsISupports, nsTreeColumns >::value,
     621             :                   "We don't support non-nsISupports native classes for "
     622             :                   "proxy-based bindings yet");
     623             : 
     624             : 
     625             : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
     626             : {
     627             : public:
     628             :   explicit constexpr DOMProxyHandler()
     629             :   {
     630             :   }
     631             : 
     632             :   virtual bool
     633             :   getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
     634             : 
     635             :   virtual bool
     636             :   defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
     637             : 
     638             :   using mozilla::dom::DOMProxyHandler::defineProperty;
     639             : 
     640             :   virtual bool
     641             :   ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
     642             : 
     643             :   virtual bool
     644             :   hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
     645             : 
     646             :   virtual bool
     647             :   get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
     648             : 
     649             :   virtual const char*
     650             :   className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
     651             : 
     652             :   virtual bool
     653             :   finalizeInBackground(const JS::Value& priv) const override;
     654             : 
     655             :   virtual void
     656             :   finalize(JSFreeOp* fop, JSObject* proxy) const override;
     657             : 
     658             :   static const DOMProxyHandler*
     659             :   getInstance();
     660             : 
     661             :   virtual bool
     662             :   delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
     663             : 
     664             :   virtual bool
     665             :   getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
     666             : };
     667             : 
     668             : MOZ_ALWAYS_INLINE bool
     669           0 : IsProxy(JSObject* obj)
     670             : {
     671           0 :   return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
     672             : }
     673             : 
     674             : MOZ_ALWAYS_INLINE nsTreeColumns*
     675           0 : UnwrapProxy(JSObject* obj)
     676             : {
     677           0 :   MOZ_ASSERT(js::IsProxy(obj));
     678           0 :   if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
     679           0 :     MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
     680           0 :     obj = js::UncheckedUnwrap(obj);
     681             :   }
     682           0 :   MOZ_ASSERT(IsProxy(obj));
     683           0 :   return static_cast<nsTreeColumns*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
     684             : }
     685             : 
     686             : bool
     687           0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
     688             : {
     689           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
     690           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     691           0 :   if (IsArrayIndex(index)) {
     692           0 :     nsTreeColumns* self = UnwrapProxy(proxy);
     693           0 :     bool found = false;
     694           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
     695           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     696             : 
     697           0 :     if (found) {
     698           0 :       if (!result) {
     699           0 :         desc.value().setNull();
     700           0 :         FillPropertyDescriptor(desc, proxy, true);
     701           0 :         return true;
     702             :       }
     703           0 :       if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
     704           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     705           0 :         return false;
     706             :       }
     707           0 :       FillPropertyDescriptor(desc, proxy, true);
     708           0 :       return true;
     709             :     }
     710             :   }
     711             : 
     712           0 :   JS::Rooted<JSObject*> expando(cx);
     713           0 :   if (!isXray && (expando = GetExpandoObject(proxy))) {
     714           0 :     if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
     715           0 :       return false;
     716             :     }
     717           0 :     if (desc.object()) {
     718             :       // Pretend the property lives on the wrapper.
     719           0 :       desc.object().set(proxy);
     720           0 :       return true;
     721             :     }
     722             :   }
     723             : 
     724           0 :   bool callNamedGetter = false;
     725           0 :   if (!IsArrayIndex(index) && !ignoreNamedProps) {
     726             :     bool hasOnProto;
     727           0 :     if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
     728           0 :       return false;
     729             :     }
     730           0 :     callNamedGetter = !hasOnProto;
     731             :   }
     732           0 :   if (callNamedGetter) {
     733           0 :     binding_detail::FakeString name;
     734             :     bool isSymbol;
     735           0 :     if (!ConvertIdToString(cx, id, name, isSymbol)) {
     736           0 :       return false;
     737             :     }
     738           0 :     if (!isSymbol) {
     739           0 :       nsTreeColumns* self = UnwrapProxy(proxy);
     740           0 :       bool found = false;
     741           0 :       auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
     742           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     743             : 
     744           0 :       if (found) {
     745           0 :         if (!result) {
     746           0 :           desc.value().setNull();
     747           0 :           FillPropertyDescriptor(desc, proxy, true, true);
     748           0 :           return true;
     749             :         }
     750           0 :         if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
     751           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     752           0 :           return false;
     753             :         }
     754           0 :         FillPropertyDescriptor(desc, proxy, true, true);
     755           0 :         return true;
     756             :       }
     757             :     }
     758             :   }
     759             : 
     760           0 :   desc.object().set(nullptr);
     761           0 :   return true;
     762             : }
     763             : 
     764             : bool
     765           0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
     766             : {
     767           0 :   if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
     768           0 :     *defined = true;
     769           0 :     return opresult.failNoIndexedSetter();
     770             :   }
     771           0 :   bool found = false;
     772           0 :   binding_detail::FakeString name;
     773             :   bool isSymbol;
     774           0 :   if (!ConvertIdToString(cx, id, name, isSymbol)) {
     775           0 :     return false;
     776             :   }
     777           0 :   if (!isSymbol) {
     778           0 :     nsTreeColumns* self = UnwrapProxy(proxy);
     779           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
     780           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     781             :     (void)result;
     782             :   }
     783             : 
     784           0 :   if (found) {
     785           0 :     *defined = true;
     786           0 :     return opresult.failNoNamedSetter();
     787             :   }
     788           0 :   return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
     789             : }
     790             : 
     791             : 
     792             : bool
     793           0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
     794             : {
     795           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
     796             : 
     797           0 :   uint32_t length = UnwrapProxy(proxy)->Length();
     798           0 :   MOZ_ASSERT(int32_t(length) >= 0);
     799           0 :   for (int32_t i = 0; i < int32_t(length); ++i) {
     800           0 :     if (!props.append(INT_TO_JSID(i))) {
     801           0 :       return false;
     802             :     }
     803             :   }
     804             : 
     805           0 :   nsTArray<nsString> names;
     806           0 :   UnwrapProxy(proxy)->GetSupportedNames(names);
     807           0 :   if (!AppendNamedPropertyIds(cx, proxy, names, false, props)) {
     808           0 :     return false;
     809             :   }
     810             : 
     811           0 :   JS::Rooted<JSObject*> expando(cx);
     812           0 :   if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
     813           0 :       !js::GetPropertyKeys(cx, expando, flags, &props)) {
     814           0 :     return false;
     815             :   }
     816             : 
     817           0 :   return true;
     818             : }
     819             : 
     820             : bool
     821           0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
     822             : {
     823           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     824             :             "Should not have a XrayWrapper here");
     825             : 
     826           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     827           0 :   if (IsArrayIndex(index)) {
     828           0 :     bool found = false;
     829           0 :     nsTreeColumns* self = UnwrapProxy(proxy);
     830           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
     831           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     832             :     (void)result;
     833             : 
     834           0 :     *bp = found;
     835           0 :     return true;
     836             :   }
     837             : 
     838             : 
     839           0 :   JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
     840           0 :   if (expando) {
     841           0 :     bool b = true;
     842           0 :     bool ok = JS_HasPropertyById(cx, expando, id, &b);
     843           0 :     *bp = !!b;
     844           0 :     if (!ok || *bp) {
     845           0 :       return ok;
     846             :     }
     847             :   }
     848             : 
     849             :   bool hasOnProto;
     850           0 :   if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
     851           0 :     return false;
     852             :   }
     853           0 :   if (!hasOnProto) {
     854           0 :     bool found = false;
     855           0 :     binding_detail::FakeString name;
     856             :     bool isSymbol;
     857           0 :     if (!ConvertIdToString(cx, id, name, isSymbol)) {
     858           0 :       return false;
     859             :     }
     860           0 :     if (!isSymbol) {
     861           0 :       nsTreeColumns* self = UnwrapProxy(proxy);
     862           0 :       auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
     863           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     864             :       (void)result;
     865             :     }
     866             : 
     867           0 :     *bp = found;
     868           0 :     return true;
     869             :   }
     870           0 :   *bp = false;
     871           0 :   return true;
     872             : }
     873             : 
     874             : bool
     875           0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
     876             : {
     877           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     878             :               "Should not have a XrayWrapper here");
     879             : 
     880           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     881           0 :   if (IsArrayIndex(index)) {
     882           0 :     nsTreeColumns* self = UnwrapProxy(proxy);
     883           0 :     bool found = false;
     884           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
     885           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     886             : 
     887           0 :     if (found) {
     888           0 :       if (!result) {
     889           0 :         vp.setNull();
     890           0 :         return true;
     891             :       }
     892           0 :       if (!GetOrCreateDOMReflector(cx, result, vp)) {
     893           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     894           0 :         return false;
     895             :       }
     896           0 :       return true;
     897             :     }
     898             :     // Even if we don't have this index, we don't forward the
     899             :     // get on to our expando object.
     900             :   } else {
     901             :     { // Scope for expando
     902           0 :       JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
     903           0 :       if (expando) {
     904             :         bool hasProp;
     905           0 :         if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
     906           0 :           return false;
     907             :         }
     908             : 
     909           0 :         if (hasProp) {
     910             :           // Forward the get to the expando object, but our receiver is whatever our
     911             :           // receiver is.
     912           0 :           return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
     913             :         }
     914             :       }
     915             :     }
     916             :   }
     917             : 
     918             :   bool foundOnPrototype;
     919           0 :   if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
     920           0 :     return false;
     921             :   }
     922             : 
     923           0 :   if (foundOnPrototype) {
     924           0 :     return true;
     925             :   }
     926             : 
     927           0 :   if (!IsArrayIndex(index)) {
     928           0 :     binding_detail::FakeString name;
     929             :     bool isSymbol;
     930           0 :     if (!ConvertIdToString(cx, id, name, isSymbol)) {
     931           0 :       return false;
     932             :     }
     933           0 :     if (!isSymbol) {
     934           0 :       nsTreeColumns* self = UnwrapProxy(proxy);
     935           0 :       bool found = false;
     936           0 :       auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
     937           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     938             : 
     939           0 :       if (found) {
     940           0 :         if (!result) {
     941           0 :           vp.setNull();
     942           0 :           return true;
     943             :         }
     944           0 :         if (!GetOrCreateDOMReflector(cx, result, vp)) {
     945           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     946           0 :           return false;
     947             :         }
     948           0 :         return true;
     949             :       }
     950             :     }
     951             :   }
     952             : 
     953           0 :   vp.setUndefined();
     954           0 :   return true;
     955             : }
     956             : 
     957             : const char*
     958           0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
     959             : {
     960           0 :   return "TreeColumns";
     961             : }
     962             : 
     963             : bool
     964           0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
     965             : {
     966           0 :   return false;
     967             : }
     968             : 
     969             : void
     970           0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
     971             : {
     972           0 :   nsTreeColumns* self = UnwrapPossiblyNotInitializedDOMObject<nsTreeColumns>(proxy);
     973           0 :   if (self) {
     974           0 :     ClearWrapper(self, self, proxy);
     975           0 :     AddForDeferredFinalization<nsTreeColumns>(self);
     976             :   }
     977           0 : }
     978             : 
     979             : const DOMProxyHandler*
     980           0 : DOMProxyHandler::getInstance()
     981             : {
     982             :   static const DOMProxyHandler instance;
     983           0 :   return &instance;
     984             : }
     985             : 
     986             : bool
     987           0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
     988             : {
     989           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     990             :             "Should not have a XrayWrapper here");
     991             : 
     992           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     993           0 :   if (IsArrayIndex(index)) {
     994             :     bool deleteSucceeded;
     995           0 :     bool found = false;
     996           0 :     nsTreeColumns* self = UnwrapProxy(proxy);
     997           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
     998           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     999             :     (void)result;
    1000           0 :     deleteSucceeded = !found;
    1001           0 :     return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
    1002             :   }
    1003             :   // Try named delete only if the named property visibility
    1004             :   // algorithm says the property is visible.
    1005           0 :   bool tryNamedDelete = true;
    1006             :   { // Scope for expando
    1007           0 :     JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
    1008           0 :     if (expando) {
    1009             :       bool hasProp;
    1010           0 :       if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
    1011           0 :         return false;
    1012             :       }
    1013           0 :       tryNamedDelete = !hasProp;
    1014             :     }
    1015             :   }
    1016           0 :   if (tryNamedDelete) {
    1017             :     bool hasOnProto;
    1018           0 :     if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
    1019           0 :       return false;
    1020             :     }
    1021           0 :     tryNamedDelete = !hasOnProto;
    1022             :   }
    1023           0 :   if (tryNamedDelete) {
    1024           0 :     bool found = false;
    1025             :     bool deleteSucceeded;
    1026           0 :     binding_detail::FakeString name;
    1027             :     bool isSymbol;
    1028           0 :     if (!ConvertIdToString(cx, id, name, isSymbol)) {
    1029           0 :       return false;
    1030             :     }
    1031           0 :     if (!isSymbol) {
    1032           0 :       nsTreeColumns* self = UnwrapProxy(proxy);
    1033           0 :       auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
    1034           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1035             :       (void)result;
    1036             :     }
    1037           0 :     deleteSucceeded = !found;
    1038           0 :     if (found) {
    1039           0 :       return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
    1040             :     }
    1041             :   }
    1042             : 
    1043           0 :   return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
    1044             : }
    1045             : 
    1046             : bool
    1047           0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
    1048             : {
    1049           0 :   JS::Rooted<JS::Value> temp(cx);
    1050           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    1051             :              "Should not have a XrayWrapper here");
    1052             : 
    1053           0 :   nsTreeColumns* self = UnwrapProxy(proxy);
    1054           0 :   uint32_t length = self->Length();
    1055             :   // Compute the end of the indices we'll get ourselves
    1056           0 :   uint32_t ourEnd = std::max(begin, std::min(end, length));
    1057             : 
    1058           0 :   for (uint32_t index = begin; index < ourEnd; ++index) {
    1059           0 :     bool found = false;
    1060           0 :     auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
    1061           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1062             : 
    1063           0 :     MOZ_ASSERT(found);
    1064           0 :     if (!result) {
    1065           0 :       temp.setNull();
    1066           0 :       if (!adder->append(cx, temp)) return false;
    1067           0 :       continue;
    1068             :     }
    1069           0 :     if (!GetOrCreateDOMReflector(cx, result, &temp)) {
    1070           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1071           0 :       return false;
    1072             :     }
    1073           0 :     if (!adder->append(cx, temp)) return false;
    1074           0 :     continue;
    1075             :   }
    1076             : 
    1077           0 :   if (end > ourEnd) {
    1078           0 :     JS::Rooted<JSObject*> proto(cx);
    1079           0 :     if (!js::GetObjectProto(cx, proxy, &proto)) {
    1080           0 :       return false;
    1081             :     }
    1082           0 :     return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
    1083             :   }
    1084             : 
    1085           0 :   return true;
    1086             : }
    1087             : 
    1088             : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
    1089             :     _objectMoved
    1090             : );
    1091             : 
    1092             : static const DOMJSClass sClass = {
    1093             :   PROXY_CLASS_WITH_EXT("TreeColumns",
    1094             :                        JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
    1095             :                        &sClassExtension),
    1096             :   { prototypes::id::TreeColumns, 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 },
    1097             :   IsBaseOf<nsISupports, nsTreeColumns >::value,
    1098             :   sNativePropertyHooks,
    1099             :   FindAssociatedGlobalForNative<nsTreeColumns>::Get,
    1100             :   GetProtoObjectHandle,
    1101             :   GetCCParticipant<nsTreeColumns>::Get()
    1102             : };
    1103             : 
    1104             : bool
    1105           0 : Wrap(JSContext* aCx, nsTreeColumns* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1106             : {
    1107             :   MOZ_ASSERT(static_cast<nsTreeColumns*>(aObject) ==
    1108             :              reinterpret_cast<nsTreeColumns*>(aObject),
    1109             :              "Multiple inheritance for nsTreeColumns is broken.");
    1110           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1111           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1112           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1113             :              "You should probably not be using Wrap() directly; use "
    1114             :              "GetOrCreateDOMReflector instead");
    1115             : 
    1116           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1117             :              "nsISupports must be on our primary inheritance chain");
    1118             : 
    1119           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1120           0 :   if (!global) {
    1121           0 :     return false;
    1122             :   }
    1123           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1124           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1125             : 
    1126             :   // That might have ended up wrapping us already, due to the wonders
    1127             :   // of XBL.  Check for that, and bail out as needed.
    1128           0 :   aReflector.set(aCache->GetWrapper());
    1129           0 :   if (aReflector) {
    1130             : #ifdef DEBUG
    1131           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1132             : #endif // DEBUG
    1133           0 :     return true;
    1134             :   }
    1135             : 
    1136           0 :   JSAutoCompartment ac(aCx, global);
    1137           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1138           0 :   if (!canonicalProto) {
    1139           0 :     return false;
    1140             :   }
    1141           0 :   JS::Rooted<JSObject*> proto(aCx);
    1142           0 :   if (aGivenProto) {
    1143           0 :     proto = aGivenProto;
    1144             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1145             :     // coming in, we changed compartments to that of "parent" so may need
    1146             :     // to wrap the proto here.
    1147           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1148           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1149           0 :         return false;
    1150             :       }
    1151             :     }
    1152             :   } else {
    1153           0 :     proto = canonicalProto;
    1154             :   }
    1155             : 
    1156           0 :   BindingJSObjectCreator<nsTreeColumns> creator(aCx);
    1157           0 :   JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
    1158           0 :   creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
    1159           0 :                             proto, aObject, expandoValue, aReflector);
    1160           0 :   if (!aReflector) {
    1161           0 :     return false;
    1162             :   }
    1163             : 
    1164             : 
    1165           0 :   aCache->SetWrapper(aReflector);
    1166           0 :   creator.InitializationSucceeded();
    1167             : 
    1168           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1169             :              aCache->GetWrapperPreserveColor() == aReflector);
    1170             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1171             :   // otherwise we won't be able to properly recreate it later, since
    1172             :   // we won't know what proto to use.  Note that we don't check
    1173             :   // aGivenProto here, since it's entirely possible (and even
    1174             :   // somewhat common) to have a non-null aGivenProto which is the
    1175             :   // same as canonicalProto.
    1176           0 :   if (proto != canonicalProto) {
    1177           0 :     PreserveWrapper(aObject);
    1178             :   }
    1179             : 
    1180           0 :   return true;
    1181             : }
    1182             : 
    1183             : static bool
    1184           0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
    1185             : {
    1186           0 :   return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
    1187             : }
    1188             : 
    1189             : static bool
    1190           0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
    1191             : {
    1192           0 :   return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
    1193             : }
    1194             : 
    1195             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1196             :   ResolveOwnProperty,
    1197             :   EnumerateOwnProperties,
    1198             :   nullptr,
    1199             :   { sNativeProperties.Upcast(), nullptr },
    1200             :   prototypes::id::TreeColumns,
    1201             :   constructors::id::TreeColumns,
    1202             :   nullptr,
    1203             :   &DefaultXrayExpandoObjectClass
    1204             : } };
    1205             : 
    1206             : void
    1207           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1208             : {
    1209           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1210           0 :   if (!parentProto) {
    1211           0 :     return;
    1212             :   }
    1213             : 
    1214           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1215           0 :   if (!constructorProto) {
    1216           0 :     return;
    1217             :   }
    1218             : 
    1219             :   static bool sIdsInited = false;
    1220           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1221           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1222           0 :       return;
    1223             :     }
    1224           0 :     sIdsInited = true;
    1225             :   }
    1226             : 
    1227           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TreeColumns);
    1228           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TreeColumns);
    1229           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1230             :                               &sPrototypeClass.mBase, protoCache,
    1231             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1232             :                               interfaceCache,
    1233             :                               sNativeProperties.Upcast(),
    1234             :                               nullptr,
    1235             :                               "TreeColumns", aDefineOnGlobal,
    1236             :                               nullptr,
    1237           0 :                               false);
    1238             : }
    1239             : 
    1240             : JS::Handle<JSObject*>
    1241           0 : GetProtoObjectHandle(JSContext* aCx)
    1242             : {
    1243             :   /* Get the interface prototype object for this class.  This will create the
    1244             :      object as needed. */
    1245           0 :   bool aDefineOnGlobal = true;
    1246             : 
    1247             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1248           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1249           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1250           0 :     return nullptr;
    1251             :   }
    1252             : 
    1253             :   /* Check to see whether the interface objects are already installed */
    1254           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1255           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::TreeColumns)) {
    1256           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1257           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1258             :   }
    1259             : 
    1260             :   /*
    1261             :    * The object might _still_ be null, but that's OK.
    1262             :    *
    1263             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1264             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1265             :    * changed after they have been set.
    1266             :    *
    1267             :    * Calling address() avoids the read read barrier that does gray
    1268             :    * unmarking, but it's not possible for the object to be gray here.
    1269             :    */
    1270             : 
    1271           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::TreeColumns);
    1272           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1273           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1274             : }
    1275             : 
    1276             : JS::Handle<JSObject*>
    1277           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1278             : {
    1279             :   /* Get the interface object for this class.  This will create the object as
    1280             :      needed. */
    1281             : 
    1282             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1283           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1284           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1285           0 :     return nullptr;
    1286             :   }
    1287             : 
    1288             :   /* Check to see whether the interface objects are already installed */
    1289           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1290           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::TreeColumns)) {
    1291           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1292           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1293             :   }
    1294             : 
    1295             :   /*
    1296             :    * The object might _still_ be null, but that's OK.
    1297             :    *
    1298             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1299             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1300             :    * changed after they have been set.
    1301             :    *
    1302             :    * Calling address() avoids the read read barrier that does gray
    1303             :    * unmarking, but it's not possible for the object to be gray here.
    1304             :    */
    1305             : 
    1306           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::TreeColumns);
    1307           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1308           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1309             : }
    1310             : 
    1311             : JSObject*
    1312           0 : GetConstructorObject(JSContext* aCx)
    1313             : {
    1314           0 :   return GetConstructorObjectHandle(aCx);
    1315             : }
    1316             : 
    1317             : } // namespace TreeColumnsBinding
    1318             : 
    1319             : 
    1320             : 
    1321             : } // namespace dom
    1322             : } // namespace mozilla

Generated by: LCOV version 1.13