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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM TreeWalker.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "NodeFilterBinding.h"
       4             : #include "TreeWalkerBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/Nullable.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/TreeWalker.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : #include "nsINode.h"
      15             : #include "nsISupports.h"
      16             : #include "xpcjsid.h"
      17             : 
      18             : namespace mozilla {
      19             : namespace dom {
      20             : 
      21             : namespace TreeWalkerBinding {
      22             : 
      23             : static bool
      24           0 : get_root(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args)
      25             : {
      26           0 :   auto result(StrongOrRawPtr<nsINode>(self->Root()));
      27           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      28           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      29           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      30           0 :     return false;
      31             :   }
      32           0 :   return true;
      33             : }
      34             : 
      35             : static const JSJitInfo root_getterinfo = {
      36             :   { (JSJitGetterOp)get_root },
      37             :   { prototypes::id::TreeWalker },
      38             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
      39             :   JSJitInfo::Getter,
      40             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      41             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      42             :   false,  /* isInfallible. False in setters. */
      43             :   true,  /* isMovable.  Not relevant for setters. */
      44             :   true, /* isEliminatable.  Not relevant for setters. */
      45             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      46             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      47             :   false,  /* isTypedMethod.  Only relevant for methods. */
      48             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      49             : };
      50             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      51             : static_assert(0 < 1, "There is no slot for us");
      52             : 
      53             : static bool
      54           0 : get_whatToShow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args)
      55             : {
      56           0 :   uint32_t result(self->WhatToShow());
      57           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      58           0 :   args.rval().setNumber(result);
      59           0 :   return true;
      60             : }
      61             : 
      62             : static const JSJitInfo whatToShow_getterinfo = {
      63             :   { (JSJitGetterOp)get_whatToShow },
      64             :   { prototypes::id::TreeWalker },
      65             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
      66             :   JSJitInfo::Getter,
      67             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      68             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      69             :   true,  /* isInfallible. False in setters. */
      70             :   true,  /* isMovable.  Not relevant for setters. */
      71             :   true, /* isEliminatable.  Not relevant for setters. */
      72             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      73             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      74             :   false,  /* isTypedMethod.  Only relevant for methods. */
      75             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      76             : };
      77             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      78             : static_assert(0 < 1, "There is no slot for us");
      79             : 
      80             : static bool
      81           0 : get_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args)
      82             : {
      83           0 :   auto result(StrongOrRawPtr<mozilla::dom::NodeFilter>(self->GetFilter()));
      84           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      85           0 :   if (result) {
      86           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
      87           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
      88           0 :       return false;
      89             :     }
      90           0 :     return true;
      91             :   } else {
      92           0 :     args.rval().setNull();
      93           0 :     return true;
      94             :   }
      95             : }
      96             : 
      97             : static const JSJitInfo filter_getterinfo = {
      98             :   { (JSJitGetterOp)get_filter },
      99             :   { prototypes::id::TreeWalker },
     100             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     101             :   JSJitInfo::Getter,
     102             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     103             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     104             :   false,  /* isInfallible. False in setters. */
     105             :   true,  /* isMovable.  Not relevant for setters. */
     106             :   true, /* 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 : get_currentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args)
     117             : {
     118           0 :   auto result(StrongOrRawPtr<nsINode>(self->CurrentNode()));
     119           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     120           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     121           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     122           0 :     return false;
     123             :   }
     124           0 :   return true;
     125             : }
     126             : 
     127             : static bool
     128           0 : set_currentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitSetterCallArgs args)
     129             : {
     130           0 :   NonNull<nsINode> arg0;
     131           0 :   if (args[0].isObject()) {
     132             :     {
     133           0 :       nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
     134           0 :       if (NS_FAILED(rv)) {
     135           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to TreeWalker.currentNode", "Node");
     136           0 :         return false;
     137             :       }
     138             :     }
     139             :   } else {
     140           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to TreeWalker.currentNode");
     141           0 :     return false;
     142             :   }
     143           0 :   binding_detail::FastErrorResult rv;
     144           0 :   self->SetCurrentNode(NonNullHelper(arg0), rv);
     145           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     146           0 :     return false;
     147             :   }
     148           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     149             : 
     150           0 :   return true;
     151             : }
     152             : 
     153             : static const JSJitInfo currentNode_getterinfo = {
     154             :   { (JSJitGetterOp)get_currentNode },
     155             :   { prototypes::id::TreeWalker },
     156             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     157             :   JSJitInfo::Getter,
     158             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     159             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     160             :   false,  /* isInfallible. False in setters. */
     161             :   true,  /* isMovable.  Not relevant for setters. */
     162             :   true, /* isEliminatable.  Not relevant for setters. */
     163             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     164             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     165             :   false,  /* isTypedMethod.  Only relevant for methods. */
     166             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     167             : };
     168             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     169             : static_assert(0 < 1, "There is no slot for us");
     170             : static const JSJitInfo currentNode_setterinfo = {
     171             :   { (JSJitGetterOp)set_currentNode },
     172             :   { prototypes::id::TreeWalker },
     173             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     174             :   JSJitInfo::Setter,
     175             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     176             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     177             :   false,  /* isInfallible. False in setters. */
     178             :   false,  /* isMovable.  Not relevant for setters. */
     179             :   false, /* isEliminatable.  Not relevant for setters. */
     180             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     181             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     182             :   false,  /* isTypedMethod.  Only relevant for methods. */
     183             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     184             : };
     185             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     186             : static_assert(0 < 1, "There is no slot for us");
     187             : 
     188             : static bool
     189           0 : parentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     190             : {
     191           0 :   binding_detail::FastErrorResult rv;
     192           0 :   auto result(StrongOrRawPtr<nsINode>(self->ParentNode(rv)));
     193           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     194           0 :     return false;
     195             :   }
     196           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     197           0 :   if (!result) {
     198           0 :     args.rval().setNull();
     199           0 :     return true;
     200             :   }
     201           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     202           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     203           0 :     return false;
     204             :   }
     205           0 :   return true;
     206             : }
     207             : 
     208             : static const JSJitInfo parentNode_methodinfo = {
     209             :   { (JSJitGetterOp)parentNode },
     210             :   { prototypes::id::TreeWalker },
     211             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     212             :   JSJitInfo::Method,
     213             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     214             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     215             :   false,  /* isInfallible. False in setters. */
     216             :   false,  /* isMovable.  Not relevant for setters. */
     217             :   false, /* isEliminatable.  Not relevant for setters. */
     218             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     219             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     220             :   false,  /* isTypedMethod.  Only relevant for methods. */
     221             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     222             : };
     223             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     224             : static_assert(0 < 1, "There is no slot for us");
     225             : 
     226             : static bool
     227           0 : firstChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     228             : {
     229           0 :   binding_detail::FastErrorResult rv;
     230           0 :   auto result(StrongOrRawPtr<nsINode>(self->FirstChild(rv)));
     231           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     232           0 :     return false;
     233             :   }
     234           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     235           0 :   if (!result) {
     236           0 :     args.rval().setNull();
     237           0 :     return true;
     238             :   }
     239           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     240           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     241           0 :     return false;
     242             :   }
     243           0 :   return true;
     244             : }
     245             : 
     246             : static const JSJitInfo firstChild_methodinfo = {
     247             :   { (JSJitGetterOp)firstChild },
     248             :   { prototypes::id::TreeWalker },
     249             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     250             :   JSJitInfo::Method,
     251             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     252             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     253             :   false,  /* isInfallible. False in setters. */
     254             :   false,  /* isMovable.  Not relevant for setters. */
     255             :   false, /* isEliminatable.  Not relevant for setters. */
     256             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     257             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     258             :   false,  /* isTypedMethod.  Only relevant for methods. */
     259             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     260             : };
     261             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     262             : static_assert(0 < 1, "There is no slot for us");
     263             : 
     264             : static bool
     265           0 : lastChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     266             : {
     267           0 :   binding_detail::FastErrorResult rv;
     268           0 :   auto result(StrongOrRawPtr<nsINode>(self->LastChild(rv)));
     269           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     270           0 :     return false;
     271             :   }
     272           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     273           0 :   if (!result) {
     274           0 :     args.rval().setNull();
     275           0 :     return true;
     276             :   }
     277           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     278           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     279           0 :     return false;
     280             :   }
     281           0 :   return true;
     282             : }
     283             : 
     284             : static const JSJitInfo lastChild_methodinfo = {
     285             :   { (JSJitGetterOp)lastChild },
     286             :   { prototypes::id::TreeWalker },
     287             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     288             :   JSJitInfo::Method,
     289             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     290             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     291             :   false,  /* isInfallible. False in setters. */
     292             :   false,  /* isMovable.  Not relevant for setters. */
     293             :   false, /* isEliminatable.  Not relevant for setters. */
     294             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     295             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     296             :   false,  /* isTypedMethod.  Only relevant for methods. */
     297             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     298             : };
     299             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     300             : static_assert(0 < 1, "There is no slot for us");
     301             : 
     302             : static bool
     303           0 : previousSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     304             : {
     305           0 :   binding_detail::FastErrorResult rv;
     306           0 :   auto result(StrongOrRawPtr<nsINode>(self->PreviousSibling(rv)));
     307           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     308           0 :     return false;
     309             :   }
     310           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     311           0 :   if (!result) {
     312           0 :     args.rval().setNull();
     313           0 :     return true;
     314             :   }
     315           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     316           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     317           0 :     return false;
     318             :   }
     319           0 :   return true;
     320             : }
     321             : 
     322             : static const JSJitInfo previousSibling_methodinfo = {
     323             :   { (JSJitGetterOp)previousSibling },
     324             :   { prototypes::id::TreeWalker },
     325             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     326             :   JSJitInfo::Method,
     327             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     328             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     329             :   false,  /* isInfallible. False in setters. */
     330             :   false,  /* isMovable.  Not relevant for setters. */
     331             :   false, /* isEliminatable.  Not relevant for setters. */
     332             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     333             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     334             :   false,  /* isTypedMethod.  Only relevant for methods. */
     335             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     336             : };
     337             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     338             : static_assert(0 < 1, "There is no slot for us");
     339             : 
     340             : static bool
     341           0 : nextSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     342             : {
     343           0 :   binding_detail::FastErrorResult rv;
     344           0 :   auto result(StrongOrRawPtr<nsINode>(self->NextSibling(rv)));
     345           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     346           0 :     return false;
     347             :   }
     348           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     349           0 :   if (!result) {
     350           0 :     args.rval().setNull();
     351           0 :     return true;
     352             :   }
     353           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     354           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     355           0 :     return false;
     356             :   }
     357           0 :   return true;
     358             : }
     359             : 
     360             : static const JSJitInfo nextSibling_methodinfo = {
     361             :   { (JSJitGetterOp)nextSibling },
     362             :   { prototypes::id::TreeWalker },
     363             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     364             :   JSJitInfo::Method,
     365             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     366             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     367             :   false,  /* isInfallible. False in setters. */
     368             :   false,  /* isMovable.  Not relevant for setters. */
     369             :   false, /* isEliminatable.  Not relevant for setters. */
     370             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     371             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     372             :   false,  /* isTypedMethod.  Only relevant for methods. */
     373             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     374             : };
     375             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     376             : static_assert(0 < 1, "There is no slot for us");
     377             : 
     378             : static bool
     379           0 : previousNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     380             : {
     381           0 :   binding_detail::FastErrorResult rv;
     382           0 :   auto result(StrongOrRawPtr<nsINode>(self->PreviousNode(rv)));
     383           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     384           0 :     return false;
     385             :   }
     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 previousNode_methodinfo = {
     399             :   { (JSJitGetterOp)previousNode },
     400             :   { prototypes::id::TreeWalker },
     401             :   { PrototypeTraits<prototypes::id::TreeWalker>::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 : nextNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args)
     418             : {
     419           0 :   binding_detail::FastErrorResult rv;
     420           0 :   auto result(StrongOrRawPtr<nsINode>(self->NextNode(rv)));
     421           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     422           0 :     return false;
     423             :   }
     424           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     425           0 :   if (!result) {
     426           0 :     args.rval().setNull();
     427           0 :     return true;
     428             :   }
     429           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     430           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     431           0 :     return false;
     432             :   }
     433           0 :   return true;
     434             : }
     435             : 
     436             : static const JSJitInfo nextNode_methodinfo = {
     437             :   { (JSJitGetterOp)nextNode },
     438             :   { prototypes::id::TreeWalker },
     439             :   { PrototypeTraits<prototypes::id::TreeWalker>::Depth },
     440             :   JSJitInfo::Method,
     441             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     442             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     443             :   false,  /* isInfallible. False in setters. */
     444             :   false,  /* isMovable.  Not relevant for setters. */
     445             :   false, /* isEliminatable.  Not relevant for setters. */
     446             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     447             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     448             :   false,  /* isTypedMethod.  Only relevant for methods. */
     449             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     450             : };
     451             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     452             : static_assert(0 < 1, "There is no slot for us");
     453             : 
     454             : static void
     455           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     456             : {
     457           0 :   mozilla::dom::TreeWalker* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TreeWalker>(obj);
     458           0 :   if (self) {
     459           0 :     AddForDeferredFinalization<mozilla::dom::TreeWalker>(self);
     460             :   }
     461           0 : }
     462             : 
     463             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     464             : #if defined(__clang__)
     465             : #pragma clang diagnostic push
     466             : #pragma clang diagnostic ignored "-Wmissing-braces"
     467             : #endif
     468             : static const JSFunctionSpec sMethods_specs[] = {
     469             :   JS_FNSPEC("parentNode", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&parentNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     470             :   JS_FNSPEC("firstChild", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&firstChild_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     471             :   JS_FNSPEC("lastChild", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&lastChild_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     472             :   JS_FNSPEC("previousSibling", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&previousSibling_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     473             :   JS_FNSPEC("nextSibling", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&nextSibling_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     474             :   JS_FNSPEC("previousNode", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&previousNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     475             :   JS_FNSPEC("nextNode", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&nextNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     476             :   JS_FS_END,
     477             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
     478             :   JS_FS_END
     479             : };
     480             : #if defined(__clang__)
     481             : #pragma clang diagnostic pop
     482             : #endif
     483             : 
     484             : static PrefableDisablers sMethods_disablers8 = {
     485             :   true, false, 0, &WantsQueryInterface<mozilla::dom::TreeWalker>::Enabled
     486             : };
     487             : 
     488             : // Can't be const because the pref-enabled boolean needs to be writable
     489             : static Prefable<const JSFunctionSpec> sMethods[] = {
     490             :   { nullptr, &sMethods_specs[0] },
     491             :   { &sMethods_disablers8, &sMethods_specs[8] },
     492             :   { nullptr, nullptr }
     493             : };
     494             : 
     495             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     496             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     497             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     498             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     499             : 
     500             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     501             : #if defined(__clang__)
     502             : #pragma clang diagnostic push
     503             : #pragma clang diagnostic ignored "-Wmissing-braces"
     504             : #endif
     505             : static const JSPropertySpec sAttributes_specs[] = {
     506             :   { "root", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &root_getterinfo, nullptr, nullptr },
     507             :   { "whatToShow", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &whatToShow_getterinfo, nullptr, nullptr },
     508             :   { "filter", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &filter_getterinfo, nullptr, nullptr },
     509             :   { "currentNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &currentNode_getterinfo, GenericBindingSetter, &currentNode_setterinfo },
     510             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     511             : };
     512             : #if defined(__clang__)
     513             : #pragma clang diagnostic pop
     514             : #endif
     515             : 
     516             : 
     517             : // Can't be const because the pref-enabled boolean needs to be writable
     518             : static Prefable<const JSPropertySpec> sAttributes[] = {
     519             :   { nullptr, &sAttributes_specs[0] },
     520             :   { nullptr, nullptr }
     521             : };
     522             : 
     523             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     524             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     525             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     526             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     527             : 
     528             : 
     529             : static uint16_t sNativeProperties_sortedPropertyIndices[12];
     530             : static PropertyInfo sNativeProperties_propertyInfos[12];
     531             : 
     532             : static const NativePropertiesN<2> sNativeProperties = {
     533             :   false, 0,
     534             :   false, 0,
     535             :   true,  0 /* sMethods */,
     536             :   true,  1 /* sAttributes */,
     537             :   false, 0,
     538             :   false, 0,
     539             :   false, 0,
     540             :   -1,
     541             :   12,
     542             :   sNativeProperties_sortedPropertyIndices,
     543             :   {
     544             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     545             :     { sAttributes, &sNativeProperties_propertyInfos[8] }
     546             :   }
     547             : };
     548             : static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     549             :     "We have a property info count that is oversized");
     550             : 
     551             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     552             :   {
     553             :     "Function",
     554             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     555             :     &sBoringInterfaceObjectClassClassOps,
     556             :     JS_NULL_CLASS_SPEC,
     557             :     JS_NULL_CLASS_EXT,
     558             :     &sInterfaceObjectClassObjectOps
     559             :   },
     560             :   eInterface,
     561             :   true,
     562             :   prototypes::id::TreeWalker,
     563             :   PrototypeTraits<prototypes::id::TreeWalker>::Depth,
     564             :   sNativePropertyHooks,
     565             :   "function TreeWalker() {\n    [native code]\n}",
     566             :   JS::GetRealmFunctionPrototype
     567             : };
     568             : 
     569             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     570             :   {
     571             :     "TreeWalkerPrototype",
     572             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     573             :     JS_NULL_CLASS_OPS,
     574             :     JS_NULL_CLASS_SPEC,
     575             :     JS_NULL_CLASS_EXT,
     576             :     JS_NULL_OBJECT_OPS
     577             :   },
     578             :   eInterfacePrototype,
     579             :   false,
     580             :   prototypes::id::TreeWalker,
     581             :   PrototypeTraits<prototypes::id::TreeWalker>::Depth,
     582             :   sNativePropertyHooks,
     583             :   "[object TreeWalkerPrototype]",
     584             :   JS::GetRealmObjectPrototype
     585             : };
     586             : 
     587             : JSObject*
     588           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     589             : {
     590           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     591             : }
     592             : 
     593             : static const js::ClassOps sClassOps = {
     594             :   nullptr, /* addProperty */
     595             :   nullptr,               /* delProperty */
     596             :   nullptr,               /* getProperty */
     597             :   nullptr,               /* setProperty */
     598             :   nullptr,               /* enumerate */
     599             :   nullptr, /* newEnumerate */
     600             :   nullptr, /* resolve */
     601             :   nullptr, /* mayResolve */
     602             :   _finalize, /* finalize */
     603             :   nullptr, /* call */
     604             :   nullptr,               /* hasInstance */
     605             :   nullptr,               /* construct */
     606             :   nullptr, /* trace */
     607             : };
     608             : 
     609             : static const js::ClassExtension sClassExtension = {
     610             :   nullptr, /* weakmapKeyDelegateOp */
     611             :   nullptr /* objectMovedOp */
     612             : };
     613             : 
     614             : static const DOMJSClass sClass = {
     615             :   { "TreeWalker",
     616             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     617             :     &sClassOps,
     618             :     JS_NULL_CLASS_SPEC,
     619             :     &sClassExtension,
     620             :     JS_NULL_OBJECT_OPS
     621             :   },
     622             :   { prototypes::id::TreeWalker, 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 },
     623             :   IsBaseOf<nsISupports, mozilla::dom::TreeWalker >::value,
     624             :   sNativePropertyHooks,
     625             :   FindAssociatedGlobalForNative<mozilla::dom::TreeWalker>::Get,
     626             :   GetProtoObjectHandle,
     627             :   GetCCParticipant<mozilla::dom::TreeWalker>::Get()
     628             : };
     629             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     630             :               "Must have the right minimal number of reserved slots.");
     631             : static_assert(1 >= 1,
     632             :               "Must have enough reserved slots.");
     633             : 
     634             : const JSClass*
     635           0 : GetJSClass()
     636             : {
     637           0 :   return sClass.ToJSClass();
     638             : }
     639             : 
     640             : bool
     641           0 : Wrap(JSContext* aCx, mozilla::dom::TreeWalker* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     642             : {
     643             :   MOZ_ASSERT(static_cast<mozilla::dom::TreeWalker*>(aObject) ==
     644             :              reinterpret_cast<mozilla::dom::TreeWalker*>(aObject),
     645             :              "Multiple inheritance for mozilla::dom::TreeWalker is broken.");
     646           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     647           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     648             : 
     649           0 :   JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
     650           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     651           0 :   if (!canonicalProto) {
     652           0 :     return false;
     653             :   }
     654           0 :   JS::Rooted<JSObject*> proto(aCx);
     655           0 :   if (aGivenProto) {
     656           0 :     proto = aGivenProto;
     657             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     658             :     // coming in, we changed compartments to that of "parent" so may need
     659             :     // to wrap the proto here.
     660           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     661           0 :       if (!JS_WrapObject(aCx, &proto)) {
     662           0 :         return false;
     663             :       }
     664             :     }
     665             :   } else {
     666           0 :     proto = canonicalProto;
     667             :   }
     668             : 
     669           0 :   BindingJSObjectCreator<mozilla::dom::TreeWalker> creator(aCx);
     670           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     671           0 :   if (!aReflector) {
     672           0 :     return false;
     673             :   }
     674             : 
     675             : 
     676             : 
     677           0 :   creator.InitializationSucceeded();
     678           0 :   return true;
     679             : }
     680             : 
     681             : const NativePropertyHooks sNativePropertyHooks[] = { {
     682             :   nullptr,
     683             :   nullptr,
     684             :   nullptr,
     685             :   { sNativeProperties.Upcast(), nullptr },
     686             :   prototypes::id::TreeWalker,
     687             :   constructors::id::TreeWalker,
     688             :   nullptr,
     689             :   &DefaultXrayExpandoObjectClass
     690             : } };
     691             : 
     692             : void
     693           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     694             : {
     695           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     696           0 :   if (!parentProto) {
     697           0 :     return;
     698             :   }
     699             : 
     700           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     701           0 :   if (!constructorProto) {
     702           0 :     return;
     703             :   }
     704             : 
     705             :   static bool sIdsInited = false;
     706           0 :   if (!sIdsInited && NS_IsMainThread()) {
     707           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     708           0 :       return;
     709             :     }
     710           0 :     sIdsInited = true;
     711             :   }
     712             : 
     713           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TreeWalker);
     714           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TreeWalker);
     715           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     716             :                               &sPrototypeClass.mBase, protoCache,
     717             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     718             :                               interfaceCache,
     719             :                               sNativeProperties.Upcast(),
     720             :                               nullptr,
     721             :                               "TreeWalker", aDefineOnGlobal,
     722             :                               nullptr,
     723           0 :                               false);
     724             : }
     725             : 
     726             : JS::Handle<JSObject*>
     727           0 : GetProtoObjectHandle(JSContext* aCx)
     728             : {
     729             :   /* Get the interface prototype object for this class.  This will create the
     730             :      object as needed. */
     731           0 :   bool aDefineOnGlobal = true;
     732             : 
     733             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     734           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     735           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     736           0 :     return nullptr;
     737             :   }
     738             : 
     739             :   /* Check to see whether the interface objects are already installed */
     740           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     741           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::TreeWalker)) {
     742           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     743           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     744             :   }
     745             : 
     746             :   /*
     747             :    * The object might _still_ be null, but that's OK.
     748             :    *
     749             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     750             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     751             :    * changed after they have been set.
     752             :    *
     753             :    * Calling address() avoids the read read barrier that does gray
     754             :    * unmarking, but it's not possible for the object to be gray here.
     755             :    */
     756             : 
     757           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::TreeWalker);
     758           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     759           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     760             : }
     761             : 
     762             : JS::Handle<JSObject*>
     763           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     764             : {
     765             :   /* Get the interface object for this class.  This will create the object as
     766             :      needed. */
     767             : 
     768             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     769           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     770           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     771           0 :     return nullptr;
     772             :   }
     773             : 
     774             :   /* Check to see whether the interface objects are already installed */
     775           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     776           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::TreeWalker)) {
     777           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     778           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     779             :   }
     780             : 
     781             :   /*
     782             :    * The object might _still_ be null, but that's OK.
     783             :    *
     784             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     785             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     786             :    * changed after they have been set.
     787             :    *
     788             :    * Calling address() avoids the read read barrier that does gray
     789             :    * unmarking, but it's not possible for the object to be gray here.
     790             :    */
     791             : 
     792           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::TreeWalker);
     793           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     794           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     795             : }
     796             : 
     797             : JSObject*
     798           0 : GetConstructorObject(JSContext* aCx)
     799             : {
     800           0 :   return GetConstructorObjectHandle(aCx);
     801             : }
     802             : 
     803             : } // namespace TreeWalkerBinding
     804             : 
     805             : 
     806             : 
     807             : } // namespace dom
     808             : } // namespace mozilla

Generated by: LCOV version 1.13