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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM CanvasRenderingContext2D.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "CanvasPath.h"
       5             : #include "CanvasRenderingContext2DBinding.h"
       6             : #include "CanvasUtils.h"
       7             : #include "WrapperFactory.h"
       8             : #include "jsapi.h"
       9             : #include "mozilla/FloatingPoint.h"
      10             : #include "mozilla/OwningNonNull.h"
      11             : #include "mozilla/Preferences.h"
      12             : #include "mozilla/dom/BindingUtils.h"
      13             : #include "mozilla/dom/CanvasGradient.h"
      14             : #include "mozilla/dom/CanvasPattern.h"
      15             : #include "mozilla/dom/CanvasRenderingContext2D.h"
      16             : #include "mozilla/dom/DOMJSClass.h"
      17             : #include "mozilla/dom/Element.h"
      18             : #include "mozilla/dom/HTMLCanvasElement.h"
      19             : #include "mozilla/dom/HTMLImageElement.h"
      20             : #include "mozilla/dom/HTMLVideoElement.h"
      21             : #include "mozilla/dom/ImageBitmap.h"
      22             : #include "mozilla/dom/ImageData.h"
      23             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      24             : #include "mozilla/dom/Nullable.h"
      25             : #include "mozilla/dom/PrimitiveConversions.h"
      26             : #include "mozilla/dom/SVGMatrix.h"
      27             : #include "mozilla/dom/ScriptSettings.h"
      28             : #include "mozilla/dom/SimpleGlobalObject.h"
      29             : #include "mozilla/dom/TextMetrics.h"
      30             : #include "mozilla/dom/UnionConversions.h"
      31             : #include "mozilla/dom/XrayExpandoClass.h"
      32             : #include "nsContentUtils.h"
      33             : #include "nsGlobalWindow.h"
      34             : #include "nsIDocument.h"
      35             : 
      36             : namespace mozilla {
      37             : namespace dom {
      38             : 
      39             : namespace CanvasWindingRuleValues {
      40             : extern const EnumEntry strings[3] = {
      41             :   {"nonzero", 7},
      42             :   {"evenodd", 7},
      43             :   { nullptr, 0 }
      44             : };
      45             : } // namespace CanvasWindingRuleValues
      46             : 
      47             : bool
      48           0 : ToJSValue(JSContext* aCx, CanvasWindingRule aArgument, JS::MutableHandle<JS::Value> aValue)
      49             : {
      50           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(CanvasWindingRuleValues::strings));
      51             :   JSString* resultStr =
      52           0 :     JS_NewStringCopyN(aCx, CanvasWindingRuleValues::strings[uint32_t(aArgument)].value,
      53           0 :                       CanvasWindingRuleValues::strings[uint32_t(aArgument)].length);
      54           0 :   if (!resultStr) {
      55           0 :     return false;
      56             :   }
      57           0 :   aValue.setString(resultStr);
      58           0 :   return true;
      59             : }
      60             : 
      61             : 
      62             : void
      63           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aUnion, const char* aName, uint32_t aFlags)
      64             : {
      65           0 :   if (aUnion.IsHTMLImageElement()) {
      66           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLImageElement(), "mHTMLImageElement", aFlags);
      67           0 :   } else if (aUnion.IsHTMLCanvasElement()) {
      68           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLCanvasElement(), "mHTMLCanvasElement", aFlags);
      69           0 :   } else if (aUnion.IsHTMLVideoElement()) {
      70           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLVideoElement(), "mHTMLVideoElement", aFlags);
      71           0 :   } else if (aUnion.IsImageBitmap()) {
      72           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsImageBitmap(), "mImageBitmap", aFlags);
      73             :   }
      74           0 : }
      75             : 
      76             : 
      77             : void
      78           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrCanvasGradientOrCanvasPattern& aUnion, const char* aName, uint32_t aFlags)
      79             : {
      80           0 :   if (aUnion.IsCanvasGradient()) {
      81           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCanvasGradient(), "mCanvasGradient", aFlags);
      82           0 :   } else if (aUnion.IsCanvasPattern()) {
      83           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCanvasPattern(), "mCanvasPattern", aFlags);
      84             :   }
      85           0 : }
      86             : 
      87             : 
      88             : void
      89           0 : ImplCycleCollectionUnlink(OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aUnion)
      90             : {
      91           0 :   aUnion.Uninit();
      92           0 : }
      93             : 
      94             : 
      95             : void
      96           0 : ImplCycleCollectionUnlink(OwningStringOrCanvasGradientOrCanvasPattern& aUnion)
      97             : {
      98           0 :   aUnion.Uninit();
      99           0 : }
     100             : 
     101             : 
     102             : 
     103           0 : ContextAttributes2D::ContextAttributes2D()
     104             : {
     105             :   // Safe to pass a null context if we pass a null value
     106           0 :   Init(nullptr, JS::NullHandleValue);
     107           0 : }
     108             : 
     109             : 
     110             : 
     111             : bool
     112           0 : ContextAttributes2D::InitIds(JSContext* cx, ContextAttributes2DAtoms* atomsCache)
     113             : {
     114           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     115             : 
     116             :   // Initialize these in reverse order so that any failure leaves the first one
     117             :   // uninitialized.
     118           0 :   if (!atomsCache->willReadFrequently_id.init(cx, "willReadFrequently") ||
     119           0 :       !atomsCache->alpha_id.init(cx, "alpha")) {
     120           0 :     return false;
     121             :   }
     122           0 :   return true;
     123             : }
     124             : 
     125             : bool
     126           0 : ContextAttributes2D::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     127             : {
     128             :   // Passing a null JSContext is OK only if we're initing from null,
     129             :   // Since in that case we will not have to do any property gets
     130             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     131             :   // checkers by static analysis tools
     132           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     133           0 :   ContextAttributes2DAtoms* atomsCache = nullptr;
     134           0 :   if (cx) {
     135           0 :     atomsCache = GetAtomCache<ContextAttributes2DAtoms>(cx);
     136           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     137           0 :       return false;
     138             :     }
     139             :   }
     140             : 
     141           0 :   if (!IsConvertibleToDictionary(val)) {
     142           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     143             :   }
     144             : 
     145           0 :   bool isNull = val.isNullOrUndefined();
     146             :   // We only need these if !isNull, in which case we have |cx|.
     147           0 :   Maybe<JS::Rooted<JSObject *> > object;
     148           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     149           0 :   if (!isNull) {
     150           0 :     MOZ_ASSERT(cx);
     151           0 :     object.emplace(cx, &val.toObject());
     152           0 :     temp.emplace(cx);
     153             :   }
     154           0 :   if (!isNull) {
     155           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->alpha_id, temp.ptr())) {
     156           0 :       return false;
     157             :     }
     158             :   }
     159           0 :   if (!isNull && !temp->isUndefined()) {
     160           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAlpha)) {
     161           0 :       return false;
     162             :     }
     163             :   } else {
     164           0 :     mAlpha = true;
     165             :   }
     166           0 :   mIsAnyMemberPresent = true;
     167             : 
     168           0 :   if (!isNull) {
     169           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->willReadFrequently_id, temp.ptr())) {
     170           0 :       return false;
     171             :     }
     172             :   }
     173           0 :   if (!isNull && !temp->isUndefined()) {
     174           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mWillReadFrequently)) {
     175           0 :       return false;
     176             :     }
     177             :   } else {
     178           0 :     mWillReadFrequently = false;
     179             :   }
     180           0 :   mIsAnyMemberPresent = true;
     181           0 :   return true;
     182             : }
     183             : 
     184             : bool
     185           0 : ContextAttributes2D::Init(const nsAString& aJSON)
     186             : {
     187           0 :   AutoJSAPI jsapi;
     188           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     189           0 :   if (!cleanGlobal) {
     190           0 :     return false;
     191             :   }
     192           0 :   if (!jsapi.Init(cleanGlobal)) {
     193           0 :     return false;
     194             :   }
     195           0 :   JSContext* cx = jsapi.cx();
     196           0 :   JS::Rooted<JS::Value> json(cx);
     197           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     198           0 :   NS_ENSURE_TRUE(ok, false);
     199           0 :   return Init(cx, json);
     200             : }
     201             : 
     202             : bool
     203           0 : ContextAttributes2D::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     204             : {
     205           0 :   ContextAttributes2DAtoms* atomsCache = GetAtomCache<ContextAttributes2DAtoms>(cx);
     206           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     207           0 :     return false;
     208             :   }
     209             : 
     210           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     211           0 :   if (!obj) {
     212           0 :     return false;
     213             :   }
     214           0 :   rval.set(JS::ObjectValue(*obj));
     215             : 
     216             :   do {
     217             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     218           0 :     JS::Rooted<JS::Value> temp(cx);
     219           0 :     bool const & currentValue = mAlpha;
     220           0 :     temp.setBoolean(currentValue);
     221           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->alpha_id, temp, JSPROP_ENUMERATE)) {
     222           0 :       return false;
     223             :     }
     224           0 :     break;
     225             :   } while(0);
     226             : 
     227             :   do {
     228             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     229           0 :     JS::Rooted<JS::Value> temp(cx);
     230           0 :     bool const & currentValue = mWillReadFrequently;
     231           0 :     temp.setBoolean(currentValue);
     232           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->willReadFrequently_id, temp, JSPROP_ENUMERATE)) {
     233           0 :       return false;
     234             :     }
     235           0 :     break;
     236             :   } while(0);
     237             : 
     238           0 :   return true;
     239             : }
     240             : 
     241             : bool
     242           0 : ContextAttributes2D::ToJSON(nsAString& aJSON) const
     243             : {
     244           0 :   AutoJSAPI jsapi;
     245           0 :   jsapi.Init();
     246           0 :   JSContext *cx = jsapi.cx();
     247             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     248             :   // because we'll only be creating objects, in ways that have no
     249             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     250             :   // which likewise guarantees no side-effects for the sorts of
     251             :   // things we will pass it.
     252           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     253           0 :   JS::Rooted<JS::Value> val(cx);
     254           0 :   if (!ToObjectInternal(cx, &val)) {
     255           0 :     return false;
     256             :   }
     257           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     258           0 :   return StringifyToJSON(cx, obj, aJSON);
     259             : }
     260             : 
     261             : void
     262           0 : ContextAttributes2D::TraceDictionary(JSTracer* trc)
     263             : {
     264           0 : }
     265             : 
     266             : ContextAttributes2D&
     267           0 : ContextAttributes2D::operator=(const ContextAttributes2D& aOther)
     268             : {
     269           0 :   mAlpha = aOther.mAlpha;
     270           0 :   mWillReadFrequently = aOther.mWillReadFrequently;
     271           0 :   return *this;
     272             : }
     273             : 
     274             : namespace binding_detail {
     275             : } // namespace binding_detail
     276             : 
     277             : 
     278             : bool
     279           0 : HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     280             : {
     281           0 :   switch (mType) {
     282             :     case eUninitialized: {
     283           0 :       return false;
     284             :       break;
     285             :     }
     286             :     case eHTMLImageElement: {
     287           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLImageElement.Value(), rval)) {
     288           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     289           0 :         return false;
     290             :       }
     291           0 :       return true;
     292             :       break;
     293             :     }
     294             :     case eHTMLCanvasElement: {
     295           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) {
     296           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     297           0 :         return false;
     298             :       }
     299           0 :       return true;
     300             :       break;
     301             :     }
     302             :     case eHTMLVideoElement: {
     303           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLVideoElement.Value(), rval)) {
     304           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     305           0 :         return false;
     306             :       }
     307           0 :       return true;
     308             :       break;
     309             :     }
     310             :     case eImageBitmap: {
     311           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mImageBitmap.Value(), rval)) {
     312           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     313           0 :         return false;
     314             :       }
     315           0 :       return true;
     316             :       break;
     317             :     }
     318             :     default: {
     319           0 :       return false;
     320             :       break;
     321             :     }
     322             :   }
     323             : 
     324             :   return false;
     325             : }
     326             : 
     327             : 
     328             : OwningNonNull<mozilla::dom::HTMLImageElement>&
     329           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLImageElement()
     330             : {
     331           0 :   if (mType == eHTMLImageElement) {
     332           0 :     return mValue.mHTMLImageElement.Value();
     333             :   }
     334           0 :   MOZ_ASSERT(mType == eUninitialized);
     335           0 :   mType = eHTMLImageElement;
     336           0 :   return mValue.mHTMLImageElement.SetValue();
     337             : }
     338             : 
     339             : OwningNonNull<mozilla::dom::HTMLImageElement>&
     340           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLImageElement()
     341             : {
     342           0 :   if (mType == eHTMLImageElement) {
     343           0 :     return mValue.mHTMLImageElement.Value();
     344             :   }
     345           0 :   Uninit();
     346           0 :   mType = eHTMLImageElement;
     347           0 :   return mValue.mHTMLImageElement.SetValue();
     348             : }
     349             : 
     350             : bool
     351           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLImageElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     352             : {
     353           0 :   tryNext = false;
     354             :   { // scope for memberSlot
     355           0 :     OwningNonNull<mozilla::dom::HTMLImageElement>& memberSlot = RawSetAsHTMLImageElement();
     356             :     static_assert(IsRefcounted<mozilla::dom::HTMLImageElement>::value, "We can only store refcounted classes.");{
     357           0 :       nsresult rv = UnwrapObject<prototypes::id::HTMLImageElement, mozilla::dom::HTMLImageElement>(value, memberSlot);
     358           0 :       if (NS_FAILED(rv)) {
     359           0 :         DestroyHTMLImageElement();
     360           0 :         tryNext = true;
     361           0 :         return true;
     362             :       }
     363             :     }
     364             :   }
     365           0 :   return true;
     366             : }
     367             : 
     368             : void
     369           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLImageElement()
     370             : {
     371           0 :   MOZ_ASSERT(IsHTMLImageElement(), "Wrong type!");
     372           0 :   mValue.mHTMLImageElement.Destroy();
     373           0 :   mType = eUninitialized;
     374           0 : }
     375             : 
     376             : 
     377             : 
     378             : 
     379             : OwningNonNull<mozilla::dom::HTMLCanvasElement>&
     380           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLCanvasElement()
     381             : {
     382           0 :   if (mType == eHTMLCanvasElement) {
     383           0 :     return mValue.mHTMLCanvasElement.Value();
     384             :   }
     385           0 :   MOZ_ASSERT(mType == eUninitialized);
     386           0 :   mType = eHTMLCanvasElement;
     387           0 :   return mValue.mHTMLCanvasElement.SetValue();
     388             : }
     389             : 
     390             : OwningNonNull<mozilla::dom::HTMLCanvasElement>&
     391           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLCanvasElement()
     392             : {
     393           0 :   if (mType == eHTMLCanvasElement) {
     394           0 :     return mValue.mHTMLCanvasElement.Value();
     395             :   }
     396           0 :   Uninit();
     397           0 :   mType = eHTMLCanvasElement;
     398           0 :   return mValue.mHTMLCanvasElement.SetValue();
     399             : }
     400             : 
     401             : bool
     402           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLCanvasElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     403             : {
     404           0 :   tryNext = false;
     405             :   { // scope for memberSlot
     406           0 :     OwningNonNull<mozilla::dom::HTMLCanvasElement>& memberSlot = RawSetAsHTMLCanvasElement();
     407             :     static_assert(IsRefcounted<mozilla::dom::HTMLCanvasElement>::value, "We can only store refcounted classes.");{
     408           0 :       nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(value, memberSlot);
     409           0 :       if (NS_FAILED(rv)) {
     410           0 :         DestroyHTMLCanvasElement();
     411           0 :         tryNext = true;
     412           0 :         return true;
     413             :       }
     414             :     }
     415             :   }
     416           0 :   return true;
     417             : }
     418             : 
     419             : void
     420           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLCanvasElement()
     421             : {
     422           0 :   MOZ_ASSERT(IsHTMLCanvasElement(), "Wrong type!");
     423           0 :   mValue.mHTMLCanvasElement.Destroy();
     424           0 :   mType = eUninitialized;
     425           0 : }
     426             : 
     427             : 
     428             : 
     429             : 
     430             : OwningNonNull<mozilla::dom::HTMLVideoElement>&
     431           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLVideoElement()
     432             : {
     433           0 :   if (mType == eHTMLVideoElement) {
     434           0 :     return mValue.mHTMLVideoElement.Value();
     435             :   }
     436           0 :   MOZ_ASSERT(mType == eUninitialized);
     437           0 :   mType = eHTMLVideoElement;
     438           0 :   return mValue.mHTMLVideoElement.SetValue();
     439             : }
     440             : 
     441             : OwningNonNull<mozilla::dom::HTMLVideoElement>&
     442           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLVideoElement()
     443             : {
     444           0 :   if (mType == eHTMLVideoElement) {
     445           0 :     return mValue.mHTMLVideoElement.Value();
     446             :   }
     447           0 :   Uninit();
     448           0 :   mType = eHTMLVideoElement;
     449           0 :   return mValue.mHTMLVideoElement.SetValue();
     450             : }
     451             : 
     452             : bool
     453           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLVideoElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     454             : {
     455           0 :   tryNext = false;
     456             :   { // scope for memberSlot
     457           0 :     OwningNonNull<mozilla::dom::HTMLVideoElement>& memberSlot = RawSetAsHTMLVideoElement();
     458             :     static_assert(IsRefcounted<mozilla::dom::HTMLVideoElement>::value, "We can only store refcounted classes.");{
     459           0 :       nsresult rv = UnwrapObject<prototypes::id::HTMLVideoElement, mozilla::dom::HTMLVideoElement>(value, memberSlot);
     460           0 :       if (NS_FAILED(rv)) {
     461           0 :         DestroyHTMLVideoElement();
     462           0 :         tryNext = true;
     463           0 :         return true;
     464             :       }
     465             :     }
     466             :   }
     467           0 :   return true;
     468             : }
     469             : 
     470             : void
     471           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLVideoElement()
     472             : {
     473           0 :   MOZ_ASSERT(IsHTMLVideoElement(), "Wrong type!");
     474           0 :   mValue.mHTMLVideoElement.Destroy();
     475           0 :   mType = eUninitialized;
     476           0 : }
     477             : 
     478             : 
     479             : 
     480             : 
     481             : OwningNonNull<mozilla::dom::ImageBitmap>&
     482           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsImageBitmap()
     483             : {
     484           0 :   if (mType == eImageBitmap) {
     485           0 :     return mValue.mImageBitmap.Value();
     486             :   }
     487           0 :   MOZ_ASSERT(mType == eUninitialized);
     488           0 :   mType = eImageBitmap;
     489           0 :   return mValue.mImageBitmap.SetValue();
     490             : }
     491             : 
     492             : OwningNonNull<mozilla::dom::ImageBitmap>&
     493           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsImageBitmap()
     494             : {
     495           0 :   if (mType == eImageBitmap) {
     496           0 :     return mValue.mImageBitmap.Value();
     497             :   }
     498           0 :   Uninit();
     499           0 :   mType = eImageBitmap;
     500           0 :   return mValue.mImageBitmap.SetValue();
     501             : }
     502             : 
     503             : bool
     504           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToImageBitmap(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     505             : {
     506           0 :   tryNext = false;
     507             :   { // scope for memberSlot
     508           0 :     OwningNonNull<mozilla::dom::ImageBitmap>& memberSlot = RawSetAsImageBitmap();
     509             :     static_assert(IsRefcounted<mozilla::dom::ImageBitmap>::value, "We can only store refcounted classes.");{
     510           0 :       nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(value, memberSlot);
     511           0 :       if (NS_FAILED(rv)) {
     512           0 :         DestroyImageBitmap();
     513           0 :         tryNext = true;
     514           0 :         return true;
     515             :       }
     516             :     }
     517             :   }
     518           0 :   return true;
     519             : }
     520             : 
     521             : void
     522           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyImageBitmap()
     523             : {
     524           0 :   MOZ_ASSERT(IsImageBitmap(), "Wrong type!");
     525           0 :   mValue.mImageBitmap.Destroy();
     526           0 :   mType = eUninitialized;
     527           0 : }
     528             : 
     529             : 
     530             : 
     531             : 
     532             : void
     533           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::Uninit()
     534             : {
     535           0 :   switch (mType) {
     536             :     case eUninitialized: {
     537           0 :       break;
     538             :     }
     539             :     case eHTMLImageElement: {
     540           0 :       DestroyHTMLImageElement();
     541           0 :       break;
     542             :     }
     543             :     case eHTMLCanvasElement: {
     544           0 :       DestroyHTMLCanvasElement();
     545           0 :       break;
     546             :     }
     547             :     case eHTMLVideoElement: {
     548           0 :       DestroyHTMLVideoElement();
     549           0 :       break;
     550             :     }
     551             :     case eImageBitmap: {
     552           0 :       DestroyImageBitmap();
     553           0 :       break;
     554             :     }
     555             :   }
     556           0 : }
     557             : 
     558             : bool
     559           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     560             : {
     561           0 :   switch (mType) {
     562             :     case eUninitialized: {
     563           0 :       return false;
     564             :       break;
     565             :     }
     566             :     case eHTMLImageElement: {
     567           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLImageElement.Value(), rval)) {
     568           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     569           0 :         return false;
     570             :       }
     571           0 :       return true;
     572             :       break;
     573             :     }
     574             :     case eHTMLCanvasElement: {
     575           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) {
     576           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     577           0 :         return false;
     578             :       }
     579           0 :       return true;
     580             :       break;
     581             :     }
     582             :     case eHTMLVideoElement: {
     583           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mHTMLVideoElement.Value(), rval)) {
     584           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     585           0 :         return false;
     586             :       }
     587           0 :       return true;
     588             :       break;
     589             :     }
     590             :     case eImageBitmap: {
     591           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mImageBitmap.Value(), rval)) {
     592           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     593           0 :         return false;
     594             :       }
     595           0 :       return true;
     596             :       break;
     597             :     }
     598             :     default: {
     599           0 :       return false;
     600             :       break;
     601             :     }
     602             :   }
     603             : 
     604             :   return false;
     605             : }
     606             : 
     607             : void
     608           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TraceUnion(JSTracer* trc)
     609             : {
     610           0 : }
     611             : 
     612             : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap&
     613           0 : OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::operator=(const OwningHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aOther)
     614             : {
     615           0 :   switch (aOther.mType) {
     616             :     case eUninitialized: {
     617           0 :       MOZ_ASSERT(mType == eUninitialized,
     618             :                  "We need to destroy ourselves?");
     619           0 :       break;
     620             :     }
     621             :     case eHTMLImageElement: {
     622           0 :       SetAsHTMLImageElement() = aOther.GetAsHTMLImageElement();
     623           0 :       break;
     624             :     }
     625             :     case eHTMLCanvasElement: {
     626           0 :       SetAsHTMLCanvasElement() = aOther.GetAsHTMLCanvasElement();
     627           0 :       break;
     628             :     }
     629             :     case eHTMLVideoElement: {
     630           0 :       SetAsHTMLVideoElement() = aOther.GetAsHTMLVideoElement();
     631           0 :       break;
     632             :     }
     633             :     case eImageBitmap: {
     634           0 :       SetAsImageBitmap() = aOther.GetAsImageBitmap();
     635           0 :       break;
     636             :     }
     637             :   }
     638           0 :   return *this;
     639             : }
     640             : 
     641             : 
     642             : 
     643           0 : HitRegionOptions::HitRegionOptions()
     644             : {
     645             :   // Safe to pass a null context if we pass a null value
     646           0 :   Init(nullptr, JS::NullHandleValue);
     647           0 : }
     648             : 
     649             : 
     650             : 
     651             : bool
     652           0 : HitRegionOptions::InitIds(JSContext* cx, HitRegionOptionsAtoms* atomsCache)
     653             : {
     654           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     655             : 
     656             :   // Initialize these in reverse order so that any failure leaves the first one
     657             :   // uninitialized.
     658           0 :   if (!atomsCache->path_id.init(cx, "path") ||
     659           0 :       !atomsCache->id_id.init(cx, "id") ||
     660           0 :       !atomsCache->control_id.init(cx, "control")) {
     661           0 :     return false;
     662             :   }
     663           0 :   return true;
     664             : }
     665             : 
     666             : bool
     667           0 : HitRegionOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     668             : {
     669             :   // Passing a null JSContext is OK only if we're initing from null,
     670             :   // Since in that case we will not have to do any property gets
     671             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     672             :   // checkers by static analysis tools
     673           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     674           0 :   HitRegionOptionsAtoms* atomsCache = nullptr;
     675           0 :   if (cx) {
     676           0 :     atomsCache = GetAtomCache<HitRegionOptionsAtoms>(cx);
     677           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     678           0 :       return false;
     679             :     }
     680             :   }
     681             : 
     682           0 :   if (!IsConvertibleToDictionary(val)) {
     683           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     684             :   }
     685             : 
     686           0 :   bool isNull = val.isNullOrUndefined();
     687             :   // We only need these if !isNull, in which case we have |cx|.
     688           0 :   Maybe<JS::Rooted<JSObject *> > object;
     689           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     690           0 :   if (!isNull) {
     691           0 :     MOZ_ASSERT(cx);
     692           0 :     object.emplace(cx, &val.toObject());
     693           0 :     temp.emplace(cx);
     694             :   }
     695           0 :   if (!isNull) {
     696           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->control_id, temp.ptr())) {
     697           0 :       return false;
     698             :     }
     699             :   }
     700           0 :   if (!isNull && !temp->isUndefined()) {
     701           0 :     if (temp.ref().isObject()) {
     702             :       static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");{
     703           0 :         nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(temp.ptr(), mControl);
     704           0 :         if (NS_FAILED(rv)) {
     705           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'control' member of HitRegionOptions", "Element");
     706           0 :           return false;
     707             :         }
     708             :       }
     709           0 :     } else if (temp.ref().isNullOrUndefined()) {
     710           0 :       mControl = nullptr;
     711             :     } else {
     712           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'control' member of HitRegionOptions");
     713           0 :       return false;
     714             :     }
     715             :   } else {
     716           0 :     mControl = nullptr;
     717             :   }
     718           0 :   mIsAnyMemberPresent = true;
     719             : 
     720           0 :   if (!isNull) {
     721           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->id_id, temp.ptr())) {
     722           0 :       return false;
     723             :     }
     724             :   }
     725           0 :   if (!isNull && !temp->isUndefined()) {
     726           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mId)) {
     727           0 :       return false;
     728             :     }
     729             :   } else {
     730             :     static const char16_t data[] = { 0 };
     731           0 :     mId.Rebind(data, ArrayLength(data) - 1);
     732             :   }
     733           0 :   mIsAnyMemberPresent = true;
     734             : 
     735           0 :   if (!isNull) {
     736           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->path_id, temp.ptr())) {
     737           0 :       return false;
     738             :     }
     739             :   }
     740           0 :   if (!isNull && !temp->isUndefined()) {
     741           0 :     if (temp.ref().isObject()) {
     742             :       static_assert(IsRefcounted<mozilla::dom::CanvasPath>::value, "We can only store refcounted classes.");{
     743           0 :         nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(temp.ptr(), mPath);
     744           0 :         if (NS_FAILED(rv)) {
     745           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'path' member of HitRegionOptions", "Path2D");
     746           0 :           return false;
     747             :         }
     748             :       }
     749           0 :     } else if (temp.ref().isNullOrUndefined()) {
     750           0 :       mPath = nullptr;
     751             :     } else {
     752           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'path' member of HitRegionOptions");
     753           0 :       return false;
     754             :     }
     755             :   } else {
     756           0 :     mPath = nullptr;
     757             :   }
     758           0 :   mIsAnyMemberPresent = true;
     759           0 :   return true;
     760             : }
     761             : 
     762             : bool
     763           0 : HitRegionOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     764             : {
     765           0 :   HitRegionOptionsAtoms* atomsCache = GetAtomCache<HitRegionOptionsAtoms>(cx);
     766           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     767           0 :     return false;
     768             :   }
     769             : 
     770           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     771           0 :   if (!obj) {
     772           0 :     return false;
     773             :   }
     774           0 :   rval.set(JS::ObjectValue(*obj));
     775             : 
     776             :   do {
     777             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     778           0 :     JS::Rooted<JS::Value> temp(cx);
     779           0 :     RefPtr<mozilla::dom::Element> const & currentValue = mControl;
     780           0 :     if (!currentValue) {
     781           0 :       temp.setNull();
     782           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->control_id, temp, JSPROP_ENUMERATE)) {
     783           0 :         return false;
     784             :       }
     785           0 :       break;
     786             :     }
     787           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     788           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     789           0 :       return false;
     790             :     }
     791           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->control_id, temp, JSPROP_ENUMERATE)) {
     792           0 :       return false;
     793             :     }
     794           0 :     break;
     795             :   } while(0);
     796             : 
     797             :   do {
     798             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     799           0 :     JS::Rooted<JS::Value> temp(cx);
     800           0 :     nsString const & currentValue = mId;
     801           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     802           0 :       return false;
     803             :     }
     804           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->id_id, temp, JSPROP_ENUMERATE)) {
     805           0 :       return false;
     806             :     }
     807           0 :     break;
     808             :   } while(0);
     809             : 
     810             :   do {
     811             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     812           0 :     JS::Rooted<JS::Value> temp(cx);
     813           0 :     RefPtr<mozilla::dom::CanvasPath> const & currentValue = mPath;
     814           0 :     if (!currentValue) {
     815           0 :       temp.setNull();
     816           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
     817           0 :         return false;
     818             :       }
     819           0 :       break;
     820             :     }
     821           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     822           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     823           0 :       return false;
     824             :     }
     825           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
     826           0 :       return false;
     827             :     }
     828           0 :     break;
     829             :   } while(0);
     830             : 
     831           0 :   return true;
     832             : }
     833             : 
     834             : void
     835           0 : HitRegionOptions::TraceDictionary(JSTracer* trc)
     836             : {
     837           0 : }
     838             : 
     839             : HitRegionOptions&
     840           0 : HitRegionOptions::operator=(const HitRegionOptions& aOther)
     841             : {
     842           0 :   mControl = aOther.mControl;
     843           0 :   mId = aOther.mId;
     844           0 :   mPath = aOther.mPath;
     845           0 :   return *this;
     846             : }
     847             : 
     848             : namespace binding_detail {
     849             : } // namespace binding_detail
     850             : 
     851             : 
     852             : bool
     853           0 : StringOrCanvasGradientOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     854             : {
     855           0 :   switch (mType) {
     856             :     case eUninitialized: {
     857           0 :       return false;
     858             :       break;
     859             :     }
     860             :     case eString: {
     861           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
     862           0 :         return false;
     863             :       }
     864           0 :       return true;
     865             :       break;
     866             :     }
     867             :     case eCanvasGradient: {
     868           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCanvasGradient.Value(), rval)) {
     869           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     870           0 :         return false;
     871             :       }
     872           0 :       return true;
     873             :       break;
     874             :     }
     875             :     case eCanvasPattern: {
     876           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
     877           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     878           0 :         return false;
     879             :       }
     880           0 :       return true;
     881             :       break;
     882             :     }
     883             :     default: {
     884           0 :       return false;
     885             :       break;
     886             :     }
     887             :   }
     888             : 
     889             :   return false;
     890             : }
     891             : 
     892             : 
     893             : nsString&
     894           0 : OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsString()
     895             : {
     896           0 :   if (mType == eString) {
     897           0 :     return mValue.mString.Value();
     898             :   }
     899           0 :   MOZ_ASSERT(mType == eUninitialized);
     900           0 :   mType = eString;
     901           0 :   return mValue.mString.SetValue();
     902             : }
     903             : 
     904             : nsString&
     905           0 : OwningStringOrCanvasGradientOrCanvasPattern::SetAsString()
     906             : {
     907           0 :   if (mType == eString) {
     908           0 :     return mValue.mString.Value();
     909             :   }
     910           0 :   Uninit();
     911           0 :   mType = eString;
     912           0 :   return mValue.mString.SetValue();
     913             : }
     914             : 
     915             : bool
     916           0 : OwningStringOrCanvasGradientOrCanvasPattern::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     917             : {
     918           0 :   tryNext = false;
     919             :   { // scope for memberSlot
     920           0 :     nsString& memberSlot = RawSetAsString();
     921           0 :     if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
     922           0 :       return false;
     923             :     }
     924             :   }
     925           0 :   return true;
     926             : }
     927             : 
     928             : 
     929             : void
     930           0 : OwningStringOrCanvasGradientOrCanvasPattern::DestroyString()
     931             : {
     932           0 :   MOZ_ASSERT(IsString(), "Wrong type!");
     933           0 :   mValue.mString.Destroy();
     934           0 :   mType = eUninitialized;
     935           0 : }
     936             : 
     937             : 
     938             : 
     939             : 
     940             : OwningNonNull<mozilla::dom::CanvasGradient>&
     941           0 : OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsCanvasGradient()
     942             : {
     943           0 :   if (mType == eCanvasGradient) {
     944           0 :     return mValue.mCanvasGradient.Value();
     945             :   }
     946           0 :   MOZ_ASSERT(mType == eUninitialized);
     947           0 :   mType = eCanvasGradient;
     948           0 :   return mValue.mCanvasGradient.SetValue();
     949             : }
     950             : 
     951             : OwningNonNull<mozilla::dom::CanvasGradient>&
     952           0 : OwningStringOrCanvasGradientOrCanvasPattern::SetAsCanvasGradient()
     953             : {
     954           0 :   if (mType == eCanvasGradient) {
     955           0 :     return mValue.mCanvasGradient.Value();
     956             :   }
     957           0 :   Uninit();
     958           0 :   mType = eCanvasGradient;
     959           0 :   return mValue.mCanvasGradient.SetValue();
     960             : }
     961             : 
     962             : bool
     963           0 : OwningStringOrCanvasGradientOrCanvasPattern::TrySetToCanvasGradient(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     964             : {
     965           0 :   tryNext = false;
     966             :   { // scope for memberSlot
     967           0 :     OwningNonNull<mozilla::dom::CanvasGradient>& memberSlot = RawSetAsCanvasGradient();
     968             :     static_assert(IsRefcounted<mozilla::dom::CanvasGradient>::value, "We can only store refcounted classes.");{
     969           0 :       nsresult rv = UnwrapObject<prototypes::id::CanvasGradient, mozilla::dom::CanvasGradient>(value, memberSlot);
     970           0 :       if (NS_FAILED(rv)) {
     971           0 :         DestroyCanvasGradient();
     972           0 :         tryNext = true;
     973           0 :         return true;
     974             :       }
     975             :     }
     976             :   }
     977           0 :   return true;
     978             : }
     979             : 
     980             : void
     981           0 : OwningStringOrCanvasGradientOrCanvasPattern::DestroyCanvasGradient()
     982             : {
     983           0 :   MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
     984           0 :   mValue.mCanvasGradient.Destroy();
     985           0 :   mType = eUninitialized;
     986           0 : }
     987             : 
     988             : 
     989             : 
     990             : 
     991             : OwningNonNull<mozilla::dom::CanvasPattern>&
     992           0 : OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsCanvasPattern()
     993             : {
     994           0 :   if (mType == eCanvasPattern) {
     995           0 :     return mValue.mCanvasPattern.Value();
     996             :   }
     997           0 :   MOZ_ASSERT(mType == eUninitialized);
     998           0 :   mType = eCanvasPattern;
     999           0 :   return mValue.mCanvasPattern.SetValue();
    1000             : }
    1001             : 
    1002             : OwningNonNull<mozilla::dom::CanvasPattern>&
    1003           0 : OwningStringOrCanvasGradientOrCanvasPattern::SetAsCanvasPattern()
    1004             : {
    1005           0 :   if (mType == eCanvasPattern) {
    1006           0 :     return mValue.mCanvasPattern.Value();
    1007             :   }
    1008           0 :   Uninit();
    1009           0 :   mType = eCanvasPattern;
    1010           0 :   return mValue.mCanvasPattern.SetValue();
    1011             : }
    1012             : 
    1013             : bool
    1014           0 : OwningStringOrCanvasGradientOrCanvasPattern::TrySetToCanvasPattern(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
    1015             : {
    1016           0 :   tryNext = false;
    1017             :   { // scope for memberSlot
    1018           0 :     OwningNonNull<mozilla::dom::CanvasPattern>& memberSlot = RawSetAsCanvasPattern();
    1019             :     static_assert(IsRefcounted<mozilla::dom::CanvasPattern>::value, "We can only store refcounted classes.");{
    1020           0 :       nsresult rv = UnwrapObject<prototypes::id::CanvasPattern, mozilla::dom::CanvasPattern>(value, memberSlot);
    1021           0 :       if (NS_FAILED(rv)) {
    1022           0 :         DestroyCanvasPattern();
    1023           0 :         tryNext = true;
    1024           0 :         return true;
    1025             :       }
    1026             :     }
    1027             :   }
    1028           0 :   return true;
    1029             : }
    1030             : 
    1031             : void
    1032           0 : OwningStringOrCanvasGradientOrCanvasPattern::DestroyCanvasPattern()
    1033             : {
    1034           0 :   MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
    1035           0 :   mValue.mCanvasPattern.Destroy();
    1036           0 :   mType = eUninitialized;
    1037           0 : }
    1038             : 
    1039             : 
    1040             : 
    1041             : 
    1042             : void
    1043           0 : OwningStringOrCanvasGradientOrCanvasPattern::Uninit()
    1044             : {
    1045           0 :   switch (mType) {
    1046             :     case eUninitialized: {
    1047           0 :       break;
    1048             :     }
    1049             :     case eString: {
    1050           0 :       DestroyString();
    1051           0 :       break;
    1052             :     }
    1053             :     case eCanvasGradient: {
    1054           0 :       DestroyCanvasGradient();
    1055           0 :       break;
    1056             :     }
    1057             :     case eCanvasPattern: {
    1058           0 :       DestroyCanvasPattern();
    1059           0 :       break;
    1060             :     }
    1061             :   }
    1062           0 : }
    1063             : 
    1064             : bool
    1065           0 : OwningStringOrCanvasGradientOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
    1066             : {
    1067           0 :   switch (mType) {
    1068             :     case eUninitialized: {
    1069           0 :       return false;
    1070             :       break;
    1071             :     }
    1072             :     case eString: {
    1073           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
    1074           0 :         return false;
    1075             :       }
    1076           0 :       return true;
    1077             :       break;
    1078             :     }
    1079             :     case eCanvasGradient: {
    1080           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCanvasGradient.Value(), rval)) {
    1081           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1082           0 :         return false;
    1083             :       }
    1084           0 :       return true;
    1085             :       break;
    1086             :     }
    1087             :     case eCanvasPattern: {
    1088           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
    1089           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1090           0 :         return false;
    1091             :       }
    1092           0 :       return true;
    1093             :       break;
    1094             :     }
    1095             :     default: {
    1096           0 :       return false;
    1097             :       break;
    1098             :     }
    1099             :   }
    1100             : 
    1101             :   return false;
    1102             : }
    1103             : 
    1104             : void
    1105           0 : OwningStringOrCanvasGradientOrCanvasPattern::TraceUnion(JSTracer* trc)
    1106             : {
    1107           0 : }
    1108             : 
    1109             : OwningStringOrCanvasGradientOrCanvasPattern&
    1110           0 : OwningStringOrCanvasGradientOrCanvasPattern::operator=(const OwningStringOrCanvasGradientOrCanvasPattern& aOther)
    1111             : {
    1112           0 :   switch (aOther.mType) {
    1113             :     case eUninitialized: {
    1114           0 :       MOZ_ASSERT(mType == eUninitialized,
    1115             :                  "We need to destroy ourselves?");
    1116           0 :       break;
    1117             :     }
    1118             :     case eString: {
    1119           0 :       SetAsString() = aOther.GetAsString();
    1120           0 :       break;
    1121             :     }
    1122             :     case eCanvasGradient: {
    1123           0 :       SetAsCanvasGradient() = aOther.GetAsCanvasGradient();
    1124           0 :       break;
    1125             :     }
    1126             :     case eCanvasPattern: {
    1127           0 :       SetAsCanvasPattern() = aOther.GetAsCanvasPattern();
    1128           0 :       break;
    1129             :     }
    1130             :   }
    1131           0 :   return *this;
    1132             : }
    1133             : 
    1134             : 
    1135             : namespace CanvasGradientBinding {
    1136             : 
    1137             : static bool
    1138           0 : addColorStop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasGradient* self, const JSJitMethodCallArgs& args)
    1139             : {
    1140           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    1141           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasGradient.addColorStop");
    1142             :   }
    1143             :   float arg0;
    1144           0 :   if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
    1145           0 :     return false;
    1146           0 :   } else if (!mozilla::IsFinite(arg0)) {
    1147           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasGradient.addColorStop");
    1148           0 :     return false;
    1149             :   }
    1150           0 :   binding_detail::FakeString arg1;
    1151           0 :   if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
    1152           0 :     return false;
    1153             :   }
    1154           0 :   binding_detail::FastErrorResult rv;
    1155           0 :   self->AddColorStop(arg0, NonNullHelper(Constify(arg1)), rv);
    1156           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1157           0 :     return false;
    1158             :   }
    1159           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1160           0 :   args.rval().setUndefined();
    1161           0 :   return true;
    1162             : }
    1163             : 
    1164             : static const JSJitInfo addColorStop_methodinfo = {
    1165             :   { (JSJitGetterOp)addColorStop },
    1166             :   { prototypes::id::CanvasGradient },
    1167             :   { PrototypeTraits<prototypes::id::CanvasGradient>::Depth },
    1168             :   JSJitInfo::Method,
    1169             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1170             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1171             :   false,  /* isInfallible. False in setters. */
    1172             :   false,  /* isMovable.  Not relevant for setters. */
    1173             :   false, /* isEliminatable.  Not relevant for setters. */
    1174             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1175             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1176             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1177             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1178             : };
    1179             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1180             : static_assert(0 < 1, "There is no slot for us");
    1181             : 
    1182             : static bool
    1183           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1184             : {
    1185           0 :   mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
    1186             :   // We don't want to preserve if we don't have a wrapper, and we
    1187             :   // obviously can't preserve if we're not initialized.
    1188           0 :   if (self && self->GetWrapperPreserveColor()) {
    1189           0 :     PreserveWrapper(self);
    1190             :   }
    1191           0 :   return true;
    1192             : }
    1193             : 
    1194             : static void
    1195           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1196             : {
    1197           0 :   mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
    1198           0 :   if (self) {
    1199           0 :     ClearWrapper(self, self, obj);
    1200           0 :     AddForDeferredFinalization<mozilla::dom::CanvasGradient>(self);
    1201             :   }
    1202           0 : }
    1203             : 
    1204             : static void
    1205           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1206             : {
    1207           0 :   mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
    1208           0 :   if (self) {
    1209           0 :     UpdateWrapper(self, self, obj, old);
    1210             :   }
    1211           0 : }
    1212             : 
    1213             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1214             : #if defined(__clang__)
    1215             : #pragma clang diagnostic push
    1216             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1217             : #endif
    1218             : static const JSFunctionSpec sMethods_specs[] = {
    1219             :   JS_FNSPEC("addColorStop", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addColorStop_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    1220             :   JS_FS_END
    1221             : };
    1222             : #if defined(__clang__)
    1223             : #pragma clang diagnostic pop
    1224             : #endif
    1225             : 
    1226             : 
    1227             : // Can't be const because the pref-enabled boolean needs to be writable
    1228             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1229             :   { nullptr, &sMethods_specs[0] },
    1230             :   { nullptr, nullptr }
    1231             : };
    1232             : 
    1233             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1234             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1235             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1236             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1237             : 
    1238             : 
    1239             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
    1240             : static PropertyInfo sNativeProperties_propertyInfos[1];
    1241             : 
    1242             : static const NativePropertiesN<1> sNativeProperties = {
    1243             :   false, 0,
    1244             :   false, 0,
    1245             :   true,  0 /* sMethods */,
    1246             :   false, 0,
    1247             :   false, 0,
    1248             :   false, 0,
    1249             :   false, 0,
    1250             :   -1,
    1251             :   1,
    1252             :   sNativeProperties_sortedPropertyIndices,
    1253             :   {
    1254             :     { sMethods, &sNativeProperties_propertyInfos[0] }
    1255             :   }
    1256             : };
    1257             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1258             :     "We have a property info count that is oversized");
    1259             : 
    1260             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1261             :   {
    1262             :     "Function",
    1263             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1264             :     &sBoringInterfaceObjectClassClassOps,
    1265             :     JS_NULL_CLASS_SPEC,
    1266             :     JS_NULL_CLASS_EXT,
    1267             :     &sInterfaceObjectClassObjectOps
    1268             :   },
    1269             :   eInterface,
    1270             :   true,
    1271             :   prototypes::id::CanvasGradient,
    1272             :   PrototypeTraits<prototypes::id::CanvasGradient>::Depth,
    1273             :   sNativePropertyHooks,
    1274             :   "function CanvasGradient() {\n    [native code]\n}",
    1275             :   JS::GetRealmFunctionPrototype
    1276             : };
    1277             : 
    1278             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1279             :   {
    1280             :     "CanvasGradientPrototype",
    1281             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1282             :     JS_NULL_CLASS_OPS,
    1283             :     JS_NULL_CLASS_SPEC,
    1284             :     JS_NULL_CLASS_EXT,
    1285             :     JS_NULL_OBJECT_OPS
    1286             :   },
    1287             :   eInterfacePrototype,
    1288             :   false,
    1289             :   prototypes::id::CanvasGradient,
    1290             :   PrototypeTraits<prototypes::id::CanvasGradient>::Depth,
    1291             :   sNativePropertyHooks,
    1292             :   "[object CanvasGradientPrototype]",
    1293             :   JS::GetRealmObjectPrototype
    1294             : };
    1295             : 
    1296             : JSObject*
    1297           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1298             : {
    1299           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1300             : }
    1301             : 
    1302             : static const js::ClassOps sClassOps = {
    1303             :   _addProperty, /* addProperty */
    1304             :   nullptr,               /* delProperty */
    1305             :   nullptr,               /* getProperty */
    1306             :   nullptr,               /* setProperty */
    1307             :   nullptr,               /* enumerate */
    1308             :   nullptr, /* newEnumerate */
    1309             :   nullptr, /* resolve */
    1310             :   nullptr, /* mayResolve */
    1311             :   _finalize, /* finalize */
    1312             :   nullptr, /* call */
    1313             :   nullptr,               /* hasInstance */
    1314             :   nullptr,               /* construct */
    1315             :   nullptr, /* trace */
    1316             : };
    1317             : 
    1318             : static const js::ClassExtension sClassExtension = {
    1319             :   nullptr, /* weakmapKeyDelegateOp */
    1320             :   _objectMoved /* objectMovedOp */
    1321             : };
    1322             : 
    1323             : static const DOMJSClass sClass = {
    1324             :   { "CanvasGradient",
    1325             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1326             :     &sClassOps,
    1327             :     JS_NULL_CLASS_SPEC,
    1328             :     &sClassExtension,
    1329             :     JS_NULL_OBJECT_OPS
    1330             :   },
    1331             :   { prototypes::id::CanvasGradient, 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 },
    1332             :   IsBaseOf<nsISupports, mozilla::dom::CanvasGradient >::value,
    1333             :   sNativePropertyHooks,
    1334             :   FindAssociatedGlobalForNative<mozilla::dom::CanvasGradient>::Get,
    1335             :   GetProtoObjectHandle,
    1336             :   GetCCParticipant<mozilla::dom::CanvasGradient>::Get()
    1337             : };
    1338             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1339             :               "Must have the right minimal number of reserved slots.");
    1340             : static_assert(1 >= 1,
    1341             :               "Must have enough reserved slots.");
    1342             : 
    1343             : const JSClass*
    1344           0 : GetJSClass()
    1345             : {
    1346           0 :   return sClass.ToJSClass();
    1347             : }
    1348             : 
    1349             : bool
    1350           0 : Wrap(JSContext* aCx, mozilla::dom::CanvasGradient* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1351             : {
    1352             :   MOZ_ASSERT(static_cast<mozilla::dom::CanvasGradient*>(aObject) ==
    1353             :              reinterpret_cast<mozilla::dom::CanvasGradient*>(aObject),
    1354             :              "Multiple inheritance for mozilla::dom::CanvasGradient is broken.");
    1355           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1356           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1357           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1358             :              "You should probably not be using Wrap() directly; use "
    1359             :              "GetOrCreateDOMReflector instead");
    1360             : 
    1361           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1362             :              "nsISupports must be on our primary inheritance chain");
    1363             : 
    1364           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1365           0 :   if (!global) {
    1366           0 :     return false;
    1367             :   }
    1368           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1369           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1370             : 
    1371             :   // That might have ended up wrapping us already, due to the wonders
    1372             :   // of XBL.  Check for that, and bail out as needed.
    1373           0 :   aReflector.set(aCache->GetWrapper());
    1374           0 :   if (aReflector) {
    1375             : #ifdef DEBUG
    1376           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1377             : #endif // DEBUG
    1378           0 :     return true;
    1379             :   }
    1380             : 
    1381           0 :   JSAutoCompartment ac(aCx, global);
    1382           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1383           0 :   if (!canonicalProto) {
    1384           0 :     return false;
    1385             :   }
    1386           0 :   JS::Rooted<JSObject*> proto(aCx);
    1387           0 :   if (aGivenProto) {
    1388           0 :     proto = aGivenProto;
    1389             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1390             :     // coming in, we changed compartments to that of "parent" so may need
    1391             :     // to wrap the proto here.
    1392           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1393           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1394           0 :         return false;
    1395             :       }
    1396             :     }
    1397             :   } else {
    1398           0 :     proto = canonicalProto;
    1399             :   }
    1400             : 
    1401           0 :   BindingJSObjectCreator<mozilla::dom::CanvasGradient> creator(aCx);
    1402           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1403           0 :   if (!aReflector) {
    1404           0 :     return false;
    1405             :   }
    1406             : 
    1407           0 :   aCache->SetWrapper(aReflector);
    1408           0 :   creator.InitializationSucceeded();
    1409             : 
    1410           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1411             :              aCache->GetWrapperPreserveColor() == aReflector);
    1412             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1413             :   // otherwise we won't be able to properly recreate it later, since
    1414             :   // we won't know what proto to use.  Note that we don't check
    1415             :   // aGivenProto here, since it's entirely possible (and even
    1416             :   // somewhat common) to have a non-null aGivenProto which is the
    1417             :   // same as canonicalProto.
    1418           0 :   if (proto != canonicalProto) {
    1419           0 :     PreserveWrapper(aObject);
    1420             :   }
    1421             : 
    1422           0 :   return true;
    1423             : }
    1424             : 
    1425             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1426             :   nullptr,
    1427             :   nullptr,
    1428             :   nullptr,
    1429             :   { sNativeProperties.Upcast(), nullptr },
    1430             :   prototypes::id::CanvasGradient,
    1431             :   constructors::id::CanvasGradient,
    1432             :   nullptr,
    1433             :   &DefaultXrayExpandoObjectClass
    1434             : } };
    1435             : 
    1436             : void
    1437           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1438             : {
    1439           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1440           0 :   if (!parentProto) {
    1441           0 :     return;
    1442             :   }
    1443             : 
    1444           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1445           0 :   if (!constructorProto) {
    1446           0 :     return;
    1447             :   }
    1448             : 
    1449             :   static bool sIdsInited = false;
    1450           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1451           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1452           0 :       return;
    1453             :     }
    1454           0 :     sIdsInited = true;
    1455             :   }
    1456             : 
    1457           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasGradient);
    1458           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasGradient);
    1459           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1460             :                               &sPrototypeClass.mBase, protoCache,
    1461             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1462             :                               interfaceCache,
    1463             :                               sNativeProperties.Upcast(),
    1464             :                               nullptr,
    1465             :                               "CanvasGradient", aDefineOnGlobal,
    1466             :                               nullptr,
    1467           0 :                               false);
    1468             : }
    1469             : 
    1470             : JS::Handle<JSObject*>
    1471           0 : GetProtoObjectHandle(JSContext* aCx)
    1472             : {
    1473             :   /* Get the interface prototype object for this class.  This will create the
    1474             :      object as needed. */
    1475           0 :   bool aDefineOnGlobal = true;
    1476             : 
    1477             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1478           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1479           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1480           0 :     return nullptr;
    1481             :   }
    1482             : 
    1483             :   /* Check to see whether the interface objects are already installed */
    1484           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1485           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CanvasGradient)) {
    1486           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1487           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1488             :   }
    1489             : 
    1490             :   /*
    1491             :    * The object might _still_ be null, but that's OK.
    1492             :    *
    1493             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1494             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1495             :    * changed after they have been set.
    1496             :    *
    1497             :    * Calling address() avoids the read read barrier that does gray
    1498             :    * unmarking, but it's not possible for the object to be gray here.
    1499             :    */
    1500             : 
    1501           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CanvasGradient);
    1502           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1503           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1504             : }
    1505             : 
    1506             : JS::Handle<JSObject*>
    1507           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1508             : {
    1509             :   /* Get the interface object for this class.  This will create the object as
    1510             :      needed. */
    1511             : 
    1512             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1513           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1514           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1515           0 :     return nullptr;
    1516             :   }
    1517             : 
    1518             :   /* Check to see whether the interface objects are already installed */
    1519           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1520           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CanvasGradient)) {
    1521           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1522           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1523             :   }
    1524             : 
    1525             :   /*
    1526             :    * The object might _still_ be null, but that's OK.
    1527             :    *
    1528             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1529             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1530             :    * changed after they have been set.
    1531             :    *
    1532             :    * Calling address() avoids the read read barrier that does gray
    1533             :    * unmarking, but it's not possible for the object to be gray here.
    1534             :    */
    1535             : 
    1536           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CanvasGradient);
    1537           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1538           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1539             : }
    1540             : 
    1541             : JSObject*
    1542           0 : GetConstructorObject(JSContext* aCx)
    1543             : {
    1544           0 :   return GetConstructorObjectHandle(aCx);
    1545             : }
    1546             : 
    1547             : } // namespace CanvasGradientBinding
    1548             : 
    1549             : 
    1550             : 
    1551             : namespace CanvasPatternBinding {
    1552             : 
    1553             : static bool
    1554           0 : setTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPattern* self, const JSJitMethodCallArgs& args)
    1555             : {
    1556           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1557           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasPattern.setTransform");
    1558             :   }
    1559           0 :   NonNull<mozilla::dom::SVGMatrix> arg0;
    1560           0 :   if (args[0].isObject()) {
    1561             :     {
    1562           0 :       nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[0], arg0);
    1563           0 :       if (NS_FAILED(rv)) {
    1564           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasPattern.setTransform", "SVGMatrix");
    1565           0 :         return false;
    1566             :       }
    1567             :     }
    1568             :   } else {
    1569           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasPattern.setTransform");
    1570           0 :     return false;
    1571             :   }
    1572           0 :   self->SetTransform(NonNullHelper(arg0));
    1573           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1574           0 :   args.rval().setUndefined();
    1575           0 :   return true;
    1576             : }
    1577             : 
    1578             : static const JSJitInfo setTransform_methodinfo = {
    1579             :   { (JSJitGetterOp)setTransform },
    1580             :   { prototypes::id::CanvasPattern },
    1581             :   { PrototypeTraits<prototypes::id::CanvasPattern>::Depth },
    1582             :   JSJitInfo::Method,
    1583             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1584             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1585             :   false,  /* isInfallible. False in setters. */
    1586             :   false,  /* isMovable.  Not relevant for setters. */
    1587             :   false, /* isEliminatable.  Not relevant for setters. */
    1588             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1589             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1590             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1591             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1592             : };
    1593             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1594             : static_assert(0 < 1, "There is no slot for us");
    1595             : 
    1596             : static bool
    1597           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1598             : {
    1599           0 :   mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
    1600             :   // We don't want to preserve if we don't have a wrapper, and we
    1601             :   // obviously can't preserve if we're not initialized.
    1602           0 :   if (self && self->GetWrapperPreserveColor()) {
    1603           0 :     PreserveWrapper(self);
    1604             :   }
    1605           0 :   return true;
    1606             : }
    1607             : 
    1608             : static void
    1609           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1610             : {
    1611           0 :   mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
    1612           0 :   if (self) {
    1613           0 :     ClearWrapper(self, self, obj);
    1614           0 :     AddForDeferredFinalization<mozilla::dom::CanvasPattern>(self);
    1615             :   }
    1616           0 : }
    1617             : 
    1618             : static void
    1619           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1620             : {
    1621           0 :   mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
    1622           0 :   if (self) {
    1623           0 :     UpdateWrapper(self, self, obj, old);
    1624             :   }
    1625           0 : }
    1626             : 
    1627             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1628             : #if defined(__clang__)
    1629             : #pragma clang diagnostic push
    1630             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1631             : #endif
    1632             : static const JSFunctionSpec sMethods_specs[] = {
    1633             :   JS_FNSPEC("setTransform", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setTransform_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1634             :   JS_FS_END
    1635             : };
    1636             : #if defined(__clang__)
    1637             : #pragma clang diagnostic pop
    1638             : #endif
    1639             : 
    1640             : 
    1641             : // Can't be const because the pref-enabled boolean needs to be writable
    1642             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1643             :   { nullptr, &sMethods_specs[0] },
    1644             :   { nullptr, nullptr }
    1645             : };
    1646             : 
    1647             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1648             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1649             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1650             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1651             : 
    1652             : 
    1653             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
    1654             : static PropertyInfo sNativeProperties_propertyInfos[1];
    1655             : 
    1656             : static const NativePropertiesN<1> sNativeProperties = {
    1657             :   false, 0,
    1658             :   false, 0,
    1659             :   true,  0 /* sMethods */,
    1660             :   false, 0,
    1661             :   false, 0,
    1662             :   false, 0,
    1663             :   false, 0,
    1664             :   -1,
    1665             :   1,
    1666             :   sNativeProperties_sortedPropertyIndices,
    1667             :   {
    1668             :     { sMethods, &sNativeProperties_propertyInfos[0] }
    1669             :   }
    1670             : };
    1671             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1672             :     "We have a property info count that is oversized");
    1673             : 
    1674             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1675             :   {
    1676             :     "Function",
    1677             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1678             :     &sBoringInterfaceObjectClassClassOps,
    1679             :     JS_NULL_CLASS_SPEC,
    1680             :     JS_NULL_CLASS_EXT,
    1681             :     &sInterfaceObjectClassObjectOps
    1682             :   },
    1683             :   eInterface,
    1684             :   true,
    1685             :   prototypes::id::CanvasPattern,
    1686             :   PrototypeTraits<prototypes::id::CanvasPattern>::Depth,
    1687             :   sNativePropertyHooks,
    1688             :   "function CanvasPattern() {\n    [native code]\n}",
    1689             :   JS::GetRealmFunctionPrototype
    1690             : };
    1691             : 
    1692             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1693             :   {
    1694             :     "CanvasPatternPrototype",
    1695             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1696             :     JS_NULL_CLASS_OPS,
    1697             :     JS_NULL_CLASS_SPEC,
    1698             :     JS_NULL_CLASS_EXT,
    1699             :     JS_NULL_OBJECT_OPS
    1700             :   },
    1701             :   eInterfacePrototype,
    1702             :   false,
    1703             :   prototypes::id::CanvasPattern,
    1704             :   PrototypeTraits<prototypes::id::CanvasPattern>::Depth,
    1705             :   sNativePropertyHooks,
    1706             :   "[object CanvasPatternPrototype]",
    1707             :   JS::GetRealmObjectPrototype
    1708             : };
    1709             : 
    1710             : JSObject*
    1711           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1712             : {
    1713           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1714             : }
    1715             : 
    1716             : static const js::ClassOps sClassOps = {
    1717             :   _addProperty, /* addProperty */
    1718             :   nullptr,               /* delProperty */
    1719             :   nullptr,               /* getProperty */
    1720             :   nullptr,               /* setProperty */
    1721             :   nullptr,               /* enumerate */
    1722             :   nullptr, /* newEnumerate */
    1723             :   nullptr, /* resolve */
    1724             :   nullptr, /* mayResolve */
    1725             :   _finalize, /* finalize */
    1726             :   nullptr, /* call */
    1727             :   nullptr,               /* hasInstance */
    1728             :   nullptr,               /* construct */
    1729             :   nullptr, /* trace */
    1730             : };
    1731             : 
    1732             : static const js::ClassExtension sClassExtension = {
    1733             :   nullptr, /* weakmapKeyDelegateOp */
    1734             :   _objectMoved /* objectMovedOp */
    1735             : };
    1736             : 
    1737             : static const DOMJSClass sClass = {
    1738             :   { "CanvasPattern",
    1739             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1740             :     &sClassOps,
    1741             :     JS_NULL_CLASS_SPEC,
    1742             :     &sClassExtension,
    1743             :     JS_NULL_OBJECT_OPS
    1744             :   },
    1745             :   { prototypes::id::CanvasPattern, 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 },
    1746             :   IsBaseOf<nsISupports, mozilla::dom::CanvasPattern >::value,
    1747             :   sNativePropertyHooks,
    1748             :   FindAssociatedGlobalForNative<mozilla::dom::CanvasPattern>::Get,
    1749             :   GetProtoObjectHandle,
    1750             :   GetCCParticipant<mozilla::dom::CanvasPattern>::Get()
    1751             : };
    1752             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1753             :               "Must have the right minimal number of reserved slots.");
    1754             : static_assert(1 >= 1,
    1755             :               "Must have enough reserved slots.");
    1756             : 
    1757             : const JSClass*
    1758           0 : GetJSClass()
    1759             : {
    1760           0 :   return sClass.ToJSClass();
    1761             : }
    1762             : 
    1763             : bool
    1764           0 : Wrap(JSContext* aCx, mozilla::dom::CanvasPattern* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1765             : {
    1766             :   MOZ_ASSERT(static_cast<mozilla::dom::CanvasPattern*>(aObject) ==
    1767             :              reinterpret_cast<mozilla::dom::CanvasPattern*>(aObject),
    1768             :              "Multiple inheritance for mozilla::dom::CanvasPattern is broken.");
    1769           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1770           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1771           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1772             :              "You should probably not be using Wrap() directly; use "
    1773             :              "GetOrCreateDOMReflector instead");
    1774             : 
    1775           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1776             :              "nsISupports must be on our primary inheritance chain");
    1777             : 
    1778           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1779           0 :   if (!global) {
    1780           0 :     return false;
    1781             :   }
    1782           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1783           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1784             : 
    1785             :   // That might have ended up wrapping us already, due to the wonders
    1786             :   // of XBL.  Check for that, and bail out as needed.
    1787           0 :   aReflector.set(aCache->GetWrapper());
    1788           0 :   if (aReflector) {
    1789             : #ifdef DEBUG
    1790           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1791             : #endif // DEBUG
    1792           0 :     return true;
    1793             :   }
    1794             : 
    1795           0 :   JSAutoCompartment ac(aCx, global);
    1796           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1797           0 :   if (!canonicalProto) {
    1798           0 :     return false;
    1799             :   }
    1800           0 :   JS::Rooted<JSObject*> proto(aCx);
    1801           0 :   if (aGivenProto) {
    1802           0 :     proto = aGivenProto;
    1803             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1804             :     // coming in, we changed compartments to that of "parent" so may need
    1805             :     // to wrap the proto here.
    1806           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1807           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1808           0 :         return false;
    1809             :       }
    1810             :     }
    1811             :   } else {
    1812           0 :     proto = canonicalProto;
    1813             :   }
    1814             : 
    1815           0 :   BindingJSObjectCreator<mozilla::dom::CanvasPattern> creator(aCx);
    1816           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1817           0 :   if (!aReflector) {
    1818           0 :     return false;
    1819             :   }
    1820             : 
    1821           0 :   aCache->SetWrapper(aReflector);
    1822           0 :   creator.InitializationSucceeded();
    1823             : 
    1824           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1825             :              aCache->GetWrapperPreserveColor() == aReflector);
    1826             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1827             :   // otherwise we won't be able to properly recreate it later, since
    1828             :   // we won't know what proto to use.  Note that we don't check
    1829             :   // aGivenProto here, since it's entirely possible (and even
    1830             :   // somewhat common) to have a non-null aGivenProto which is the
    1831             :   // same as canonicalProto.
    1832           0 :   if (proto != canonicalProto) {
    1833           0 :     PreserveWrapper(aObject);
    1834             :   }
    1835             : 
    1836           0 :   return true;
    1837             : }
    1838             : 
    1839             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1840             :   nullptr,
    1841             :   nullptr,
    1842             :   nullptr,
    1843             :   { sNativeProperties.Upcast(), nullptr },
    1844             :   prototypes::id::CanvasPattern,
    1845             :   constructors::id::CanvasPattern,
    1846             :   nullptr,
    1847             :   &DefaultXrayExpandoObjectClass
    1848             : } };
    1849             : 
    1850             : void
    1851           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1852             : {
    1853           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1854           0 :   if (!parentProto) {
    1855           0 :     return;
    1856             :   }
    1857             : 
    1858           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1859           0 :   if (!constructorProto) {
    1860           0 :     return;
    1861             :   }
    1862             : 
    1863             :   static bool sIdsInited = false;
    1864           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1865           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1866           0 :       return;
    1867             :     }
    1868           0 :     sIdsInited = true;
    1869             :   }
    1870             : 
    1871           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasPattern);
    1872           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasPattern);
    1873           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1874             :                               &sPrototypeClass.mBase, protoCache,
    1875             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1876             :                               interfaceCache,
    1877             :                               sNativeProperties.Upcast(),
    1878             :                               nullptr,
    1879             :                               "CanvasPattern", aDefineOnGlobal,
    1880             :                               nullptr,
    1881           0 :                               false);
    1882             : }
    1883             : 
    1884             : JS::Handle<JSObject*>
    1885           0 : GetProtoObjectHandle(JSContext* aCx)
    1886             : {
    1887             :   /* Get the interface prototype object for this class.  This will create the
    1888             :      object as needed. */
    1889           0 :   bool aDefineOnGlobal = true;
    1890             : 
    1891             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1892           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1893           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1894           0 :     return nullptr;
    1895             :   }
    1896             : 
    1897             :   /* Check to see whether the interface objects are already installed */
    1898           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1899           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CanvasPattern)) {
    1900           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1901           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1902             :   }
    1903             : 
    1904             :   /*
    1905             :    * The object might _still_ be null, but that's OK.
    1906             :    *
    1907             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1908             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1909             :    * changed after they have been set.
    1910             :    *
    1911             :    * Calling address() avoids the read read barrier that does gray
    1912             :    * unmarking, but it's not possible for the object to be gray here.
    1913             :    */
    1914             : 
    1915           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CanvasPattern);
    1916           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1917           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1918             : }
    1919             : 
    1920             : JS::Handle<JSObject*>
    1921           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1922             : {
    1923             :   /* Get the interface object for this class.  This will create the object as
    1924             :      needed. */
    1925             : 
    1926             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1927           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1928           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1929           0 :     return nullptr;
    1930             :   }
    1931             : 
    1932             :   /* Check to see whether the interface objects are already installed */
    1933           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1934           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CanvasPattern)) {
    1935           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1936           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1937             :   }
    1938             : 
    1939             :   /*
    1940             :    * The object might _still_ be null, but that's OK.
    1941             :    *
    1942             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1943             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1944             :    * changed after they have been set.
    1945             :    *
    1946             :    * Calling address() avoids the read read barrier that does gray
    1947             :    * unmarking, but it's not possible for the object to be gray here.
    1948             :    */
    1949             : 
    1950           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CanvasPattern);
    1951           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1952           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1953             : }
    1954             : 
    1955             : JSObject*
    1956           0 : GetConstructorObject(JSContext* aCx)
    1957             : {
    1958           0 :   return GetConstructorObjectHandle(aCx);
    1959             : }
    1960             : 
    1961             : } // namespace CanvasPatternBinding
    1962             : 
    1963             : 
    1964             : 
    1965             : namespace CanvasRenderingContext2DBinding {
    1966             : 
    1967             : static bool
    1968           0 : get_canvas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    1969             : {
    1970           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLCanvasElement>(self->GetCanvas()));
    1971           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1972           0 :   if (!result) {
    1973           0 :     args.rval().setNull();
    1974           0 :     return true;
    1975             :   }
    1976           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    1977           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1978           0 :     return false;
    1979             :   }
    1980           0 :   return true;
    1981             : }
    1982             : 
    1983             : static const JSJitInfo canvas_getterinfo = {
    1984             :   { (JSJitGetterOp)get_canvas },
    1985             :   { prototypes::id::CanvasRenderingContext2D },
    1986             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    1987             :   JSJitInfo::Getter,
    1988             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1989             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1990             :   false,  /* isInfallible. False in setters. */
    1991             :   false,  /* isMovable.  Not relevant for setters. */
    1992             :   false, /* isEliminatable.  Not relevant for setters. */
    1993             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1994             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1995             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1996             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1997             : };
    1998             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1999             : static_assert(0 < 1, "There is no slot for us");
    2000             : 
    2001             : static bool
    2002           0 : get_mozCurrentTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2003             : {
    2004           0 :   binding_detail::FastErrorResult rv;
    2005           0 :   JS::Rooted<JSObject*> result(cx);
    2006           0 :   self->GetMozCurrentTransform(cx, &result, rv);
    2007           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2008           0 :     return false;
    2009             :   }
    2010           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2011           0 :   JS::ExposeObjectToActiveJS(result);
    2012           0 :   args.rval().setObject(*result);
    2013           0 :   if (!MaybeWrapObjectValue(cx, args.rval())) {
    2014           0 :     return false;
    2015             :   }
    2016           0 :   return true;
    2017             : }
    2018             : 
    2019             : static bool
    2020           0 : set_mozCurrentTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2021             : {
    2022           0 :   JS::Rooted<JSObject*> arg0(cx);
    2023           0 :   if (args[0].isObject()) {
    2024           0 :     arg0 = &args[0].toObject();
    2025             :   } else {
    2026           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to CanvasRenderingContext2D.mozCurrentTransform");
    2027           0 :     return false;
    2028             :   }
    2029           0 :   binding_detail::FastErrorResult rv;
    2030           0 :   self->SetMozCurrentTransform(cx, arg0, rv);
    2031           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2032           0 :     return false;
    2033             :   }
    2034           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2035             : 
    2036           0 :   return true;
    2037             : }
    2038             : 
    2039             : static const JSJitInfo mozCurrentTransform_getterinfo = {
    2040             :   { (JSJitGetterOp)get_mozCurrentTransform },
    2041             :   { prototypes::id::CanvasRenderingContext2D },
    2042             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2043             :   JSJitInfo::Getter,
    2044             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2045             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2046             :   false,  /* isInfallible. False in setters. */
    2047             :   false,  /* isMovable.  Not relevant for setters. */
    2048             :   false, /* isEliminatable.  Not relevant for setters. */
    2049             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2050             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2051             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2052             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2053             : };
    2054             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2055             : static_assert(0 < 1, "There is no slot for us");
    2056             : static const JSJitInfo mozCurrentTransform_setterinfo = {
    2057             :   { (JSJitGetterOp)set_mozCurrentTransform },
    2058             :   { prototypes::id::CanvasRenderingContext2D },
    2059             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2060             :   JSJitInfo::Setter,
    2061             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2062             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2063             :   false,  /* isInfallible. False in setters. */
    2064             :   false,  /* isMovable.  Not relevant for setters. */
    2065             :   false, /* isEliminatable.  Not relevant for setters. */
    2066             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2067             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2068             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2069             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2070             : };
    2071             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2072             : static_assert(0 < 1, "There is no slot for us");
    2073             : 
    2074             : static bool
    2075           0 : get_mozCurrentTransformInverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2076             : {
    2077           0 :   binding_detail::FastErrorResult rv;
    2078           0 :   JS::Rooted<JSObject*> result(cx);
    2079           0 :   self->GetMozCurrentTransformInverse(cx, &result, rv);
    2080           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2081           0 :     return false;
    2082             :   }
    2083           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2084           0 :   JS::ExposeObjectToActiveJS(result);
    2085           0 :   args.rval().setObject(*result);
    2086           0 :   if (!MaybeWrapObjectValue(cx, args.rval())) {
    2087           0 :     return false;
    2088             :   }
    2089           0 :   return true;
    2090             : }
    2091             : 
    2092             : static bool
    2093           0 : set_mozCurrentTransformInverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2094             : {
    2095           0 :   JS::Rooted<JSObject*> arg0(cx);
    2096           0 :   if (args[0].isObject()) {
    2097           0 :     arg0 = &args[0].toObject();
    2098             :   } else {
    2099           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to CanvasRenderingContext2D.mozCurrentTransformInverse");
    2100           0 :     return false;
    2101             :   }
    2102           0 :   binding_detail::FastErrorResult rv;
    2103           0 :   self->SetMozCurrentTransformInverse(cx, arg0, rv);
    2104           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2105           0 :     return false;
    2106             :   }
    2107           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2108             : 
    2109           0 :   return true;
    2110             : }
    2111             : 
    2112             : static const JSJitInfo mozCurrentTransformInverse_getterinfo = {
    2113             :   { (JSJitGetterOp)get_mozCurrentTransformInverse },
    2114             :   { prototypes::id::CanvasRenderingContext2D },
    2115             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2116             :   JSJitInfo::Getter,
    2117             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2118             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2119             :   false,  /* isInfallible. False in setters. */
    2120             :   false,  /* isMovable.  Not relevant for setters. */
    2121             :   false, /* isEliminatable.  Not relevant for setters. */
    2122             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2123             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2124             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2125             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2126             : };
    2127             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2128             : static_assert(0 < 1, "There is no slot for us");
    2129             : static const JSJitInfo mozCurrentTransformInverse_setterinfo = {
    2130             :   { (JSJitGetterOp)set_mozCurrentTransformInverse },
    2131             :   { prototypes::id::CanvasRenderingContext2D },
    2132             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2133             :   JSJitInfo::Setter,
    2134             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2135             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2136             :   false,  /* isInfallible. False in setters. */
    2137             :   false,  /* isMovable.  Not relevant for setters. */
    2138             :   false, /* isEliminatable.  Not relevant for setters. */
    2139             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2140             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2141             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2142             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2143             : };
    2144             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2145             : static_assert(0 < 1, "There is no slot for us");
    2146             : 
    2147             : static bool
    2148           0 : get_mozTextStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2149             : {
    2150           0 :   DOMString result;
    2151           0 :   self->GetMozTextStyle(result);
    2152           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2153           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    2154           0 :     return false;
    2155             :   }
    2156           0 :   return true;
    2157             : }
    2158             : 
    2159             : static bool
    2160           0 : set_mozTextStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2161             : {
    2162           0 :   binding_detail::FakeString arg0;
    2163           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    2164           0 :     return false;
    2165             :   }
    2166           0 :   binding_detail::FastErrorResult rv;
    2167           0 :   self->SetMozTextStyle(NonNullHelper(Constify(arg0)), rv);
    2168           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2169           0 :     return false;
    2170             :   }
    2171           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2172             : 
    2173           0 :   return true;
    2174             : }
    2175             : 
    2176             : static const JSJitInfo mozTextStyle_getterinfo = {
    2177             :   { (JSJitGetterOp)get_mozTextStyle },
    2178             :   { prototypes::id::CanvasRenderingContext2D },
    2179             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2180             :   JSJitInfo::Getter,
    2181             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2182             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    2183             :   false,  /* isInfallible. False in setters. */
    2184             :   false,  /* isMovable.  Not relevant for setters. */
    2185             :   false, /* isEliminatable.  Not relevant for setters. */
    2186             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2187             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2188             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2189             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2190             : };
    2191             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2192             : static_assert(0 < 1, "There is no slot for us");
    2193             : static const JSJitInfo mozTextStyle_setterinfo = {
    2194             :   { (JSJitGetterOp)set_mozTextStyle },
    2195             :   { prototypes::id::CanvasRenderingContext2D },
    2196             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2197             :   JSJitInfo::Setter,
    2198             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2199             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2200             :   false,  /* isInfallible. False in setters. */
    2201             :   false,  /* isMovable.  Not relevant for setters. */
    2202             :   false, /* isEliminatable.  Not relevant for setters. */
    2203             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2204             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2205             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2206             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2207             : };
    2208             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2209             : static_assert(0 < 1, "There is no slot for us");
    2210             : 
    2211             : static bool
    2212           0 : get_mozImageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2213             : {
    2214           0 :   DeprecationWarning(cx, obj, nsIDocument::ePrefixedImageSmoothingEnabled);
    2215           0 :   bool result(self->ImageSmoothingEnabled());
    2216           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2217           0 :   args.rval().setBoolean(result);
    2218           0 :   return true;
    2219             : }
    2220             : 
    2221             : static bool
    2222           0 : set_mozImageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2223             : {
    2224           0 :   DeprecationWarning(cx, obj, nsIDocument::ePrefixedImageSmoothingEnabled);
    2225             :   bool arg0;
    2226           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
    2227           0 :     return false;
    2228             :   }
    2229           0 :   self->SetImageSmoothingEnabled(arg0);
    2230           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2231             : 
    2232           0 :   return true;
    2233             : }
    2234             : 
    2235             : static const JSJitInfo mozImageSmoothingEnabled_getterinfo = {
    2236             :   { (JSJitGetterOp)get_mozImageSmoothingEnabled },
    2237             :   { prototypes::id::CanvasRenderingContext2D },
    2238             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2239             :   JSJitInfo::Getter,
    2240             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2241             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    2242             :   true,  /* isInfallible. False in setters. */
    2243             :   false,  /* isMovable.  Not relevant for setters. */
    2244             :   false, /* isEliminatable.  Not relevant for setters. */
    2245             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2246             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2247             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2248             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2249             : };
    2250             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2251             : static_assert(0 < 1, "There is no slot for us");
    2252             : static const JSJitInfo mozImageSmoothingEnabled_setterinfo = {
    2253             :   { (JSJitGetterOp)set_mozImageSmoothingEnabled },
    2254             :   { prototypes::id::CanvasRenderingContext2D },
    2255             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2256             :   JSJitInfo::Setter,
    2257             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2258             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2259             :   false,  /* isInfallible. False in setters. */
    2260             :   false,  /* isMovable.  Not relevant for setters. */
    2261             :   false, /* isEliminatable.  Not relevant for setters. */
    2262             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2263             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2264             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2265             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2266             : };
    2267             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2268             : static_assert(0 < 1, "There is no slot for us");
    2269             : 
    2270             : static bool
    2271           0 : drawWindow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2272             : {
    2273           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    2274           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawWindow");
    2275             :   }
    2276           0 :   NonNull<nsGlobalWindow> arg0;
    2277           0 :   if (args[0].isObject()) {
    2278             :     {
    2279           0 :       nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[0], arg0);
    2280           0 :       if (NS_FAILED(rv)) {
    2281           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawWindow", "Window");
    2282           0 :         return false;
    2283             :       }
    2284             :     }
    2285             :   } else {
    2286           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawWindow");
    2287           0 :     return false;
    2288             :   }
    2289             :   double arg1;
    2290           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    2291           0 :     return false;
    2292           0 :   } else if (!mozilla::IsFinite(arg1)) {
    2293           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.drawWindow");
    2294           0 :     return false;
    2295             :   }
    2296             :   double arg2;
    2297           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    2298           0 :     return false;
    2299           0 :   } else if (!mozilla::IsFinite(arg2)) {
    2300           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.drawWindow");
    2301           0 :     return false;
    2302             :   }
    2303             :   double arg3;
    2304           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    2305           0 :     return false;
    2306           0 :   } else if (!mozilla::IsFinite(arg3)) {
    2307           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.drawWindow");
    2308           0 :     return false;
    2309             :   }
    2310             :   double arg4;
    2311           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    2312           0 :     return false;
    2313           0 :   } else if (!mozilla::IsFinite(arg4)) {
    2314           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.drawWindow");
    2315           0 :     return false;
    2316             :   }
    2317           0 :   binding_detail::FakeString arg5;
    2318           0 :   if (!ConvertJSValueToString(cx, args[5], eStringify, eStringify, arg5)) {
    2319           0 :     return false;
    2320             :   }
    2321             :   uint32_t arg6;
    2322           0 :   if (args.hasDefined(6)) {
    2323           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[6], &arg6)) {
    2324           0 :       return false;
    2325             :     }
    2326             :   } else {
    2327           0 :     arg6 = 0U;
    2328             :   }
    2329           0 :   binding_detail::FastErrorResult rv;
    2330           0 :   self->DrawWindow(NonNullHelper(arg0), arg1, arg2, arg3, arg4, NonNullHelper(Constify(arg5)), arg6, rv);
    2331           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2332           0 :     return false;
    2333             :   }
    2334           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2335           0 :   args.rval().setUndefined();
    2336           0 :   return true;
    2337             : }
    2338             : 
    2339             : static const JSJitInfo drawWindow_methodinfo = {
    2340             :   { (JSJitGetterOp)drawWindow },
    2341             :   { prototypes::id::CanvasRenderingContext2D },
    2342             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2343             :   JSJitInfo::Method,
    2344             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2345             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2346             :   false,  /* isInfallible. False in setters. */
    2347             :   false,  /* isMovable.  Not relevant for setters. */
    2348             :   false, /* isEliminatable.  Not relevant for setters. */
    2349             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2350             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2351             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2352             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2353             : };
    2354             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2355             : static_assert(0 < 1, "There is no slot for us");
    2356             : 
    2357             : static bool
    2358           0 : demote(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2359             : {
    2360           0 :   self->Demote();
    2361           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2362           0 :   args.rval().setUndefined();
    2363           0 :   return true;
    2364             : }
    2365             : 
    2366             : static const JSJitInfo demote_methodinfo = {
    2367             :   { (JSJitGetterOp)demote },
    2368             :   { prototypes::id::CanvasRenderingContext2D },
    2369             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2370             :   JSJitInfo::Method,
    2371             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2372             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2373             :   true,  /* isInfallible. False in setters. */
    2374             :   false,  /* isMovable.  Not relevant for setters. */
    2375             :   false, /* isEliminatable.  Not relevant for setters. */
    2376             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2377             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2378             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2379             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2380             : };
    2381             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2382             : static_assert(0 < 1, "There is no slot for us");
    2383             : 
    2384             : static bool
    2385           0 : get_globalAlpha(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2386             : {
    2387           0 :   double result(self->GlobalAlpha());
    2388           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2389           0 :   args.rval().set(JS_NumberValue(double(result)));
    2390           0 :   return true;
    2391             : }
    2392             : 
    2393             : static bool
    2394           0 : set_globalAlpha(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2395             : {
    2396             :   double arg0;
    2397           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    2398           0 :     return false;
    2399             :   }
    2400           0 :   self->SetGlobalAlpha(arg0);
    2401           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2402             : 
    2403           0 :   return true;
    2404             : }
    2405             : 
    2406             : static const JSJitInfo globalAlpha_getterinfo = {
    2407             :   { (JSJitGetterOp)get_globalAlpha },
    2408             :   { prototypes::id::CanvasRenderingContext2D },
    2409             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2410             :   JSJitInfo::Getter,
    2411             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2412             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2413             :   true,  /* isInfallible. False in setters. */
    2414             :   false,  /* isMovable.  Not relevant for setters. */
    2415             :   false, /* isEliminatable.  Not relevant for setters. */
    2416             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2417             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2418             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2419             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2420             : };
    2421             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2422             : static_assert(0 < 1, "There is no slot for us");
    2423             : static const JSJitInfo globalAlpha_setterinfo = {
    2424             :   { (JSJitGetterOp)set_globalAlpha },
    2425             :   { prototypes::id::CanvasRenderingContext2D },
    2426             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2427             :   JSJitInfo::Setter,
    2428             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2429             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2430             :   false,  /* isInfallible. False in setters. */
    2431             :   false,  /* isMovable.  Not relevant for setters. */
    2432             :   false, /* isEliminatable.  Not relevant for setters. */
    2433             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2434             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2435             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2436             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2437             : };
    2438             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2439             : static_assert(0 < 1, "There is no slot for us");
    2440             : 
    2441             : static bool
    2442           0 : get_globalCompositeOperation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    2443             : {
    2444           0 :   binding_detail::FastErrorResult rv;
    2445           0 :   DOMString result;
    2446           0 :   self->GetGlobalCompositeOperation(result, rv);
    2447           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2448           0 :     return false;
    2449             :   }
    2450           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2451           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    2452           0 :     return false;
    2453             :   }
    2454           0 :   return true;
    2455             : }
    2456             : 
    2457             : static bool
    2458           0 : set_globalCompositeOperation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    2459             : {
    2460           0 :   binding_detail::FakeString arg0;
    2461           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    2462           0 :     return false;
    2463             :   }
    2464           0 :   binding_detail::FastErrorResult rv;
    2465           0 :   self->SetGlobalCompositeOperation(NonNullHelper(Constify(arg0)), rv);
    2466           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2467           0 :     return false;
    2468             :   }
    2469           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2470             : 
    2471           0 :   return true;
    2472             : }
    2473             : 
    2474             : static const JSJitInfo globalCompositeOperation_getterinfo = {
    2475             :   { (JSJitGetterOp)get_globalCompositeOperation },
    2476             :   { prototypes::id::CanvasRenderingContext2D },
    2477             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2478             :   JSJitInfo::Getter,
    2479             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2480             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    2481             :   false,  /* isInfallible. False in setters. */
    2482             :   false,  /* isMovable.  Not relevant for setters. */
    2483             :   false, /* isEliminatable.  Not relevant for setters. */
    2484             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2485             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2486             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2487             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2488             : };
    2489             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2490             : static_assert(0 < 1, "There is no slot for us");
    2491             : static const JSJitInfo globalCompositeOperation_setterinfo = {
    2492             :   { (JSJitGetterOp)set_globalCompositeOperation },
    2493             :   { prototypes::id::CanvasRenderingContext2D },
    2494             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2495             :   JSJitInfo::Setter,
    2496             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2497             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2498             :   false,  /* isInfallible. False in setters. */
    2499             :   false,  /* isMovable.  Not relevant for setters. */
    2500             :   false, /* isEliminatable.  Not relevant for setters. */
    2501             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2502             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2503             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2504             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2505             : };
    2506             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2507             : static_assert(0 < 1, "There is no slot for us");
    2508             : 
    2509             : static bool
    2510           0 : drawImage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2511             : {
    2512           0 :   unsigned argcount = std::min(args.length(), 9u);
    2513           0 :   switch (argcount) {
    2514             :     case 3: {
    2515           0 :       bool foundNonFiniteFloat = false;
    2516           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
    2517           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
    2518             :       {
    2519           0 :         bool done = false, failed = false, tryNext;
    2520           0 :         if (args[0].isObject()) {
    2521           0 :           done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
    2522           0 :                  (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
    2523           0 :                  (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
    2524           0 :                  (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
    2525             : 
    2526             :         }
    2527           0 :         if (failed) {
    2528           0 :           return false;
    2529             :         }
    2530           0 :         if (!done) {
    2531           0 :           ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
    2532           0 :           return false;
    2533             :         }
    2534             :       }
    2535             :       double arg1;
    2536           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    2537           0 :         return false;
    2538           0 :       } else if (!mozilla::IsFinite(arg1)) {
    2539           0 :         foundNonFiniteFloat = true;
    2540             :       }
    2541             :       double arg2;
    2542           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    2543           0 :         return false;
    2544           0 :       } else if (!mozilla::IsFinite(arg2)) {
    2545           0 :         foundNonFiniteFloat = true;
    2546             :       }
    2547           0 :       if (foundNonFiniteFloat) {
    2548           0 :         args.rval().setUndefined();
    2549           0 :         return true;
    2550             :       }
    2551           0 :       binding_detail::FastErrorResult rv;
    2552           0 :       self->DrawImage(Constify(arg0), arg1, arg2, rv);
    2553           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2554           0 :         return false;
    2555             :       }
    2556           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2557           0 :       args.rval().setUndefined();
    2558           0 :       return true;
    2559             :       break;
    2560             :     }
    2561             :     case 5: {
    2562           0 :       bool foundNonFiniteFloat = false;
    2563           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
    2564           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
    2565             :       {
    2566           0 :         bool done = false, failed = false, tryNext;
    2567           0 :         if (args[0].isObject()) {
    2568           0 :           done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
    2569           0 :                  (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
    2570           0 :                  (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
    2571           0 :                  (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
    2572             : 
    2573             :         }
    2574           0 :         if (failed) {
    2575           0 :           return false;
    2576             :         }
    2577           0 :         if (!done) {
    2578           0 :           ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
    2579           0 :           return false;
    2580             :         }
    2581             :       }
    2582             :       double arg1;
    2583           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    2584           0 :         return false;
    2585           0 :       } else if (!mozilla::IsFinite(arg1)) {
    2586           0 :         foundNonFiniteFloat = true;
    2587             :       }
    2588             :       double arg2;
    2589           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    2590           0 :         return false;
    2591           0 :       } else if (!mozilla::IsFinite(arg2)) {
    2592           0 :         foundNonFiniteFloat = true;
    2593             :       }
    2594             :       double arg3;
    2595           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    2596           0 :         return false;
    2597           0 :       } else if (!mozilla::IsFinite(arg3)) {
    2598           0 :         foundNonFiniteFloat = true;
    2599             :       }
    2600             :       double arg4;
    2601           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    2602           0 :         return false;
    2603           0 :       } else if (!mozilla::IsFinite(arg4)) {
    2604           0 :         foundNonFiniteFloat = true;
    2605             :       }
    2606           0 :       if (foundNonFiniteFloat) {
    2607           0 :         args.rval().setUndefined();
    2608           0 :         return true;
    2609             :       }
    2610           0 :       binding_detail::FastErrorResult rv;
    2611           0 :       self->DrawImage(Constify(arg0), arg1, arg2, arg3, arg4, rv);
    2612           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2613           0 :         return false;
    2614             :       }
    2615           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2616           0 :       args.rval().setUndefined();
    2617           0 :       return true;
    2618             :       break;
    2619             :     }
    2620             :     case 9: {
    2621           0 :       bool foundNonFiniteFloat = false;
    2622           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
    2623           0 :       HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
    2624             :       {
    2625           0 :         bool done = false, failed = false, tryNext;
    2626           0 :         if (args[0].isObject()) {
    2627           0 :           done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
    2628           0 :                  (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
    2629           0 :                  (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
    2630           0 :                  (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
    2631             : 
    2632             :         }
    2633           0 :         if (failed) {
    2634           0 :           return false;
    2635             :         }
    2636           0 :         if (!done) {
    2637           0 :           ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
    2638           0 :           return false;
    2639             :         }
    2640             :       }
    2641             :       double arg1;
    2642           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    2643           0 :         return false;
    2644           0 :       } else if (!mozilla::IsFinite(arg1)) {
    2645           0 :         foundNonFiniteFloat = true;
    2646             :       }
    2647             :       double arg2;
    2648           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    2649           0 :         return false;
    2650           0 :       } else if (!mozilla::IsFinite(arg2)) {
    2651           0 :         foundNonFiniteFloat = true;
    2652             :       }
    2653             :       double arg3;
    2654           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    2655           0 :         return false;
    2656           0 :       } else if (!mozilla::IsFinite(arg3)) {
    2657           0 :         foundNonFiniteFloat = true;
    2658             :       }
    2659             :       double arg4;
    2660           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    2661           0 :         return false;
    2662           0 :       } else if (!mozilla::IsFinite(arg4)) {
    2663           0 :         foundNonFiniteFloat = true;
    2664             :       }
    2665             :       double arg5;
    2666           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    2667           0 :         return false;
    2668           0 :       } else if (!mozilla::IsFinite(arg5)) {
    2669           0 :         foundNonFiniteFloat = true;
    2670             :       }
    2671             :       double arg6;
    2672           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
    2673           0 :         return false;
    2674           0 :       } else if (!mozilla::IsFinite(arg6)) {
    2675           0 :         foundNonFiniteFloat = true;
    2676             :       }
    2677             :       double arg7;
    2678           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[7], &arg7)) {
    2679           0 :         return false;
    2680           0 :       } else if (!mozilla::IsFinite(arg7)) {
    2681           0 :         foundNonFiniteFloat = true;
    2682             :       }
    2683             :       double arg8;
    2684           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[8], &arg8)) {
    2685           0 :         return false;
    2686           0 :       } else if (!mozilla::IsFinite(arg8)) {
    2687           0 :         foundNonFiniteFloat = true;
    2688             :       }
    2689           0 :       if (foundNonFiniteFloat) {
    2690           0 :         args.rval().setUndefined();
    2691           0 :         return true;
    2692             :       }
    2693           0 :       binding_detail::FastErrorResult rv;
    2694           0 :       self->DrawImage(Constify(arg0), arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, rv);
    2695           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2696           0 :         return false;
    2697             :       }
    2698           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2699           0 :       args.rval().setUndefined();
    2700           0 :       return true;
    2701             :       break;
    2702             :     }
    2703             :     default: {
    2704           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawImage");
    2705             :       break;
    2706             :     }
    2707             :   }
    2708             :   MOZ_CRASH("We have an always-returning default case");
    2709             :   return false;
    2710             : }
    2711             : 
    2712             : static const JSJitInfo drawImage_methodinfo = {
    2713             :   { (JSJitGetterOp)drawImage },
    2714             :   { prototypes::id::CanvasRenderingContext2D },
    2715             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2716             :   JSJitInfo::Method,
    2717             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2718             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2719             :   false,  /* isInfallible. False in setters. */
    2720             :   false,  /* isMovable.  Not relevant for setters. */
    2721             :   false, /* isEliminatable.  Not relevant for setters. */
    2722             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2723             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2724             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2725             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2726             : };
    2727             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2728             : static_assert(0 < 1, "There is no slot for us");
    2729             : 
    2730             : static bool
    2731           0 : beginPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2732             : {
    2733           0 :   self->BeginPath();
    2734           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2735           0 :   args.rval().setUndefined();
    2736           0 :   return true;
    2737             : }
    2738             : 
    2739             : static const JSJitInfo beginPath_methodinfo = {
    2740             :   { (JSJitGetterOp)beginPath },
    2741             :   { prototypes::id::CanvasRenderingContext2D },
    2742             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2743             :   JSJitInfo::Method,
    2744             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2745             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2746             :   true,  /* isInfallible. False in setters. */
    2747             :   false,  /* isMovable.  Not relevant for setters. */
    2748             :   false, /* isEliminatable.  Not relevant for setters. */
    2749             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2750             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2751             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2752             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2753             : };
    2754             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2755             : static_assert(0 < 1, "There is no slot for us");
    2756             : 
    2757             : static bool
    2758           0 : fill(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2759             : {
    2760           0 :   unsigned argcount = std::min(args.length(), 2u);
    2761           0 :   switch (argcount) {
    2762             :     case 0: {
    2763             :       CanvasWindingRule arg0;
    2764           0 :       if (args.hasDefined(0)) {
    2765             :         {
    2766             :           int index;
    2767           0 :           if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.fill", &index)) {
    2768           0 :             return false;
    2769             :           }
    2770           0 :           MOZ_ASSERT(index >= 0);
    2771           0 :           arg0 = static_cast<CanvasWindingRule>(index);
    2772             :         }
    2773             :       } else {
    2774           0 :         arg0 = CanvasWindingRule::Nonzero;
    2775             :       }
    2776           0 :       self->Fill(arg0);
    2777           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2778           0 :       args.rval().setUndefined();
    2779           0 :       return true;
    2780             :       break;
    2781             :     }
    2782             :     case 1: {
    2783           0 :       if (args[0].isObject()) {
    2784             :         do {
    2785           0 :           NonNull<mozilla::dom::CanvasPath> arg0;
    2786             :           {
    2787           0 :             nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    2788           0 :             if (NS_FAILED(rv)) {
    2789           0 :               break;
    2790             :             }
    2791             :           }
    2792             :           CanvasWindingRule arg1;
    2793           0 :           if (args.hasDefined(1)) {
    2794             :             {
    2795             :               int index;
    2796           0 :               if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.fill", &index)) {
    2797           0 :                 return false;
    2798             :               }
    2799           0 :               MOZ_ASSERT(index >= 0);
    2800           0 :               arg1 = static_cast<CanvasWindingRule>(index);
    2801             :             }
    2802             :           } else {
    2803           0 :             arg1 = CanvasWindingRule::Nonzero;
    2804             :           }
    2805           0 :           self->Fill(NonNullHelper(arg0), arg1);
    2806           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2807           0 :           args.rval().setUndefined();
    2808           0 :           return true;
    2809             :         } while (0);
    2810             :       }
    2811             :       CanvasWindingRule arg0;
    2812           0 :       if (args.hasDefined(0)) {
    2813             :         {
    2814             :           int index;
    2815           0 :           if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.fill", &index)) {
    2816           0 :             return false;
    2817             :           }
    2818           0 :           MOZ_ASSERT(index >= 0);
    2819           0 :           arg0 = static_cast<CanvasWindingRule>(index);
    2820             :         }
    2821             :       } else {
    2822           0 :         arg0 = CanvasWindingRule::Nonzero;
    2823             :       }
    2824           0 :       self->Fill(arg0);
    2825           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2826           0 :       args.rval().setUndefined();
    2827           0 :       return true;
    2828             :       break;
    2829             :     }
    2830             :     case 2: {
    2831           0 :       NonNull<mozilla::dom::CanvasPath> arg0;
    2832           0 :       if (args[0].isObject()) {
    2833             :         {
    2834           0 :           nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    2835           0 :           if (NS_FAILED(rv)) {
    2836           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.fill", "Path2D");
    2837           0 :             return false;
    2838             :           }
    2839             :         }
    2840             :       } else {
    2841           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.fill");
    2842           0 :         return false;
    2843             :       }
    2844             :       CanvasWindingRule arg1;
    2845           0 :       if (args.hasDefined(1)) {
    2846             :         {
    2847             :           int index;
    2848           0 :           if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.fill", &index)) {
    2849           0 :             return false;
    2850             :           }
    2851           0 :           MOZ_ASSERT(index >= 0);
    2852           0 :           arg1 = static_cast<CanvasWindingRule>(index);
    2853             :         }
    2854             :       } else {
    2855           0 :         arg1 = CanvasWindingRule::Nonzero;
    2856             :       }
    2857           0 :       self->Fill(NonNullHelper(arg0), arg1);
    2858           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2859           0 :       args.rval().setUndefined();
    2860           0 :       return true;
    2861             :       break;
    2862             :     }
    2863             :     default: {
    2864           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fill");
    2865             :       break;
    2866             :     }
    2867             :   }
    2868             :   MOZ_CRASH("We have an always-returning default case");
    2869             :   return false;
    2870             : }
    2871             : 
    2872             : static const JSJitInfo fill_methodinfo = {
    2873             :   { (JSJitGetterOp)fill },
    2874             :   { prototypes::id::CanvasRenderingContext2D },
    2875             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2876             :   JSJitInfo::Method,
    2877             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2878             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2879             :   false,  /* isInfallible. False in setters. */
    2880             :   false,  /* isMovable.  Not relevant for setters. */
    2881             :   false, /* isEliminatable.  Not relevant for setters. */
    2882             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2883             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2884             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2885             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2886             : };
    2887             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2888             : static_assert(0 < 1, "There is no slot for us");
    2889             : 
    2890             : static bool
    2891           0 : stroke(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2892             : {
    2893           0 :   unsigned argcount = std::min(args.length(), 1u);
    2894           0 :   switch (argcount) {
    2895             :     case 0: {
    2896           0 :       self->Stroke();
    2897           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2898           0 :       args.rval().setUndefined();
    2899           0 :       return true;
    2900             :       break;
    2901             :     }
    2902             :     case 1: {
    2903           0 :       NonNull<mozilla::dom::CanvasPath> arg0;
    2904           0 :       if (args[0].isObject()) {
    2905             :         {
    2906           0 :           nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    2907           0 :           if (NS_FAILED(rv)) {
    2908           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.stroke", "Path2D");
    2909           0 :             return false;
    2910             :           }
    2911             :         }
    2912             :       } else {
    2913           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.stroke");
    2914           0 :         return false;
    2915             :       }
    2916           0 :       self->Stroke(NonNullHelper(arg0));
    2917           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2918           0 :       args.rval().setUndefined();
    2919           0 :       return true;
    2920             :       break;
    2921             :     }
    2922             :     default: {
    2923           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.stroke");
    2924             :       break;
    2925             :     }
    2926             :   }
    2927             :   MOZ_CRASH("We have an always-returning default case");
    2928             :   return false;
    2929             : }
    2930             : 
    2931             : static const JSJitInfo stroke_methodinfo = {
    2932             :   { (JSJitGetterOp)stroke },
    2933             :   { prototypes::id::CanvasRenderingContext2D },
    2934             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    2935             :   JSJitInfo::Method,
    2936             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2937             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    2938             :   false,  /* isInfallible. False in setters. */
    2939             :   false,  /* isMovable.  Not relevant for setters. */
    2940             :   false, /* isEliminatable.  Not relevant for setters. */
    2941             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2942             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2943             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2944             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2945             : };
    2946             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2947             : static_assert(0 < 1, "There is no slot for us");
    2948             : 
    2949             : static bool
    2950           0 : clip(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    2951             : {
    2952           0 :   unsigned argcount = std::min(args.length(), 2u);
    2953           0 :   switch (argcount) {
    2954             :     case 0: {
    2955             :       CanvasWindingRule arg0;
    2956           0 :       if (args.hasDefined(0)) {
    2957             :         {
    2958             :           int index;
    2959           0 :           if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.clip", &index)) {
    2960           0 :             return false;
    2961             :           }
    2962           0 :           MOZ_ASSERT(index >= 0);
    2963           0 :           arg0 = static_cast<CanvasWindingRule>(index);
    2964             :         }
    2965             :       } else {
    2966           0 :         arg0 = CanvasWindingRule::Nonzero;
    2967             :       }
    2968           0 :       self->Clip(arg0);
    2969           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2970           0 :       args.rval().setUndefined();
    2971           0 :       return true;
    2972             :       break;
    2973             :     }
    2974             :     case 1: {
    2975           0 :       if (args[0].isObject()) {
    2976             :         do {
    2977           0 :           NonNull<mozilla::dom::CanvasPath> arg0;
    2978             :           {
    2979           0 :             nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    2980           0 :             if (NS_FAILED(rv)) {
    2981           0 :               break;
    2982             :             }
    2983             :           }
    2984             :           CanvasWindingRule arg1;
    2985           0 :           if (args.hasDefined(1)) {
    2986             :             {
    2987             :               int index;
    2988           0 :               if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.clip", &index)) {
    2989           0 :                 return false;
    2990             :               }
    2991           0 :               MOZ_ASSERT(index >= 0);
    2992           0 :               arg1 = static_cast<CanvasWindingRule>(index);
    2993             :             }
    2994             :           } else {
    2995           0 :             arg1 = CanvasWindingRule::Nonzero;
    2996             :           }
    2997           0 :           self->Clip(NonNullHelper(arg0), arg1);
    2998           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2999           0 :           args.rval().setUndefined();
    3000           0 :           return true;
    3001             :         } while (0);
    3002             :       }
    3003             :       CanvasWindingRule arg0;
    3004           0 :       if (args.hasDefined(0)) {
    3005             :         {
    3006             :           int index;
    3007           0 :           if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.clip", &index)) {
    3008           0 :             return false;
    3009             :           }
    3010           0 :           MOZ_ASSERT(index >= 0);
    3011           0 :           arg0 = static_cast<CanvasWindingRule>(index);
    3012             :         }
    3013             :       } else {
    3014           0 :         arg0 = CanvasWindingRule::Nonzero;
    3015             :       }
    3016           0 :       self->Clip(arg0);
    3017           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3018           0 :       args.rval().setUndefined();
    3019           0 :       return true;
    3020             :       break;
    3021             :     }
    3022             :     case 2: {
    3023           0 :       NonNull<mozilla::dom::CanvasPath> arg0;
    3024           0 :       if (args[0].isObject()) {
    3025             :         {
    3026           0 :           nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    3027           0 :           if (NS_FAILED(rv)) {
    3028           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.clip", "Path2D");
    3029           0 :             return false;
    3030             :           }
    3031             :         }
    3032             :       } else {
    3033           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.clip");
    3034           0 :         return false;
    3035             :       }
    3036             :       CanvasWindingRule arg1;
    3037           0 :       if (args.hasDefined(1)) {
    3038             :         {
    3039             :           int index;
    3040           0 :           if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.clip", &index)) {
    3041           0 :             return false;
    3042             :           }
    3043           0 :           MOZ_ASSERT(index >= 0);
    3044           0 :           arg1 = static_cast<CanvasWindingRule>(index);
    3045             :         }
    3046             :       } else {
    3047           0 :         arg1 = CanvasWindingRule::Nonzero;
    3048             :       }
    3049           0 :       self->Clip(NonNullHelper(arg0), arg1);
    3050           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3051           0 :       args.rval().setUndefined();
    3052           0 :       return true;
    3053             :       break;
    3054             :     }
    3055             :     default: {
    3056           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.clip");
    3057             :       break;
    3058             :     }
    3059             :   }
    3060             :   MOZ_CRASH("We have an always-returning default case");
    3061             :   return false;
    3062             : }
    3063             : 
    3064             : static const JSJitInfo clip_methodinfo = {
    3065             :   { (JSJitGetterOp)clip },
    3066             :   { prototypes::id::CanvasRenderingContext2D },
    3067             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3068             :   JSJitInfo::Method,
    3069             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3070             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3071             :   false,  /* isInfallible. False in setters. */
    3072             :   false,  /* isMovable.  Not relevant for setters. */
    3073             :   false, /* isEliminatable.  Not relevant for setters. */
    3074             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3075             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3076             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3077             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3078             : };
    3079             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3080             : static_assert(0 < 1, "There is no slot for us");
    3081             : 
    3082             : static bool
    3083           0 : isPointInPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3084             : {
    3085           0 :   unsigned argcount = std::min(args.length(), 4u);
    3086           0 :   switch (argcount) {
    3087             :     case 2: {
    3088             :       double arg0;
    3089           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3090           0 :         return false;
    3091             :       }
    3092             :       double arg1;
    3093           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3094           0 :         return false;
    3095             :       }
    3096             :       CanvasWindingRule arg2;
    3097           0 :       if (args.hasDefined(2)) {
    3098             :         {
    3099             :           int index;
    3100           0 :           if (!FindEnumStringIndex<true>(cx, args[2], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 3 of CanvasRenderingContext2D.isPointInPath", &index)) {
    3101           0 :             return false;
    3102             :           }
    3103           0 :           MOZ_ASSERT(index >= 0);
    3104           0 :           arg2 = static_cast<CanvasWindingRule>(index);
    3105             :         }
    3106             :       } else {
    3107           0 :         arg2 = CanvasWindingRule::Nonzero;
    3108             :       }
    3109           0 :       bool result(self->IsPointInPath(arg0, arg1, arg2));
    3110           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3111           0 :       args.rval().setBoolean(result);
    3112           0 :       return true;
    3113             :       break;
    3114             :     }
    3115             :     case 3: {
    3116           0 :       if (args[0].isObject()) {
    3117             :         do {
    3118           0 :           NonNull<mozilla::dom::CanvasPath> arg0;
    3119             :           {
    3120           0 :             nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    3121           0 :             if (NS_FAILED(rv)) {
    3122           0 :               break;
    3123             :             }
    3124             :           }
    3125             :           double arg1;
    3126           0 :           if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3127           0 :             return false;
    3128             :           }
    3129             :           double arg2;
    3130           0 :           if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3131           0 :             return false;
    3132             :           }
    3133             :           CanvasWindingRule arg3;
    3134           0 :           if (args.hasDefined(3)) {
    3135             :             {
    3136             :               int index;
    3137           0 :               if (!FindEnumStringIndex<true>(cx, args[3], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 4 of CanvasRenderingContext2D.isPointInPath", &index)) {
    3138           0 :                 return false;
    3139             :               }
    3140           0 :               MOZ_ASSERT(index >= 0);
    3141           0 :               arg3 = static_cast<CanvasWindingRule>(index);
    3142             :             }
    3143             :           } else {
    3144           0 :             arg3 = CanvasWindingRule::Nonzero;
    3145             :           }
    3146           0 :           bool result(self->IsPointInPath(NonNullHelper(arg0), arg1, arg2, arg3));
    3147           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3148           0 :           args.rval().setBoolean(result);
    3149           0 :           return true;
    3150             :         } while (0);
    3151             :       }
    3152             :       double arg0;
    3153           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3154           0 :         return false;
    3155             :       }
    3156             :       double arg1;
    3157           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3158           0 :         return false;
    3159             :       }
    3160             :       CanvasWindingRule arg2;
    3161           0 :       if (args.hasDefined(2)) {
    3162             :         {
    3163             :           int index;
    3164           0 :           if (!FindEnumStringIndex<true>(cx, args[2], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 3 of CanvasRenderingContext2D.isPointInPath", &index)) {
    3165           0 :             return false;
    3166             :           }
    3167           0 :           MOZ_ASSERT(index >= 0);
    3168           0 :           arg2 = static_cast<CanvasWindingRule>(index);
    3169             :         }
    3170             :       } else {
    3171           0 :         arg2 = CanvasWindingRule::Nonzero;
    3172             :       }
    3173           0 :       bool result(self->IsPointInPath(arg0, arg1, arg2));
    3174           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3175           0 :       args.rval().setBoolean(result);
    3176           0 :       return true;
    3177             :       break;
    3178             :     }
    3179             :     case 4: {
    3180           0 :       NonNull<mozilla::dom::CanvasPath> arg0;
    3181           0 :       if (args[0].isObject()) {
    3182             :         {
    3183           0 :           nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    3184           0 :           if (NS_FAILED(rv)) {
    3185           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.isPointInPath", "Path2D");
    3186           0 :             return false;
    3187             :           }
    3188             :         }
    3189             :       } else {
    3190           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.isPointInPath");
    3191           0 :         return false;
    3192             :       }
    3193             :       double arg1;
    3194           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3195           0 :         return false;
    3196             :       }
    3197             :       double arg2;
    3198           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3199           0 :         return false;
    3200             :       }
    3201             :       CanvasWindingRule arg3;
    3202           0 :       if (args.hasDefined(3)) {
    3203             :         {
    3204             :           int index;
    3205           0 :           if (!FindEnumStringIndex<true>(cx, args[3], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 4 of CanvasRenderingContext2D.isPointInPath", &index)) {
    3206           0 :             return false;
    3207             :           }
    3208           0 :           MOZ_ASSERT(index >= 0);
    3209           0 :           arg3 = static_cast<CanvasWindingRule>(index);
    3210             :         }
    3211             :       } else {
    3212           0 :         arg3 = CanvasWindingRule::Nonzero;
    3213             :       }
    3214           0 :       bool result(self->IsPointInPath(NonNullHelper(arg0), arg1, arg2, arg3));
    3215           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3216           0 :       args.rval().setBoolean(result);
    3217           0 :       return true;
    3218             :       break;
    3219             :     }
    3220             :     default: {
    3221           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.isPointInPath");
    3222             :       break;
    3223             :     }
    3224             :   }
    3225             :   MOZ_CRASH("We have an always-returning default case");
    3226             :   return false;
    3227             : }
    3228             : 
    3229             : static const JSJitInfo isPointInPath_methodinfo = {
    3230             :   { (JSJitGetterOp)isPointInPath },
    3231             :   { prototypes::id::CanvasRenderingContext2D },
    3232             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3233             :   JSJitInfo::Method,
    3234             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3235             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    3236             :   false,  /* isInfallible. False in setters. */
    3237             :   false,  /* isMovable.  Not relevant for setters. */
    3238             :   false, /* isEliminatable.  Not relevant for setters. */
    3239             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3240             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3241             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3242             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3243             : };
    3244             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3245             : static_assert(0 < 1, "There is no slot for us");
    3246             : 
    3247             : static bool
    3248           0 : isPointInStroke(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3249             : {
    3250           0 :   unsigned argcount = std::min(args.length(), 3u);
    3251           0 :   switch (argcount) {
    3252             :     case 2: {
    3253             :       double arg0;
    3254           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3255           0 :         return false;
    3256           0 :       } else if (!mozilla::IsFinite(arg0)) {
    3257           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.isPointInStroke");
    3258           0 :         return false;
    3259             :       }
    3260             :       double arg1;
    3261           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3262           0 :         return false;
    3263           0 :       } else if (!mozilla::IsFinite(arg1)) {
    3264           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.isPointInStroke");
    3265           0 :         return false;
    3266             :       }
    3267           0 :       bool result(self->IsPointInStroke(arg0, arg1));
    3268           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3269           0 :       args.rval().setBoolean(result);
    3270           0 :       return true;
    3271             :       break;
    3272             :     }
    3273             :     case 3: {
    3274           0 :       NonNull<mozilla::dom::CanvasPath> arg0;
    3275           0 :       if (args[0].isObject()) {
    3276             :         {
    3277           0 :           nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    3278           0 :           if (NS_FAILED(rv)) {
    3279           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.isPointInStroke", "Path2D");
    3280           0 :             return false;
    3281             :           }
    3282             :         }
    3283             :       } else {
    3284           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.isPointInStroke");
    3285           0 :         return false;
    3286             :       }
    3287             :       double arg1;
    3288           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3289           0 :         return false;
    3290             :       }
    3291             :       double arg2;
    3292           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3293           0 :         return false;
    3294             :       }
    3295           0 :       bool result(self->IsPointInStroke(NonNullHelper(arg0), arg1, arg2));
    3296           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3297           0 :       args.rval().setBoolean(result);
    3298           0 :       return true;
    3299             :       break;
    3300             :     }
    3301             :     default: {
    3302           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.isPointInStroke");
    3303             :       break;
    3304             :     }
    3305             :   }
    3306             :   MOZ_CRASH("We have an always-returning default case");
    3307             :   return false;
    3308             : }
    3309             : 
    3310             : static const JSJitInfo isPointInStroke_methodinfo = {
    3311             :   { (JSJitGetterOp)isPointInStroke },
    3312             :   { prototypes::id::CanvasRenderingContext2D },
    3313             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3314             :   JSJitInfo::Method,
    3315             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3316             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    3317             :   false,  /* isInfallible. False in setters. */
    3318             :   false,  /* isMovable.  Not relevant for setters. */
    3319             :   false, /* isEliminatable.  Not relevant for setters. */
    3320             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3321             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3322             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3323             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3324             : };
    3325             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3326             : static_assert(0 < 1, "There is no slot for us");
    3327             : 
    3328             : static bool
    3329           0 : get_strokeStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    3330             : {
    3331           0 :   OwningStringOrCanvasGradientOrCanvasPattern result;
    3332           0 :   self->GetStrokeStyle(result);
    3333           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3334           0 :   if (!result.ToJSVal(cx, obj, args.rval())) {
    3335           0 :     return false;
    3336             :   }
    3337           0 :   return true;
    3338             : }
    3339             : 
    3340             : static bool
    3341           0 : set_strokeStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    3342             : {
    3343           0 :   StringOrCanvasGradientOrCanvasPattern arg0;
    3344           0 :   StringOrCanvasGradientOrCanvasPatternArgument arg0_holder(arg0);
    3345             :   {
    3346           0 :     bool done = false, failed = false, tryNext;
    3347           0 :     if (args[0].isObject()) {
    3348           0 :       done = (failed = !arg0_holder.TrySetToCanvasGradient(cx, args[0], tryNext, false)) || !tryNext ||
    3349           0 :              (failed = !arg0_holder.TrySetToCanvasPattern(cx, args[0], tryNext, false)) || !tryNext;
    3350             : 
    3351             :     }
    3352           0 :     if (!done) {
    3353             :       do {
    3354           0 :         done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
    3355           0 :         break;
    3356             :       } while (0);
    3357             :     }
    3358           0 :     if (failed) {
    3359           0 :       return false;
    3360             :     }
    3361           0 :     if (!done) {
    3362           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to CanvasRenderingContext2D.strokeStyle", "CanvasGradient, CanvasPattern");
    3363           0 :       return false;
    3364             :     }
    3365             :   }
    3366           0 :   self->SetStrokeStyle(Constify(arg0));
    3367           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3368             : 
    3369           0 :   return true;
    3370             : }
    3371             : 
    3372             : static const JSJitInfo strokeStyle_getterinfo = {
    3373             :   { (JSJitGetterOp)get_strokeStyle },
    3374             :   { prototypes::id::CanvasRenderingContext2D },
    3375             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3376             :   JSJitInfo::Getter,
    3377             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3378             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3379             :   false,  /* isInfallible. False in setters. */
    3380             :   false,  /* isMovable.  Not relevant for setters. */
    3381             :   false, /* isEliminatable.  Not relevant for setters. */
    3382             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3383             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3384             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3385             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3386             : };
    3387             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3388             : static_assert(0 < 1, "There is no slot for us");
    3389             : static const JSJitInfo strokeStyle_setterinfo = {
    3390             :   { (JSJitGetterOp)set_strokeStyle },
    3391             :   { prototypes::id::CanvasRenderingContext2D },
    3392             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3393             :   JSJitInfo::Setter,
    3394             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3395             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3396             :   false,  /* isInfallible. False in setters. */
    3397             :   false,  /* isMovable.  Not relevant for setters. */
    3398             :   false, /* isEliminatable.  Not relevant for setters. */
    3399             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3400             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3401             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3402             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3403             : };
    3404             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3405             : static_assert(0 < 1, "There is no slot for us");
    3406             : 
    3407             : static bool
    3408           0 : get_fillStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    3409             : {
    3410           0 :   OwningStringOrCanvasGradientOrCanvasPattern result;
    3411           0 :   self->GetFillStyle(result);
    3412           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3413           0 :   if (!result.ToJSVal(cx, obj, args.rval())) {
    3414           0 :     return false;
    3415             :   }
    3416           0 :   return true;
    3417             : }
    3418             : 
    3419             : static bool
    3420           0 : set_fillStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    3421             : {
    3422           0 :   StringOrCanvasGradientOrCanvasPattern arg0;
    3423           0 :   StringOrCanvasGradientOrCanvasPatternArgument arg0_holder(arg0);
    3424             :   {
    3425           0 :     bool done = false, failed = false, tryNext;
    3426           0 :     if (args[0].isObject()) {
    3427           0 :       done = (failed = !arg0_holder.TrySetToCanvasGradient(cx, args[0], tryNext, false)) || !tryNext ||
    3428           0 :              (failed = !arg0_holder.TrySetToCanvasPattern(cx, args[0], tryNext, false)) || !tryNext;
    3429             : 
    3430             :     }
    3431           0 :     if (!done) {
    3432             :       do {
    3433           0 :         done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
    3434           0 :         break;
    3435             :       } while (0);
    3436             :     }
    3437           0 :     if (failed) {
    3438           0 :       return false;
    3439             :     }
    3440           0 :     if (!done) {
    3441           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to CanvasRenderingContext2D.fillStyle", "CanvasGradient, CanvasPattern");
    3442           0 :       return false;
    3443             :     }
    3444             :   }
    3445           0 :   self->SetFillStyle(Constify(arg0));
    3446           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3447             : 
    3448           0 :   return true;
    3449             : }
    3450             : 
    3451             : static const JSJitInfo fillStyle_getterinfo = {
    3452             :   { (JSJitGetterOp)get_fillStyle },
    3453             :   { prototypes::id::CanvasRenderingContext2D },
    3454             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3455             :   JSJitInfo::Getter,
    3456             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3457             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3458             :   false,  /* isInfallible. False in setters. */
    3459             :   false,  /* isMovable.  Not relevant for setters. */
    3460             :   false, /* isEliminatable.  Not relevant for setters. */
    3461             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3462             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3463             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3464             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3465             : };
    3466             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3467             : static_assert(0 < 1, "There is no slot for us");
    3468             : static const JSJitInfo fillStyle_setterinfo = {
    3469             :   { (JSJitGetterOp)set_fillStyle },
    3470             :   { prototypes::id::CanvasRenderingContext2D },
    3471             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3472             :   JSJitInfo::Setter,
    3473             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3474             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3475             :   false,  /* isInfallible. False in setters. */
    3476             :   false,  /* isMovable.  Not relevant for setters. */
    3477             :   false, /* isEliminatable.  Not relevant for setters. */
    3478             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3479             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3480             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3481             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3482             : };
    3483             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3484             : static_assert(0 < 1, "There is no slot for us");
    3485             : 
    3486             : static bool
    3487           0 : createLinearGradient(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3488             : {
    3489           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    3490           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createLinearGradient");
    3491             :   }
    3492             :   double arg0;
    3493           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3494           0 :     return false;
    3495           0 :   } else if (!mozilla::IsFinite(arg0)) {
    3496           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createLinearGradient");
    3497           0 :     return false;
    3498             :   }
    3499             :   double arg1;
    3500           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3501           0 :     return false;
    3502           0 :   } else if (!mozilla::IsFinite(arg1)) {
    3503           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createLinearGradient");
    3504           0 :     return false;
    3505             :   }
    3506             :   double arg2;
    3507           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3508           0 :     return false;
    3509           0 :   } else if (!mozilla::IsFinite(arg2)) {
    3510           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.createLinearGradient");
    3511           0 :     return false;
    3512             :   }
    3513             :   double arg3;
    3514           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    3515           0 :     return false;
    3516           0 :   } else if (!mozilla::IsFinite(arg3)) {
    3517           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.createLinearGradient");
    3518           0 :     return false;
    3519             :   }
    3520           0 :   auto result(StrongOrRawPtr<mozilla::dom::CanvasGradient>(self->CreateLinearGradient(arg0, arg1, arg2, arg3)));
    3521           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3522             :   static_assert(!IsPointer<decltype(result)>::value,
    3523             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    3524           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    3525           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3526           0 :     return false;
    3527             :   }
    3528           0 :   return true;
    3529             : }
    3530             : 
    3531             : static const JSJitInfo createLinearGradient_methodinfo = {
    3532             :   { (JSJitGetterOp)createLinearGradient },
    3533             :   { prototypes::id::CanvasRenderingContext2D },
    3534             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3535             :   JSJitInfo::Method,
    3536             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3537             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3538             :   false,  /* isInfallible. False in setters. */
    3539             :   false,  /* isMovable.  Not relevant for setters. */
    3540             :   false, /* isEliminatable.  Not relevant for setters. */
    3541             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3542             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3543             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3544             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3545             : };
    3546             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3547             : static_assert(0 < 1, "There is no slot for us");
    3548             : 
    3549             : static bool
    3550           0 : createRadialGradient(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3551             : {
    3552           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    3553           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createRadialGradient");
    3554             :   }
    3555             :   double arg0;
    3556           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3557           0 :     return false;
    3558           0 :   } else if (!mozilla::IsFinite(arg0)) {
    3559           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createRadialGradient");
    3560           0 :     return false;
    3561             :   }
    3562             :   double arg1;
    3563           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3564           0 :     return false;
    3565           0 :   } else if (!mozilla::IsFinite(arg1)) {
    3566           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createRadialGradient");
    3567           0 :     return false;
    3568             :   }
    3569             :   double arg2;
    3570           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3571           0 :     return false;
    3572           0 :   } else if (!mozilla::IsFinite(arg2)) {
    3573           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.createRadialGradient");
    3574           0 :     return false;
    3575             :   }
    3576             :   double arg3;
    3577           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    3578           0 :     return false;
    3579           0 :   } else if (!mozilla::IsFinite(arg3)) {
    3580           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.createRadialGradient");
    3581           0 :     return false;
    3582             :   }
    3583             :   double arg4;
    3584           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    3585           0 :     return false;
    3586           0 :   } else if (!mozilla::IsFinite(arg4)) {
    3587           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.createRadialGradient");
    3588           0 :     return false;
    3589             :   }
    3590             :   double arg5;
    3591           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    3592           0 :     return false;
    3593           0 :   } else if (!mozilla::IsFinite(arg5)) {
    3594           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 6 of CanvasRenderingContext2D.createRadialGradient");
    3595           0 :     return false;
    3596             :   }
    3597           0 :   binding_detail::FastErrorResult rv;
    3598           0 :   auto result(StrongOrRawPtr<mozilla::dom::CanvasGradient>(self->CreateRadialGradient(arg0, arg1, arg2, arg3, arg4, arg5, rv)));
    3599           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3600           0 :     return false;
    3601             :   }
    3602           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3603             :   static_assert(!IsPointer<decltype(result)>::value,
    3604             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    3605           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    3606           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3607           0 :     return false;
    3608             :   }
    3609           0 :   return true;
    3610             : }
    3611             : 
    3612             : static const JSJitInfo createRadialGradient_methodinfo = {
    3613             :   { (JSJitGetterOp)createRadialGradient },
    3614             :   { prototypes::id::CanvasRenderingContext2D },
    3615             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3616             :   JSJitInfo::Method,
    3617             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3618             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3619             :   false,  /* isInfallible. False in setters. */
    3620             :   false,  /* isMovable.  Not relevant for setters. */
    3621             :   false, /* isEliminatable.  Not relevant for setters. */
    3622             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3623             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3624             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3625             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3626             : };
    3627             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3628             : static_assert(0 < 1, "There is no slot for us");
    3629             : 
    3630             : static bool
    3631           0 : createPattern(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3632             : {
    3633           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    3634           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createPattern");
    3635             :   }
    3636           0 :   HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
    3637           0 :   HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
    3638             :   {
    3639           0 :     bool done = false, failed = false, tryNext;
    3640           0 :     if (args[0].isObject()) {
    3641           0 :       done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
    3642           0 :              (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
    3643           0 :              (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
    3644           0 :              (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
    3645             : 
    3646             :     }
    3647           0 :     if (failed) {
    3648           0 :       return false;
    3649             :     }
    3650           0 :     if (!done) {
    3651           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.createPattern", "HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
    3652           0 :       return false;
    3653             :     }
    3654             :   }
    3655           0 :   binding_detail::FakeString arg1;
    3656           0 :   if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) {
    3657           0 :     return false;
    3658             :   }
    3659           0 :   binding_detail::FastErrorResult rv;
    3660           0 :   auto result(StrongOrRawPtr<mozilla::dom::CanvasPattern>(self->CreatePattern(Constify(arg0), NonNullHelper(Constify(arg1)), rv)));
    3661           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3662           0 :     return false;
    3663             :   }
    3664           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3665             :   static_assert(!IsPointer<decltype(result)>::value,
    3666             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    3667           0 :   if (!result) {
    3668           0 :     args.rval().setNull();
    3669           0 :     return true;
    3670             :   }
    3671           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    3672           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3673           0 :     return false;
    3674             :   }
    3675           0 :   return true;
    3676             : }
    3677             : 
    3678             : static const JSJitInfo createPattern_methodinfo = {
    3679             :   { (JSJitGetterOp)createPattern },
    3680             :   { prototypes::id::CanvasRenderingContext2D },
    3681             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3682             :   JSJitInfo::Method,
    3683             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3684             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3685             :   false,  /* isInfallible. False in setters. */
    3686             :   false,  /* isMovable.  Not relevant for setters. */
    3687             :   false, /* isEliminatable.  Not relevant for setters. */
    3688             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3689             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3690             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3691             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3692             : };
    3693             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3694             : static_assert(0 < 1, "There is no slot for us");
    3695             : 
    3696             : static bool
    3697           0 : get_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    3698             : {
    3699           0 :   DOMString result;
    3700           0 :   self->GetFilter(result);
    3701           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3702           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    3703           0 :     return false;
    3704             :   }
    3705           0 :   return true;
    3706             : }
    3707             : 
    3708             : static bool
    3709           0 : set_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    3710             : {
    3711           0 :   binding_detail::FakeString arg0;
    3712           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    3713           0 :     return false;
    3714             :   }
    3715           0 :   binding_detail::FastErrorResult rv;
    3716           0 :   self->SetFilter(NonNullHelper(Constify(arg0)), rv);
    3717           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3718           0 :     return false;
    3719             :   }
    3720           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3721             : 
    3722           0 :   return true;
    3723             : }
    3724             : 
    3725             : static const JSJitInfo filter_getterinfo = {
    3726             :   { (JSJitGetterOp)get_filter },
    3727             :   { prototypes::id::CanvasRenderingContext2D },
    3728             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3729             :   JSJitInfo::Getter,
    3730             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3731             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    3732             :   false,  /* isInfallible. False in setters. */
    3733             :   false,  /* isMovable.  Not relevant for setters. */
    3734             :   false, /* isEliminatable.  Not relevant for setters. */
    3735             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3736             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3737             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3738             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3739             : };
    3740             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3741             : static_assert(0 < 1, "There is no slot for us");
    3742             : static const JSJitInfo filter_setterinfo = {
    3743             :   { (JSJitGetterOp)set_filter },
    3744             :   { prototypes::id::CanvasRenderingContext2D },
    3745             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3746             :   JSJitInfo::Setter,
    3747             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3748             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3749             :   false,  /* isInfallible. False in setters. */
    3750             :   false,  /* isMovable.  Not relevant for setters. */
    3751             :   false, /* isEliminatable.  Not relevant for setters. */
    3752             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3753             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3754             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3755             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3756             : };
    3757             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3758             : static_assert(0 < 1, "There is no slot for us");
    3759             : 
    3760             : static bool
    3761           0 : addHitRegion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3762             : {
    3763           0 :   binding_detail::FastHitRegionOptions arg0;
    3764           0 :   if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of CanvasRenderingContext2D.addHitRegion", false)) {
    3765           0 :     return false;
    3766             :   }
    3767           0 :   binding_detail::FastErrorResult rv;
    3768           0 :   self->AddHitRegion(Constify(arg0), rv);
    3769           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3770           0 :     return false;
    3771             :   }
    3772           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3773           0 :   args.rval().setUndefined();
    3774           0 :   return true;
    3775             : }
    3776             : 
    3777             : static const JSJitInfo addHitRegion_methodinfo = {
    3778             :   { (JSJitGetterOp)addHitRegion },
    3779             :   { prototypes::id::CanvasRenderingContext2D },
    3780             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3781             :   JSJitInfo::Method,
    3782             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3783             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3784             :   false,  /* isInfallible. False in setters. */
    3785             :   false,  /* isMovable.  Not relevant for setters. */
    3786             :   false, /* isEliminatable.  Not relevant for setters. */
    3787             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3788             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3789             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3790             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3791             : };
    3792             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3793             : static_assert(0 < 1, "There is no slot for us");
    3794             : 
    3795             : static bool
    3796           0 : removeHitRegion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3797             : {
    3798           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    3799           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.removeHitRegion");
    3800             :   }
    3801           0 :   binding_detail::FakeString arg0;
    3802           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    3803           0 :     return false;
    3804             :   }
    3805           0 :   self->RemoveHitRegion(NonNullHelper(Constify(arg0)));
    3806           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3807           0 :   args.rval().setUndefined();
    3808           0 :   return true;
    3809             : }
    3810             : 
    3811             : static const JSJitInfo removeHitRegion_methodinfo = {
    3812             :   { (JSJitGetterOp)removeHitRegion },
    3813             :   { prototypes::id::CanvasRenderingContext2D },
    3814             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3815             :   JSJitInfo::Method,
    3816             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3817             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3818             :   false,  /* isInfallible. False in setters. */
    3819             :   false,  /* isMovable.  Not relevant for setters. */
    3820             :   false, /* isEliminatable.  Not relevant for setters. */
    3821             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3822             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3823             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3824             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3825             : };
    3826             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3827             : static_assert(0 < 1, "There is no slot for us");
    3828             : 
    3829             : static bool
    3830           0 : clearHitRegions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3831             : {
    3832           0 :   self->ClearHitRegions();
    3833           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3834           0 :   args.rval().setUndefined();
    3835           0 :   return true;
    3836             : }
    3837             : 
    3838             : static const JSJitInfo clearHitRegions_methodinfo = {
    3839             :   { (JSJitGetterOp)clearHitRegions },
    3840             :   { prototypes::id::CanvasRenderingContext2D },
    3841             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3842             :   JSJitInfo::Method,
    3843             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3844             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    3845             :   true,  /* isInfallible. False in setters. */
    3846             :   false,  /* isMovable.  Not relevant for setters. */
    3847             :   false, /* isEliminatable.  Not relevant for setters. */
    3848             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3849             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3850             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3851             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3852             : };
    3853             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3854             : static_assert(0 < 1, "There is no slot for us");
    3855             : 
    3856             : static bool
    3857           0 : createImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3858             : {
    3859           0 :   unsigned argcount = std::min(args.length(), 2u);
    3860           0 :   switch (argcount) {
    3861             :     case 1: {
    3862           0 :       NonNull<mozilla::dom::ImageData> arg0;
    3863           0 :       if (args[0].isObject()) {
    3864             :         {
    3865           0 :           nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
    3866           0 :           if (NS_FAILED(rv)) {
    3867           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.createImageData", "ImageData");
    3868           0 :             return false;
    3869             :           }
    3870             :         }
    3871             :       } else {
    3872           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.createImageData");
    3873           0 :         return false;
    3874             :       }
    3875           0 :       binding_detail::FastErrorResult rv;
    3876           0 :       auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->CreateImageData(cx, NonNullHelper(arg0), rv)));
    3877           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3878           0 :         return false;
    3879             :       }
    3880           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3881             :       static_assert(!IsPointer<decltype(result)>::value,
    3882             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    3883           0 :       if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
    3884           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3885           0 :         return false;
    3886             :       }
    3887           0 :       return true;
    3888             :       break;
    3889             :     }
    3890             :     case 2: {
    3891             :       double arg0;
    3892           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3893           0 :         return false;
    3894           0 :       } else if (!mozilla::IsFinite(arg0)) {
    3895           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createImageData");
    3896           0 :         return false;
    3897             :       }
    3898             :       double arg1;
    3899           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3900           0 :         return false;
    3901           0 :       } else if (!mozilla::IsFinite(arg1)) {
    3902           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createImageData");
    3903           0 :         return false;
    3904             :       }
    3905           0 :       binding_detail::FastErrorResult rv;
    3906           0 :       auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->CreateImageData(cx, arg0, arg1, rv)));
    3907           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3908           0 :         return false;
    3909             :       }
    3910           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3911             :       static_assert(!IsPointer<decltype(result)>::value,
    3912             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    3913           0 :       if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
    3914           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3915           0 :         return false;
    3916             :       }
    3917           0 :       return true;
    3918             :       break;
    3919             :     }
    3920             :     default: {
    3921           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createImageData");
    3922             :       break;
    3923             :     }
    3924             :   }
    3925             :   MOZ_CRASH("We have an always-returning default case");
    3926             :   return false;
    3927             : }
    3928             : 
    3929             : static const JSJitInfo createImageData_methodinfo = {
    3930             :   { (JSJitGetterOp)createImageData },
    3931             :   { prototypes::id::CanvasRenderingContext2D },
    3932             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    3933             :   JSJitInfo::Method,
    3934             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3935             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3936             :   false,  /* isInfallible. False in setters. */
    3937             :   false,  /* isMovable.  Not relevant for setters. */
    3938             :   false, /* isEliminatable.  Not relevant for setters. */
    3939             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3940             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3941             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3942             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3943             : };
    3944             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3945             : static_assert(0 < 1, "There is no slot for us");
    3946             : 
    3947             : static bool
    3948           0 : getImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    3949             : {
    3950           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    3951           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.getImageData");
    3952             :   }
    3953             :   double arg0;
    3954           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    3955           0 :     return false;
    3956           0 :   } else if (!mozilla::IsFinite(arg0)) {
    3957           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.getImageData");
    3958           0 :     return false;
    3959             :   }
    3960             :   double arg1;
    3961           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    3962           0 :     return false;
    3963           0 :   } else if (!mozilla::IsFinite(arg1)) {
    3964           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.getImageData");
    3965           0 :     return false;
    3966             :   }
    3967             :   double arg2;
    3968           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    3969           0 :     return false;
    3970           0 :   } else if (!mozilla::IsFinite(arg2)) {
    3971           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.getImageData");
    3972           0 :     return false;
    3973             :   }
    3974             :   double arg3;
    3975           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    3976           0 :     return false;
    3977           0 :   } else if (!mozilla::IsFinite(arg3)) {
    3978           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.getImageData");
    3979           0 :     return false;
    3980             :   }
    3981           0 :   binding_detail::FastErrorResult rv;
    3982           0 :   auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->GetImageData(cx, arg0, arg1, arg2, arg3, rv)));
    3983           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3984           0 :     return false;
    3985             :   }
    3986           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3987             :   static_assert(!IsPointer<decltype(result)>::value,
    3988             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    3989           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
    3990           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3991           0 :     return false;
    3992             :   }
    3993           0 :   return true;
    3994             : }
    3995             : 
    3996             : static const JSJitInfo getImageData_methodinfo = {
    3997             :   { (JSJitGetterOp)getImageData },
    3998             :   { prototypes::id::CanvasRenderingContext2D },
    3999             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4000             :   JSJitInfo::Method,
    4001             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4002             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    4003             :   false,  /* isInfallible. False in setters. */
    4004             :   false,  /* isMovable.  Not relevant for setters. */
    4005             :   false, /* isEliminatable.  Not relevant for setters. */
    4006             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4007             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4008             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4009             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4010             : };
    4011             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4012             : static_assert(0 < 1, "There is no slot for us");
    4013             : 
    4014             : static bool
    4015           0 : putImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4016             : {
    4017           0 :   unsigned argcount = std::min(args.length(), 7u);
    4018           0 :   switch (argcount) {
    4019             :     case 3: {
    4020           0 :       NonNull<mozilla::dom::ImageData> arg0;
    4021           0 :       if (args[0].isObject()) {
    4022             :         {
    4023           0 :           nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
    4024           0 :           if (NS_FAILED(rv)) {
    4025           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.putImageData", "ImageData");
    4026           0 :             return false;
    4027             :           }
    4028             :         }
    4029             :       } else {
    4030           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.putImageData");
    4031           0 :         return false;
    4032             :       }
    4033             :       double arg1;
    4034           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4035           0 :         return false;
    4036           0 :       } else if (!mozilla::IsFinite(arg1)) {
    4037           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.putImageData");
    4038           0 :         return false;
    4039             :       }
    4040             :       double arg2;
    4041           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4042           0 :         return false;
    4043           0 :       } else if (!mozilla::IsFinite(arg2)) {
    4044           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.putImageData");
    4045           0 :         return false;
    4046             :       }
    4047           0 :       binding_detail::FastErrorResult rv;
    4048           0 :       self->PutImageData(NonNullHelper(arg0), arg1, arg2, rv);
    4049           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4050           0 :         return false;
    4051             :       }
    4052           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4053           0 :       args.rval().setUndefined();
    4054           0 :       return true;
    4055             :       break;
    4056             :     }
    4057             :     case 7: {
    4058           0 :       NonNull<mozilla::dom::ImageData> arg0;
    4059           0 :       if (args[0].isObject()) {
    4060             :         {
    4061           0 :           nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
    4062           0 :           if (NS_FAILED(rv)) {
    4063           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.putImageData", "ImageData");
    4064           0 :             return false;
    4065             :           }
    4066             :         }
    4067             :       } else {
    4068           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.putImageData");
    4069           0 :         return false;
    4070             :       }
    4071             :       double arg1;
    4072           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4073           0 :         return false;
    4074           0 :       } else if (!mozilla::IsFinite(arg1)) {
    4075           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.putImageData");
    4076           0 :         return false;
    4077             :       }
    4078             :       double arg2;
    4079           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4080           0 :         return false;
    4081           0 :       } else if (!mozilla::IsFinite(arg2)) {
    4082           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.putImageData");
    4083           0 :         return false;
    4084             :       }
    4085             :       double arg3;
    4086           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    4087           0 :         return false;
    4088           0 :       } else if (!mozilla::IsFinite(arg3)) {
    4089           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.putImageData");
    4090           0 :         return false;
    4091             :       }
    4092             :       double arg4;
    4093           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    4094           0 :         return false;
    4095           0 :       } else if (!mozilla::IsFinite(arg4)) {
    4096           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.putImageData");
    4097           0 :         return false;
    4098             :       }
    4099             :       double arg5;
    4100           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    4101           0 :         return false;
    4102           0 :       } else if (!mozilla::IsFinite(arg5)) {
    4103           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 6 of CanvasRenderingContext2D.putImageData");
    4104           0 :         return false;
    4105             :       }
    4106             :       double arg6;
    4107           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
    4108           0 :         return false;
    4109           0 :       } else if (!mozilla::IsFinite(arg6)) {
    4110           0 :         ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 7 of CanvasRenderingContext2D.putImageData");
    4111           0 :         return false;
    4112             :       }
    4113           0 :       binding_detail::FastErrorResult rv;
    4114           0 :       self->PutImageData(NonNullHelper(arg0), arg1, arg2, arg3, arg4, arg5, arg6, rv);
    4115           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4116           0 :         return false;
    4117             :       }
    4118           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4119           0 :       args.rval().setUndefined();
    4120           0 :       return true;
    4121             :       break;
    4122             :     }
    4123             :     default: {
    4124           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.putImageData");
    4125             :       break;
    4126             :     }
    4127             :   }
    4128             :   MOZ_CRASH("We have an always-returning default case");
    4129             :   return false;
    4130             : }
    4131             : 
    4132             : static const JSJitInfo putImageData_methodinfo = {
    4133             :   { (JSJitGetterOp)putImageData },
    4134             :   { prototypes::id::CanvasRenderingContext2D },
    4135             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4136             :   JSJitInfo::Method,
    4137             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4138             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4139             :   false,  /* isInfallible. False in setters. */
    4140             :   false,  /* isMovable.  Not relevant for setters. */
    4141             :   false, /* isEliminatable.  Not relevant for setters. */
    4142             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4143             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4144             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4145             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4146             : };
    4147             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4148             : static_assert(0 < 1, "There is no slot for us");
    4149             : 
    4150             : static bool
    4151           0 : get_imageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4152             : {
    4153           0 :   bool result(self->ImageSmoothingEnabled());
    4154           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4155           0 :   args.rval().setBoolean(result);
    4156           0 :   return true;
    4157             : }
    4158             : 
    4159             : static bool
    4160           0 : set_imageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4161             : {
    4162             :   bool arg0;
    4163           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
    4164           0 :     return false;
    4165             :   }
    4166           0 :   self->SetImageSmoothingEnabled(arg0);
    4167           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4168             : 
    4169           0 :   return true;
    4170             : }
    4171             : 
    4172             : static const JSJitInfo imageSmoothingEnabled_getterinfo = {
    4173             :   { (JSJitGetterOp)get_imageSmoothingEnabled },
    4174             :   { prototypes::id::CanvasRenderingContext2D },
    4175             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4176             :   JSJitInfo::Getter,
    4177             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4178             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    4179             :   true,  /* isInfallible. False in setters. */
    4180             :   false,  /* isMovable.  Not relevant for setters. */
    4181             :   false, /* isEliminatable.  Not relevant for setters. */
    4182             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4183             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4184             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4185             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4186             : };
    4187             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4188             : static_assert(0 < 1, "There is no slot for us");
    4189             : static const JSJitInfo imageSmoothingEnabled_setterinfo = {
    4190             :   { (JSJitGetterOp)set_imageSmoothingEnabled },
    4191             :   { prototypes::id::CanvasRenderingContext2D },
    4192             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4193             :   JSJitInfo::Setter,
    4194             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4195             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4196             :   false,  /* isInfallible. False in setters. */
    4197             :   false,  /* isMovable.  Not relevant for setters. */
    4198             :   false, /* isEliminatable.  Not relevant for setters. */
    4199             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4200             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4201             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4202             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4203             : };
    4204             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4205             : static_assert(0 < 1, "There is no slot for us");
    4206             : 
    4207             : static bool
    4208           0 : get_lineWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4209             : {
    4210           0 :   double result(self->LineWidth());
    4211           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4212           0 :   args.rval().set(JS_NumberValue(double(result)));
    4213           0 :   return true;
    4214             : }
    4215             : 
    4216             : static bool
    4217           0 : set_lineWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4218             : {
    4219           0 :   bool foundNonFiniteFloat = false;
    4220             :   double arg0;
    4221           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4222           0 :     return false;
    4223           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4224           0 :     foundNonFiniteFloat = true;
    4225             :   }
    4226           0 :   if (foundNonFiniteFloat) {
    4227           0 :     return true;
    4228             :   }
    4229           0 :   self->SetLineWidth(arg0);
    4230           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4231             : 
    4232           0 :   return true;
    4233             : }
    4234             : 
    4235             : static const JSJitInfo lineWidth_getterinfo = {
    4236             :   { (JSJitGetterOp)get_lineWidth },
    4237             :   { prototypes::id::CanvasRenderingContext2D },
    4238             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4239             :   JSJitInfo::Getter,
    4240             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4241             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4242             :   true,  /* isInfallible. False in setters. */
    4243             :   false,  /* isMovable.  Not relevant for setters. */
    4244             :   false, /* isEliminatable.  Not relevant for setters. */
    4245             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4246             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4247             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4248             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4249             : };
    4250             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4251             : static_assert(0 < 1, "There is no slot for us");
    4252             : static const JSJitInfo lineWidth_setterinfo = {
    4253             :   { (JSJitGetterOp)set_lineWidth },
    4254             :   { prototypes::id::CanvasRenderingContext2D },
    4255             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4256             :   JSJitInfo::Setter,
    4257             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4258             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4259             :   false,  /* isInfallible. False in setters. */
    4260             :   false,  /* isMovable.  Not relevant for setters. */
    4261             :   false, /* isEliminatable.  Not relevant for setters. */
    4262             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4263             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4264             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4265             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4266             : };
    4267             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4268             : static_assert(0 < 1, "There is no slot for us");
    4269             : 
    4270             : static bool
    4271           0 : get_lineCap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4272             : {
    4273           0 :   DOMString result;
    4274           0 :   self->GetLineCap(result);
    4275           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4276           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    4277           0 :     return false;
    4278             :   }
    4279           0 :   return true;
    4280             : }
    4281             : 
    4282             : static bool
    4283           0 : set_lineCap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4284             : {
    4285           0 :   binding_detail::FakeString arg0;
    4286           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    4287           0 :     return false;
    4288             :   }
    4289           0 :   self->SetLineCap(NonNullHelper(Constify(arg0)));
    4290           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4291             : 
    4292           0 :   return true;
    4293             : }
    4294             : 
    4295             : static const JSJitInfo lineCap_getterinfo = {
    4296             :   { (JSJitGetterOp)get_lineCap },
    4297             :   { prototypes::id::CanvasRenderingContext2D },
    4298             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4299             :   JSJitInfo::Getter,
    4300             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4301             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    4302             :   false,  /* isInfallible. False in setters. */
    4303             :   false,  /* isMovable.  Not relevant for setters. */
    4304             :   false, /* isEliminatable.  Not relevant for setters. */
    4305             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4306             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4307             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4308             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4309             : };
    4310             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4311             : static_assert(0 < 1, "There is no slot for us");
    4312             : static const JSJitInfo lineCap_setterinfo = {
    4313             :   { (JSJitGetterOp)set_lineCap },
    4314             :   { prototypes::id::CanvasRenderingContext2D },
    4315             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4316             :   JSJitInfo::Setter,
    4317             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4318             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4319             :   false,  /* isInfallible. False in setters. */
    4320             :   false,  /* isMovable.  Not relevant for setters. */
    4321             :   false, /* isEliminatable.  Not relevant for setters. */
    4322             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4323             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4324             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4325             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4326             : };
    4327             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4328             : static_assert(0 < 1, "There is no slot for us");
    4329             : 
    4330             : static bool
    4331           0 : get_lineJoin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4332             : {
    4333           0 :   binding_detail::FastErrorResult rv;
    4334           0 :   DOMString result;
    4335           0 :   self->GetLineJoin(result, rv);
    4336           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4337           0 :     return false;
    4338             :   }
    4339           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4340           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    4341           0 :     return false;
    4342             :   }
    4343           0 :   return true;
    4344             : }
    4345             : 
    4346             : static bool
    4347           0 : set_lineJoin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4348             : {
    4349           0 :   binding_detail::FakeString arg0;
    4350           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    4351           0 :     return false;
    4352             :   }
    4353           0 :   self->SetLineJoin(NonNullHelper(Constify(arg0)));
    4354           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4355             : 
    4356           0 :   return true;
    4357             : }
    4358             : 
    4359             : static const JSJitInfo lineJoin_getterinfo = {
    4360             :   { (JSJitGetterOp)get_lineJoin },
    4361             :   { prototypes::id::CanvasRenderingContext2D },
    4362             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4363             :   JSJitInfo::Getter,
    4364             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4365             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    4366             :   false,  /* isInfallible. False in setters. */
    4367             :   false,  /* isMovable.  Not relevant for setters. */
    4368             :   false, /* isEliminatable.  Not relevant for setters. */
    4369             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4370             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4371             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4372             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4373             : };
    4374             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4375             : static_assert(0 < 1, "There is no slot for us");
    4376             : static const JSJitInfo lineJoin_setterinfo = {
    4377             :   { (JSJitGetterOp)set_lineJoin },
    4378             :   { prototypes::id::CanvasRenderingContext2D },
    4379             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4380             :   JSJitInfo::Setter,
    4381             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4382             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4383             :   false,  /* isInfallible. False in setters. */
    4384             :   false,  /* isMovable.  Not relevant for setters. */
    4385             :   false, /* isEliminatable.  Not relevant for setters. */
    4386             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4387             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4388             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4389             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4390             : };
    4391             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4392             : static_assert(0 < 1, "There is no slot for us");
    4393             : 
    4394             : static bool
    4395           0 : get_miterLimit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4396             : {
    4397           0 :   double result(self->MiterLimit());
    4398           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4399           0 :   args.rval().set(JS_NumberValue(double(result)));
    4400           0 :   return true;
    4401             : }
    4402             : 
    4403             : static bool
    4404           0 : set_miterLimit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4405             : {
    4406           0 :   bool foundNonFiniteFloat = false;
    4407             :   double arg0;
    4408           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4409           0 :     return false;
    4410           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4411           0 :     foundNonFiniteFloat = true;
    4412             :   }
    4413           0 :   if (foundNonFiniteFloat) {
    4414           0 :     return true;
    4415             :   }
    4416           0 :   self->SetMiterLimit(arg0);
    4417           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4418             : 
    4419           0 :   return true;
    4420             : }
    4421             : 
    4422             : static const JSJitInfo miterLimit_getterinfo = {
    4423             :   { (JSJitGetterOp)get_miterLimit },
    4424             :   { prototypes::id::CanvasRenderingContext2D },
    4425             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4426             :   JSJitInfo::Getter,
    4427             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4428             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4429             :   true,  /* isInfallible. False in setters. */
    4430             :   false,  /* isMovable.  Not relevant for setters. */
    4431             :   false, /* isEliminatable.  Not relevant for setters. */
    4432             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4433             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4434             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4435             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4436             : };
    4437             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4438             : static_assert(0 < 1, "There is no slot for us");
    4439             : static const JSJitInfo miterLimit_setterinfo = {
    4440             :   { (JSJitGetterOp)set_miterLimit },
    4441             :   { prototypes::id::CanvasRenderingContext2D },
    4442             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4443             :   JSJitInfo::Setter,
    4444             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4445             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4446             :   false,  /* isInfallible. False in setters. */
    4447             :   false,  /* isMovable.  Not relevant for setters. */
    4448             :   false, /* isEliminatable.  Not relevant for setters. */
    4449             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4450             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4451             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4452             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4453             : };
    4454             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4455             : static_assert(0 < 1, "There is no slot for us");
    4456             : 
    4457             : static bool
    4458           0 : setLineDash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4459             : {
    4460           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    4461           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.setLineDash");
    4462             :   }
    4463           0 :   bool foundNonFiniteFloat = false;
    4464           0 :   binding_detail::AutoSequence<double> arg0;
    4465           0 :   if (args[0].isObject()) {
    4466           0 :     JS::ForOfIterator iter(cx);
    4467           0 :     if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
    4468           0 :       return false;
    4469             :     }
    4470           0 :     if (!iter.valueIsIterable()) {
    4471           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of CanvasRenderingContext2D.setLineDash");
    4472           0 :       return false;
    4473             :     }
    4474           0 :     binding_detail::AutoSequence<double> &arr = arg0;
    4475           0 :     JS::Rooted<JS::Value> temp(cx);
    4476             :     while (true) {
    4477             :       bool done;
    4478           0 :       if (!iter.next(&temp, &done)) {
    4479           0 :         return false;
    4480             :       }
    4481           0 :       if (done) {
    4482           0 :         break;
    4483             :       }
    4484           0 :       double* slotPtr = arr.AppendElement(mozilla::fallible);
    4485           0 :       if (!slotPtr) {
    4486           0 :         JS_ReportOutOfMemory(cx);
    4487           0 :         return false;
    4488             :       }
    4489           0 :       double& slot = *slotPtr;
    4490           0 :       if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
    4491           0 :         return false;
    4492           0 :       } else if (!mozilla::IsFinite(slot)) {
    4493           0 :         foundNonFiniteFloat = true;
    4494             :       }
    4495           0 :     }
    4496             :   } else {
    4497           0 :     ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of CanvasRenderingContext2D.setLineDash");
    4498           0 :     return false;
    4499             :   }
    4500           0 :   if (foundNonFiniteFloat) {
    4501           0 :     args.rval().setUndefined();
    4502           0 :     return true;
    4503             :   }
    4504           0 :   binding_detail::FastErrorResult rv;
    4505           0 :   self->SetLineDash(Constify(arg0), rv);
    4506           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4507           0 :     return false;
    4508             :   }
    4509           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4510           0 :   args.rval().setUndefined();
    4511           0 :   return true;
    4512             : }
    4513             : 
    4514             : static const JSJitInfo setLineDash_methodinfo = {
    4515             :   { (JSJitGetterOp)setLineDash },
    4516             :   { prototypes::id::CanvasRenderingContext2D },
    4517             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4518             :   JSJitInfo::Method,
    4519             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4520             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4521             :   false,  /* isInfallible. False in setters. */
    4522             :   false,  /* isMovable.  Not relevant for setters. */
    4523             :   false, /* isEliminatable.  Not relevant for setters. */
    4524             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4525             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4526             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4527             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4528             : };
    4529             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4530             : static_assert(0 < 1, "There is no slot for us");
    4531             : 
    4532             : static bool
    4533           0 : getLineDash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4534             : {
    4535           0 :   nsTArray<double> result;
    4536           0 :   self->GetLineDash(result);
    4537           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4538             : 
    4539           0 :   uint32_t length = result.Length();
    4540           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
    4541           0 :   if (!returnArray) {
    4542           0 :     return false;
    4543             :   }
    4544             :   // Scope for 'tmp'
    4545             :   {
    4546           0 :     JS::Rooted<JS::Value> tmp(cx);
    4547           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
    4548             :       // Control block to let us common up the JS_DefineElement calls when there
    4549             :       // are different ways to succeed at wrapping the object.
    4550             :       do {
    4551           0 :         tmp.set(JS_NumberValue(double(result[sequenceIdx0])));
    4552           0 :         break;
    4553             :       } while (0);
    4554           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
    4555             :                             JSPROP_ENUMERATE)) {
    4556           0 :         return false;
    4557             :       }
    4558             :     }
    4559             :   }
    4560           0 :   args.rval().setObject(*returnArray);
    4561           0 :   return true;
    4562             : }
    4563             : 
    4564             : static const JSJitInfo getLineDash_methodinfo = {
    4565             :   { (JSJitGetterOp)getLineDash },
    4566             :   { prototypes::id::CanvasRenderingContext2D },
    4567             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4568             :   JSJitInfo::Method,
    4569             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4570             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    4571             :   false,  /* isInfallible. False in setters. */
    4572             :   false,  /* isMovable.  Not relevant for setters. */
    4573             :   false, /* isEliminatable.  Not relevant for setters. */
    4574             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4575             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4576             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4577             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4578             : };
    4579             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4580             : static_assert(0 < 1, "There is no slot for us");
    4581             : 
    4582             : static bool
    4583           0 : get_lineDashOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    4584             : {
    4585           0 :   double result(self->LineDashOffset());
    4586           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4587           0 :   args.rval().set(JS_NumberValue(double(result)));
    4588           0 :   return true;
    4589             : }
    4590             : 
    4591             : static bool
    4592           0 : set_lineDashOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    4593             : {
    4594           0 :   bool foundNonFiniteFloat = false;
    4595             :   double arg0;
    4596           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4597           0 :     return false;
    4598           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4599           0 :     foundNonFiniteFloat = true;
    4600             :   }
    4601           0 :   if (foundNonFiniteFloat) {
    4602           0 :     return true;
    4603             :   }
    4604           0 :   self->SetLineDashOffset(arg0);
    4605           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4606             : 
    4607           0 :   return true;
    4608             : }
    4609             : 
    4610             : static const JSJitInfo lineDashOffset_getterinfo = {
    4611             :   { (JSJitGetterOp)get_lineDashOffset },
    4612             :   { prototypes::id::CanvasRenderingContext2D },
    4613             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4614             :   JSJitInfo::Getter,
    4615             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4616             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4617             :   true,  /* isInfallible. False in setters. */
    4618             :   false,  /* isMovable.  Not relevant for setters. */
    4619             :   false, /* isEliminatable.  Not relevant for setters. */
    4620             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4621             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4622             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4623             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4624             : };
    4625             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4626             : static_assert(0 < 1, "There is no slot for us");
    4627             : static const JSJitInfo lineDashOffset_setterinfo = {
    4628             :   { (JSJitGetterOp)set_lineDashOffset },
    4629             :   { prototypes::id::CanvasRenderingContext2D },
    4630             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4631             :   JSJitInfo::Setter,
    4632             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4633             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4634             :   false,  /* isInfallible. False in setters. */
    4635             :   false,  /* isMovable.  Not relevant for setters. */
    4636             :   false, /* isEliminatable.  Not relevant for setters. */
    4637             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4638             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4639             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4640             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4641             : };
    4642             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4643             : static_assert(0 < 1, "There is no slot for us");
    4644             : 
    4645             : static bool
    4646           0 : closePath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4647             : {
    4648           0 :   self->ClosePath();
    4649           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4650           0 :   args.rval().setUndefined();
    4651           0 :   return true;
    4652             : }
    4653             : 
    4654             : static const JSJitInfo closePath_methodinfo = {
    4655             :   { (JSJitGetterOp)closePath },
    4656             :   { prototypes::id::CanvasRenderingContext2D },
    4657             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4658             :   JSJitInfo::Method,
    4659             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4660             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4661             :   true,  /* isInfallible. False in setters. */
    4662             :   false,  /* isMovable.  Not relevant for setters. */
    4663             :   false, /* isEliminatable.  Not relevant for setters. */
    4664             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4665             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4666             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4667             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4668             : };
    4669             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4670             : static_assert(0 < 1, "There is no slot for us");
    4671             : 
    4672             : static bool
    4673           0 : moveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4674             : {
    4675           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    4676           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.moveTo");
    4677             :   }
    4678           0 :   bool foundNonFiniteFloat = false;
    4679             :   double arg0;
    4680           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4681           0 :     return false;
    4682           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4683           0 :     foundNonFiniteFloat = true;
    4684             :   }
    4685             :   double arg1;
    4686           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4687           0 :     return false;
    4688           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4689           0 :     foundNonFiniteFloat = true;
    4690             :   }
    4691           0 :   if (foundNonFiniteFloat) {
    4692           0 :     args.rval().setUndefined();
    4693           0 :     return true;
    4694             :   }
    4695           0 :   self->MoveTo(arg0, arg1);
    4696           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4697           0 :   args.rval().setUndefined();
    4698           0 :   return true;
    4699             : }
    4700             : 
    4701             : static const JSJitInfo moveTo_methodinfo = {
    4702             :   { (JSJitGetterOp)moveTo },
    4703             :   { prototypes::id::CanvasRenderingContext2D },
    4704             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4705             :   JSJitInfo::Method,
    4706             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4707             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4708             :   false,  /* isInfallible. False in setters. */
    4709             :   false,  /* isMovable.  Not relevant for setters. */
    4710             :   false, /* isEliminatable.  Not relevant for setters. */
    4711             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4712             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4713             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4714             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4715             : };
    4716             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4717             : static_assert(0 < 1, "There is no slot for us");
    4718             : 
    4719             : static bool
    4720           0 : lineTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4721             : {
    4722           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    4723           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.lineTo");
    4724             :   }
    4725           0 :   bool foundNonFiniteFloat = false;
    4726             :   double arg0;
    4727           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4728           0 :     return false;
    4729           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4730           0 :     foundNonFiniteFloat = true;
    4731             :   }
    4732             :   double arg1;
    4733           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4734           0 :     return false;
    4735           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4736           0 :     foundNonFiniteFloat = true;
    4737             :   }
    4738           0 :   if (foundNonFiniteFloat) {
    4739           0 :     args.rval().setUndefined();
    4740           0 :     return true;
    4741             :   }
    4742           0 :   self->LineTo(arg0, arg1);
    4743           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4744           0 :   args.rval().setUndefined();
    4745           0 :   return true;
    4746             : }
    4747             : 
    4748             : static const JSJitInfo lineTo_methodinfo = {
    4749             :   { (JSJitGetterOp)lineTo },
    4750             :   { prototypes::id::CanvasRenderingContext2D },
    4751             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4752             :   JSJitInfo::Method,
    4753             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4754             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4755             :   false,  /* isInfallible. False in setters. */
    4756             :   false,  /* isMovable.  Not relevant for setters. */
    4757             :   false, /* isEliminatable.  Not relevant for setters. */
    4758             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4759             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4760             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4761             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4762             : };
    4763             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4764             : static_assert(0 < 1, "There is no slot for us");
    4765             : 
    4766             : static bool
    4767           0 : quadraticCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4768             : {
    4769           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    4770           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.quadraticCurveTo");
    4771             :   }
    4772           0 :   bool foundNonFiniteFloat = false;
    4773             :   double arg0;
    4774           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4775           0 :     return false;
    4776           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4777           0 :     foundNonFiniteFloat = true;
    4778             :   }
    4779             :   double arg1;
    4780           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4781           0 :     return false;
    4782           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4783           0 :     foundNonFiniteFloat = true;
    4784             :   }
    4785             :   double arg2;
    4786           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4787           0 :     return false;
    4788           0 :   } else if (!mozilla::IsFinite(arg2)) {
    4789           0 :     foundNonFiniteFloat = true;
    4790             :   }
    4791             :   double arg3;
    4792           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    4793           0 :     return false;
    4794           0 :   } else if (!mozilla::IsFinite(arg3)) {
    4795           0 :     foundNonFiniteFloat = true;
    4796             :   }
    4797           0 :   if (foundNonFiniteFloat) {
    4798           0 :     args.rval().setUndefined();
    4799           0 :     return true;
    4800             :   }
    4801           0 :   self->QuadraticCurveTo(arg0, arg1, arg2, arg3);
    4802           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4803           0 :   args.rval().setUndefined();
    4804           0 :   return true;
    4805             : }
    4806             : 
    4807             : static const JSJitInfo quadraticCurveTo_methodinfo = {
    4808             :   { (JSJitGetterOp)quadraticCurveTo },
    4809             :   { prototypes::id::CanvasRenderingContext2D },
    4810             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4811             :   JSJitInfo::Method,
    4812             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4813             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4814             :   false,  /* isInfallible. False in setters. */
    4815             :   false,  /* isMovable.  Not relevant for setters. */
    4816             :   false, /* isEliminatable.  Not relevant for setters. */
    4817             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4818             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4819             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4820             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4821             : };
    4822             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4823             : static_assert(0 < 1, "There is no slot for us");
    4824             : 
    4825             : static bool
    4826           0 : bezierCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4827             : {
    4828           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    4829           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.bezierCurveTo");
    4830             :   }
    4831           0 :   bool foundNonFiniteFloat = false;
    4832             :   double arg0;
    4833           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4834           0 :     return false;
    4835           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4836           0 :     foundNonFiniteFloat = true;
    4837             :   }
    4838             :   double arg1;
    4839           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4840           0 :     return false;
    4841           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4842           0 :     foundNonFiniteFloat = true;
    4843             :   }
    4844             :   double arg2;
    4845           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4846           0 :     return false;
    4847           0 :   } else if (!mozilla::IsFinite(arg2)) {
    4848           0 :     foundNonFiniteFloat = true;
    4849             :   }
    4850             :   double arg3;
    4851           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    4852           0 :     return false;
    4853           0 :   } else if (!mozilla::IsFinite(arg3)) {
    4854           0 :     foundNonFiniteFloat = true;
    4855             :   }
    4856             :   double arg4;
    4857           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    4858           0 :     return false;
    4859           0 :   } else if (!mozilla::IsFinite(arg4)) {
    4860           0 :     foundNonFiniteFloat = true;
    4861             :   }
    4862             :   double arg5;
    4863           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    4864           0 :     return false;
    4865           0 :   } else if (!mozilla::IsFinite(arg5)) {
    4866           0 :     foundNonFiniteFloat = true;
    4867             :   }
    4868           0 :   if (foundNonFiniteFloat) {
    4869           0 :     args.rval().setUndefined();
    4870           0 :     return true;
    4871             :   }
    4872           0 :   self->BezierCurveTo(arg0, arg1, arg2, arg3, arg4, arg5);
    4873           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4874           0 :   args.rval().setUndefined();
    4875           0 :   return true;
    4876             : }
    4877             : 
    4878             : static const JSJitInfo bezierCurveTo_methodinfo = {
    4879             :   { (JSJitGetterOp)bezierCurveTo },
    4880             :   { prototypes::id::CanvasRenderingContext2D },
    4881             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4882             :   JSJitInfo::Method,
    4883             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4884             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4885             :   false,  /* isInfallible. False in setters. */
    4886             :   false,  /* isMovable.  Not relevant for setters. */
    4887             :   false, /* isEliminatable.  Not relevant for setters. */
    4888             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4889             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4890             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4891             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4892             : };
    4893             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4894             : static_assert(0 < 1, "There is no slot for us");
    4895             : 
    4896             : static bool
    4897           0 : arcTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4898             : {
    4899           0 :   if (MOZ_UNLIKELY(args.length() < 5)) {
    4900           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.arcTo");
    4901             :   }
    4902           0 :   bool foundNonFiniteFloat = false;
    4903             :   double arg0;
    4904           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4905           0 :     return false;
    4906           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4907           0 :     foundNonFiniteFloat = true;
    4908             :   }
    4909             :   double arg1;
    4910           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4911           0 :     return false;
    4912           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4913           0 :     foundNonFiniteFloat = true;
    4914             :   }
    4915             :   double arg2;
    4916           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4917           0 :     return false;
    4918           0 :   } else if (!mozilla::IsFinite(arg2)) {
    4919           0 :     foundNonFiniteFloat = true;
    4920             :   }
    4921             :   double arg3;
    4922           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    4923           0 :     return false;
    4924           0 :   } else if (!mozilla::IsFinite(arg3)) {
    4925           0 :     foundNonFiniteFloat = true;
    4926             :   }
    4927             :   double arg4;
    4928           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    4929           0 :     return false;
    4930           0 :   } else if (!mozilla::IsFinite(arg4)) {
    4931           0 :     foundNonFiniteFloat = true;
    4932             :   }
    4933           0 :   if (foundNonFiniteFloat) {
    4934           0 :     args.rval().setUndefined();
    4935           0 :     return true;
    4936             :   }
    4937           0 :   binding_detail::FastErrorResult rv;
    4938           0 :   self->ArcTo(arg0, arg1, arg2, arg3, arg4, rv);
    4939           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4940           0 :     return false;
    4941             :   }
    4942           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4943           0 :   args.rval().setUndefined();
    4944           0 :   return true;
    4945             : }
    4946             : 
    4947             : static const JSJitInfo arcTo_methodinfo = {
    4948             :   { (JSJitGetterOp)arcTo },
    4949             :   { prototypes::id::CanvasRenderingContext2D },
    4950             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    4951             :   JSJitInfo::Method,
    4952             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4953             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    4954             :   false,  /* isInfallible. False in setters. */
    4955             :   false,  /* isMovable.  Not relevant for setters. */
    4956             :   false, /* isEliminatable.  Not relevant for setters. */
    4957             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4958             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4959             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4960             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4961             : };
    4962             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4963             : static_assert(0 < 1, "There is no slot for us");
    4964             : 
    4965             : static bool
    4966           0 : rect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    4967             : {
    4968           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    4969           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.rect");
    4970             :   }
    4971           0 :   bool foundNonFiniteFloat = false;
    4972             :   double arg0;
    4973           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    4974           0 :     return false;
    4975           0 :   } else if (!mozilla::IsFinite(arg0)) {
    4976           0 :     foundNonFiniteFloat = true;
    4977             :   }
    4978             :   double arg1;
    4979           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    4980           0 :     return false;
    4981           0 :   } else if (!mozilla::IsFinite(arg1)) {
    4982           0 :     foundNonFiniteFloat = true;
    4983             :   }
    4984             :   double arg2;
    4985           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    4986           0 :     return false;
    4987           0 :   } else if (!mozilla::IsFinite(arg2)) {
    4988           0 :     foundNonFiniteFloat = true;
    4989             :   }
    4990             :   double arg3;
    4991           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    4992           0 :     return false;
    4993           0 :   } else if (!mozilla::IsFinite(arg3)) {
    4994           0 :     foundNonFiniteFloat = true;
    4995             :   }
    4996           0 :   if (foundNonFiniteFloat) {
    4997           0 :     args.rval().setUndefined();
    4998           0 :     return true;
    4999             :   }
    5000           0 :   self->Rect(arg0, arg1, arg2, arg3);
    5001           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5002           0 :   args.rval().setUndefined();
    5003           0 :   return true;
    5004             : }
    5005             : 
    5006             : static const JSJitInfo rect_methodinfo = {
    5007             :   { (JSJitGetterOp)rect },
    5008             :   { prototypes::id::CanvasRenderingContext2D },
    5009             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5010             :   JSJitInfo::Method,
    5011             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5012             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5013             :   false,  /* isInfallible. False in setters. */
    5014             :   false,  /* isMovable.  Not relevant for setters. */
    5015             :   false, /* isEliminatable.  Not relevant for setters. */
    5016             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5017             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5018             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5019             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5020             : };
    5021             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5022             : static_assert(0 < 1, "There is no slot for us");
    5023             : 
    5024             : static bool
    5025           0 : arc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5026             : {
    5027           0 :   if (MOZ_UNLIKELY(args.length() < 5)) {
    5028           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.arc");
    5029             :   }
    5030           0 :   bool foundNonFiniteFloat = false;
    5031             :   double arg0;
    5032           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5033           0 :     return false;
    5034           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5035           0 :     foundNonFiniteFloat = true;
    5036             :   }
    5037             :   double arg1;
    5038           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5039           0 :     return false;
    5040           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5041           0 :     foundNonFiniteFloat = true;
    5042             :   }
    5043             :   double arg2;
    5044           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5045           0 :     return false;
    5046           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5047           0 :     foundNonFiniteFloat = true;
    5048             :   }
    5049             :   double arg3;
    5050           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    5051           0 :     return false;
    5052           0 :   } else if (!mozilla::IsFinite(arg3)) {
    5053           0 :     foundNonFiniteFloat = true;
    5054             :   }
    5055             :   double arg4;
    5056           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    5057           0 :     return false;
    5058           0 :   } else if (!mozilla::IsFinite(arg4)) {
    5059           0 :     foundNonFiniteFloat = true;
    5060             :   }
    5061             :   bool arg5;
    5062           0 :   if (args.hasDefined(5)) {
    5063           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
    5064           0 :       return false;
    5065             :     }
    5066             :   } else {
    5067           0 :     arg5 = false;
    5068             :   }
    5069           0 :   if (foundNonFiniteFloat) {
    5070           0 :     args.rval().setUndefined();
    5071           0 :     return true;
    5072             :   }
    5073           0 :   binding_detail::FastErrorResult rv;
    5074           0 :   self->Arc(arg0, arg1, arg2, arg3, arg4, arg5, rv);
    5075           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5076           0 :     return false;
    5077             :   }
    5078           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5079           0 :   args.rval().setUndefined();
    5080           0 :   return true;
    5081             : }
    5082             : 
    5083             : static const JSJitInfo arc_methodinfo = {
    5084             :   { (JSJitGetterOp)arc },
    5085             :   { prototypes::id::CanvasRenderingContext2D },
    5086             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5087             :   JSJitInfo::Method,
    5088             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5089             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5090             :   false,  /* isInfallible. False in setters. */
    5091             :   false,  /* isMovable.  Not relevant for setters. */
    5092             :   false, /* isEliminatable.  Not relevant for setters. */
    5093             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5094             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5095             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5096             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5097             : };
    5098             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5099             : static_assert(0 < 1, "There is no slot for us");
    5100             : 
    5101             : static bool
    5102           0 : ellipse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5103             : {
    5104           0 :   if (MOZ_UNLIKELY(args.length() < 7)) {
    5105           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.ellipse");
    5106             :   }
    5107           0 :   bool foundNonFiniteFloat = false;
    5108             :   double arg0;
    5109           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5110           0 :     return false;
    5111           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5112           0 :     foundNonFiniteFloat = true;
    5113             :   }
    5114             :   double arg1;
    5115           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5116           0 :     return false;
    5117           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5118           0 :     foundNonFiniteFloat = true;
    5119             :   }
    5120             :   double arg2;
    5121           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5122           0 :     return false;
    5123           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5124           0 :     foundNonFiniteFloat = true;
    5125             :   }
    5126             :   double arg3;
    5127           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    5128           0 :     return false;
    5129           0 :   } else if (!mozilla::IsFinite(arg3)) {
    5130           0 :     foundNonFiniteFloat = true;
    5131             :   }
    5132             :   double arg4;
    5133           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    5134           0 :     return false;
    5135           0 :   } else if (!mozilla::IsFinite(arg4)) {
    5136           0 :     foundNonFiniteFloat = true;
    5137             :   }
    5138             :   double arg5;
    5139           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    5140           0 :     return false;
    5141           0 :   } else if (!mozilla::IsFinite(arg5)) {
    5142           0 :     foundNonFiniteFloat = true;
    5143             :   }
    5144             :   double arg6;
    5145           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
    5146           0 :     return false;
    5147           0 :   } else if (!mozilla::IsFinite(arg6)) {
    5148           0 :     foundNonFiniteFloat = true;
    5149             :   }
    5150             :   bool arg7;
    5151           0 :   if (args.hasDefined(7)) {
    5152           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
    5153           0 :       return false;
    5154             :     }
    5155             :   } else {
    5156           0 :     arg7 = false;
    5157             :   }
    5158           0 :   if (foundNonFiniteFloat) {
    5159           0 :     args.rval().setUndefined();
    5160           0 :     return true;
    5161             :   }
    5162           0 :   binding_detail::FastErrorResult rv;
    5163           0 :   self->Ellipse(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, rv);
    5164           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5165           0 :     return false;
    5166             :   }
    5167           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5168           0 :   args.rval().setUndefined();
    5169           0 :   return true;
    5170             : }
    5171             : 
    5172             : static const JSJitInfo ellipse_methodinfo = {
    5173             :   { (JSJitGetterOp)ellipse },
    5174             :   { prototypes::id::CanvasRenderingContext2D },
    5175             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5176             :   JSJitInfo::Method,
    5177             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5178             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5179             :   false,  /* isInfallible. False in setters. */
    5180             :   false,  /* isMovable.  Not relevant for setters. */
    5181             :   false, /* isEliminatable.  Not relevant for setters. */
    5182             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5183             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5184             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5185             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5186             : };
    5187             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5188             : static_assert(0 < 1, "There is no slot for us");
    5189             : 
    5190             : static bool
    5191           0 : clearRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5192             : {
    5193           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    5194           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.clearRect");
    5195             :   }
    5196           0 :   bool foundNonFiniteFloat = false;
    5197             :   double arg0;
    5198           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5199           0 :     return false;
    5200           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5201           0 :     foundNonFiniteFloat = true;
    5202             :   }
    5203             :   double arg1;
    5204           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5205           0 :     return false;
    5206           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5207           0 :     foundNonFiniteFloat = true;
    5208             :   }
    5209             :   double arg2;
    5210           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5211           0 :     return false;
    5212           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5213           0 :     foundNonFiniteFloat = true;
    5214             :   }
    5215             :   double arg3;
    5216           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    5217           0 :     return false;
    5218           0 :   } else if (!mozilla::IsFinite(arg3)) {
    5219           0 :     foundNonFiniteFloat = true;
    5220             :   }
    5221           0 :   if (foundNonFiniteFloat) {
    5222           0 :     args.rval().setUndefined();
    5223           0 :     return true;
    5224             :   }
    5225           0 :   self->ClearRect(arg0, arg1, arg2, arg3);
    5226           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5227           0 :   args.rval().setUndefined();
    5228           0 :   return true;
    5229             : }
    5230             : 
    5231             : static const JSJitInfo clearRect_methodinfo = {
    5232             :   { (JSJitGetterOp)clearRect },
    5233             :   { prototypes::id::CanvasRenderingContext2D },
    5234             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5235             :   JSJitInfo::Method,
    5236             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5237             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5238             :   false,  /* isInfallible. False in setters. */
    5239             :   false,  /* isMovable.  Not relevant for setters. */
    5240             :   false, /* isEliminatable.  Not relevant for setters. */
    5241             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5242             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5243             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5244             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5245             : };
    5246             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5247             : static_assert(0 < 1, "There is no slot for us");
    5248             : 
    5249             : static bool
    5250           0 : fillRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5251             : {
    5252           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    5253           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fillRect");
    5254             :   }
    5255           0 :   bool foundNonFiniteFloat = false;
    5256             :   double arg0;
    5257           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5258           0 :     return false;
    5259           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5260           0 :     foundNonFiniteFloat = true;
    5261             :   }
    5262             :   double arg1;
    5263           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5264           0 :     return false;
    5265           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5266           0 :     foundNonFiniteFloat = true;
    5267             :   }
    5268             :   double arg2;
    5269           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5270           0 :     return false;
    5271           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5272           0 :     foundNonFiniteFloat = true;
    5273             :   }
    5274             :   double arg3;
    5275           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    5276           0 :     return false;
    5277           0 :   } else if (!mozilla::IsFinite(arg3)) {
    5278           0 :     foundNonFiniteFloat = true;
    5279             :   }
    5280           0 :   if (foundNonFiniteFloat) {
    5281           0 :     args.rval().setUndefined();
    5282           0 :     return true;
    5283             :   }
    5284           0 :   self->FillRect(arg0, arg1, arg2, arg3);
    5285           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5286           0 :   args.rval().setUndefined();
    5287           0 :   return true;
    5288             : }
    5289             : 
    5290             : static const JSJitInfo fillRect_methodinfo = {
    5291             :   { (JSJitGetterOp)fillRect },
    5292             :   { prototypes::id::CanvasRenderingContext2D },
    5293             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5294             :   JSJitInfo::Method,
    5295             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5296             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5297             :   false,  /* isInfallible. False in setters. */
    5298             :   false,  /* isMovable.  Not relevant for setters. */
    5299             :   false, /* isEliminatable.  Not relevant for setters. */
    5300             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5301             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5302             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5303             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5304             : };
    5305             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5306             : static_assert(0 < 1, "There is no slot for us");
    5307             : 
    5308             : static bool
    5309           0 : strokeRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5310             : {
    5311           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    5312           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.strokeRect");
    5313             :   }
    5314           0 :   bool foundNonFiniteFloat = false;
    5315             :   double arg0;
    5316           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5317           0 :     return false;
    5318           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5319           0 :     foundNonFiniteFloat = true;
    5320             :   }
    5321             :   double arg1;
    5322           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5323           0 :     return false;
    5324           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5325           0 :     foundNonFiniteFloat = true;
    5326             :   }
    5327             :   double arg2;
    5328           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5329           0 :     return false;
    5330           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5331           0 :     foundNonFiniteFloat = true;
    5332             :   }
    5333             :   double arg3;
    5334           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    5335           0 :     return false;
    5336           0 :   } else if (!mozilla::IsFinite(arg3)) {
    5337           0 :     foundNonFiniteFloat = true;
    5338             :   }
    5339           0 :   if (foundNonFiniteFloat) {
    5340           0 :     args.rval().setUndefined();
    5341           0 :     return true;
    5342             :   }
    5343           0 :   self->StrokeRect(arg0, arg1, arg2, arg3);
    5344           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5345           0 :   args.rval().setUndefined();
    5346           0 :   return true;
    5347             : }
    5348             : 
    5349             : static const JSJitInfo strokeRect_methodinfo = {
    5350             :   { (JSJitGetterOp)strokeRect },
    5351             :   { prototypes::id::CanvasRenderingContext2D },
    5352             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5353             :   JSJitInfo::Method,
    5354             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5355             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5356             :   false,  /* isInfallible. False in setters. */
    5357             :   false,  /* isMovable.  Not relevant for setters. */
    5358             :   false, /* isEliminatable.  Not relevant for setters. */
    5359             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5360             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5361             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5362             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5363             : };
    5364             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5365             : static_assert(0 < 1, "There is no slot for us");
    5366             : 
    5367             : static bool
    5368           0 : get_shadowOffsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5369             : {
    5370           0 :   double result(self->ShadowOffsetX());
    5371           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5372           0 :   args.rval().set(JS_NumberValue(double(result)));
    5373           0 :   return true;
    5374             : }
    5375             : 
    5376             : static bool
    5377           0 : set_shadowOffsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5378             : {
    5379           0 :   bool foundNonFiniteFloat = false;
    5380             :   double arg0;
    5381           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5382           0 :     return false;
    5383           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5384           0 :     foundNonFiniteFloat = true;
    5385             :   }
    5386           0 :   if (foundNonFiniteFloat) {
    5387           0 :     return true;
    5388             :   }
    5389           0 :   self->SetShadowOffsetX(arg0);
    5390           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5391             : 
    5392           0 :   return true;
    5393             : }
    5394             : 
    5395             : static const JSJitInfo shadowOffsetX_getterinfo = {
    5396             :   { (JSJitGetterOp)get_shadowOffsetX },
    5397             :   { prototypes::id::CanvasRenderingContext2D },
    5398             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5399             :   JSJitInfo::Getter,
    5400             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5401             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    5402             :   true,  /* isInfallible. False in setters. */
    5403             :   false,  /* isMovable.  Not relevant for setters. */
    5404             :   false, /* isEliminatable.  Not relevant for setters. */
    5405             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5406             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5407             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5408             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5409             : };
    5410             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5411             : static_assert(0 < 1, "There is no slot for us");
    5412             : static const JSJitInfo shadowOffsetX_setterinfo = {
    5413             :   { (JSJitGetterOp)set_shadowOffsetX },
    5414             :   { prototypes::id::CanvasRenderingContext2D },
    5415             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5416             :   JSJitInfo::Setter,
    5417             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5418             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5419             :   false,  /* isInfallible. False in setters. */
    5420             :   false,  /* isMovable.  Not relevant for setters. */
    5421             :   false, /* isEliminatable.  Not relevant for setters. */
    5422             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5423             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5424             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5425             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5426             : };
    5427             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5428             : static_assert(0 < 1, "There is no slot for us");
    5429             : 
    5430             : static bool
    5431           0 : get_shadowOffsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5432             : {
    5433           0 :   double result(self->ShadowOffsetY());
    5434           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5435           0 :   args.rval().set(JS_NumberValue(double(result)));
    5436           0 :   return true;
    5437             : }
    5438             : 
    5439             : static bool
    5440           0 : set_shadowOffsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5441             : {
    5442           0 :   bool foundNonFiniteFloat = false;
    5443             :   double arg0;
    5444           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5445           0 :     return false;
    5446           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5447           0 :     foundNonFiniteFloat = true;
    5448             :   }
    5449           0 :   if (foundNonFiniteFloat) {
    5450           0 :     return true;
    5451             :   }
    5452           0 :   self->SetShadowOffsetY(arg0);
    5453           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5454             : 
    5455           0 :   return true;
    5456             : }
    5457             : 
    5458             : static const JSJitInfo shadowOffsetY_getterinfo = {
    5459             :   { (JSJitGetterOp)get_shadowOffsetY },
    5460             :   { prototypes::id::CanvasRenderingContext2D },
    5461             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5462             :   JSJitInfo::Getter,
    5463             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5464             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    5465             :   true,  /* isInfallible. False in setters. */
    5466             :   false,  /* isMovable.  Not relevant for setters. */
    5467             :   false, /* isEliminatable.  Not relevant for setters. */
    5468             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5469             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5470             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5471             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5472             : };
    5473             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5474             : static_assert(0 < 1, "There is no slot for us");
    5475             : static const JSJitInfo shadowOffsetY_setterinfo = {
    5476             :   { (JSJitGetterOp)set_shadowOffsetY },
    5477             :   { prototypes::id::CanvasRenderingContext2D },
    5478             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5479             :   JSJitInfo::Setter,
    5480             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5481             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5482             :   false,  /* isInfallible. False in setters. */
    5483             :   false,  /* isMovable.  Not relevant for setters. */
    5484             :   false, /* isEliminatable.  Not relevant for setters. */
    5485             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5486             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5487             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5488             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5489             : };
    5490             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5491             : static_assert(0 < 1, "There is no slot for us");
    5492             : 
    5493             : static bool
    5494           0 : get_shadowBlur(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5495             : {
    5496           0 :   double result(self->ShadowBlur());
    5497           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5498           0 :   args.rval().set(JS_NumberValue(double(result)));
    5499           0 :   return true;
    5500             : }
    5501             : 
    5502             : static bool
    5503           0 : set_shadowBlur(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5504             : {
    5505           0 :   bool foundNonFiniteFloat = false;
    5506             :   double arg0;
    5507           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    5508           0 :     return false;
    5509           0 :   } else if (!mozilla::IsFinite(arg0)) {
    5510           0 :     foundNonFiniteFloat = true;
    5511             :   }
    5512           0 :   if (foundNonFiniteFloat) {
    5513           0 :     return true;
    5514             :   }
    5515           0 :   self->SetShadowBlur(arg0);
    5516           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5517             : 
    5518           0 :   return true;
    5519             : }
    5520             : 
    5521             : static const JSJitInfo shadowBlur_getterinfo = {
    5522             :   { (JSJitGetterOp)get_shadowBlur },
    5523             :   { prototypes::id::CanvasRenderingContext2D },
    5524             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5525             :   JSJitInfo::Getter,
    5526             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5527             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    5528             :   true,  /* isInfallible. False in setters. */
    5529             :   false,  /* isMovable.  Not relevant for setters. */
    5530             :   false, /* isEliminatable.  Not relevant for setters. */
    5531             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5532             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5533             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5534             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5535             : };
    5536             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5537             : static_assert(0 < 1, "There is no slot for us");
    5538             : static const JSJitInfo shadowBlur_setterinfo = {
    5539             :   { (JSJitGetterOp)set_shadowBlur },
    5540             :   { prototypes::id::CanvasRenderingContext2D },
    5541             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5542             :   JSJitInfo::Setter,
    5543             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5544             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5545             :   false,  /* isInfallible. False in setters. */
    5546             :   false,  /* isMovable.  Not relevant for setters. */
    5547             :   false, /* isEliminatable.  Not relevant for setters. */
    5548             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5549             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5550             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5551             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5552             : };
    5553             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5554             : static_assert(0 < 1, "There is no slot for us");
    5555             : 
    5556             : static bool
    5557           0 : get_shadowColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5558             : {
    5559           0 :   DOMString result;
    5560           0 :   self->GetShadowColor(result);
    5561           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5562           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    5563           0 :     return false;
    5564             :   }
    5565           0 :   return true;
    5566             : }
    5567             : 
    5568             : static bool
    5569           0 : set_shadowColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5570             : {
    5571           0 :   binding_detail::FakeString arg0;
    5572           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5573           0 :     return false;
    5574             :   }
    5575           0 :   self->SetShadowColor(NonNullHelper(Constify(arg0)));
    5576           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5577             : 
    5578           0 :   return true;
    5579             : }
    5580             : 
    5581             : static const JSJitInfo shadowColor_getterinfo = {
    5582             :   { (JSJitGetterOp)get_shadowColor },
    5583             :   { prototypes::id::CanvasRenderingContext2D },
    5584             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5585             :   JSJitInfo::Getter,
    5586             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5587             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    5588             :   false,  /* isInfallible. False in setters. */
    5589             :   false,  /* isMovable.  Not relevant for setters. */
    5590             :   false, /* isEliminatable.  Not relevant for setters. */
    5591             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5592             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5593             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5594             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5595             : };
    5596             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5597             : static_assert(0 < 1, "There is no slot for us");
    5598             : static const JSJitInfo shadowColor_setterinfo = {
    5599             :   { (JSJitGetterOp)set_shadowColor },
    5600             :   { prototypes::id::CanvasRenderingContext2D },
    5601             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5602             :   JSJitInfo::Setter,
    5603             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5604             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5605             :   false,  /* isInfallible. False in setters. */
    5606             :   false,  /* isMovable.  Not relevant for setters. */
    5607             :   false, /* isEliminatable.  Not relevant for setters. */
    5608             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5609             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5610             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5611             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5612             : };
    5613             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5614             : static_assert(0 < 1, "There is no slot for us");
    5615             : 
    5616             : static bool
    5617           0 : save(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5618             : {
    5619           0 :   self->Save();
    5620           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5621           0 :   args.rval().setUndefined();
    5622           0 :   return true;
    5623             : }
    5624             : 
    5625             : static const JSJitInfo save_methodinfo = {
    5626             :   { (JSJitGetterOp)save },
    5627             :   { prototypes::id::CanvasRenderingContext2D },
    5628             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5629             :   JSJitInfo::Method,
    5630             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5631             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5632             :   true,  /* isInfallible. False in setters. */
    5633             :   false,  /* isMovable.  Not relevant for setters. */
    5634             :   false, /* isEliminatable.  Not relevant for setters. */
    5635             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5636             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5637             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5638             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5639             : };
    5640             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5641             : static_assert(0 < 1, "There is no slot for us");
    5642             : 
    5643             : static bool
    5644           0 : restore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5645             : {
    5646           0 :   self->Restore();
    5647           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5648           0 :   args.rval().setUndefined();
    5649           0 :   return true;
    5650             : }
    5651             : 
    5652             : static const JSJitInfo restore_methodinfo = {
    5653             :   { (JSJitGetterOp)restore },
    5654             :   { prototypes::id::CanvasRenderingContext2D },
    5655             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5656             :   JSJitInfo::Method,
    5657             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5658             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5659             :   true,  /* isInfallible. False in setters. */
    5660             :   false,  /* isMovable.  Not relevant for setters. */
    5661             :   false, /* isEliminatable.  Not relevant for setters. */
    5662             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5663             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5664             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5665             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5666             : };
    5667             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5668             : static_assert(0 < 1, "There is no slot for us");
    5669             : 
    5670             : static bool
    5671           0 : fillText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5672             : {
    5673           0 :   if (MOZ_UNLIKELY(args.length() < 3)) {
    5674           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fillText");
    5675             :   }
    5676           0 :   bool foundNonFiniteFloat = false;
    5677           0 :   binding_detail::FakeString arg0;
    5678           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5679           0 :     return false;
    5680             :   }
    5681             :   double arg1;
    5682           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5683           0 :     return false;
    5684           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5685           0 :     foundNonFiniteFloat = true;
    5686             :   }
    5687             :   double arg2;
    5688           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5689           0 :     return false;
    5690           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5691           0 :     foundNonFiniteFloat = true;
    5692             :   }
    5693           0 :   Optional<double> arg3;
    5694           0 :   if (args.hasDefined(3)) {
    5695           0 :     arg3.Construct();
    5696           0 :     if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3.Value())) {
    5697           0 :       return false;
    5698           0 :     } else if (!mozilla::IsFinite(arg3.Value())) {
    5699           0 :       foundNonFiniteFloat = true;
    5700             :     }
    5701             :   }
    5702           0 :   if (foundNonFiniteFloat) {
    5703           0 :     args.rval().setUndefined();
    5704           0 :     return true;
    5705             :   }
    5706           0 :   binding_detail::FastErrorResult rv;
    5707           0 :   self->FillText(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), rv);
    5708           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5709           0 :     return false;
    5710             :   }
    5711           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5712           0 :   args.rval().setUndefined();
    5713           0 :   return true;
    5714             : }
    5715             : 
    5716             : static const JSJitInfo fillText_methodinfo = {
    5717             :   { (JSJitGetterOp)fillText },
    5718             :   { prototypes::id::CanvasRenderingContext2D },
    5719             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5720             :   JSJitInfo::Method,
    5721             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5722             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5723             :   false,  /* isInfallible. False in setters. */
    5724             :   false,  /* isMovable.  Not relevant for setters. */
    5725             :   false, /* isEliminatable.  Not relevant for setters. */
    5726             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5727             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5728             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5729             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5730             : };
    5731             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5732             : static_assert(0 < 1, "There is no slot for us");
    5733             : 
    5734             : static bool
    5735           0 : strokeText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5736             : {
    5737           0 :   if (MOZ_UNLIKELY(args.length() < 3)) {
    5738           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.strokeText");
    5739             :   }
    5740           0 :   bool foundNonFiniteFloat = false;
    5741           0 :   binding_detail::FakeString arg0;
    5742           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5743           0 :     return false;
    5744             :   }
    5745             :   double arg1;
    5746           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    5747           0 :     return false;
    5748           0 :   } else if (!mozilla::IsFinite(arg1)) {
    5749           0 :     foundNonFiniteFloat = true;
    5750             :   }
    5751             :   double arg2;
    5752           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    5753           0 :     return false;
    5754           0 :   } else if (!mozilla::IsFinite(arg2)) {
    5755           0 :     foundNonFiniteFloat = true;
    5756             :   }
    5757           0 :   Optional<double> arg3;
    5758           0 :   if (args.hasDefined(3)) {
    5759           0 :     arg3.Construct();
    5760           0 :     if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3.Value())) {
    5761           0 :       return false;
    5762           0 :     } else if (!mozilla::IsFinite(arg3.Value())) {
    5763           0 :       foundNonFiniteFloat = true;
    5764             :     }
    5765             :   }
    5766           0 :   if (foundNonFiniteFloat) {
    5767           0 :     args.rval().setUndefined();
    5768           0 :     return true;
    5769             :   }
    5770           0 :   binding_detail::FastErrorResult rv;
    5771           0 :   self->StrokeText(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), rv);
    5772           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5773           0 :     return false;
    5774             :   }
    5775           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5776           0 :   args.rval().setUndefined();
    5777           0 :   return true;
    5778             : }
    5779             : 
    5780             : static const JSJitInfo strokeText_methodinfo = {
    5781             :   { (JSJitGetterOp)strokeText },
    5782             :   { prototypes::id::CanvasRenderingContext2D },
    5783             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5784             :   JSJitInfo::Method,
    5785             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5786             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5787             :   false,  /* isInfallible. False in setters. */
    5788             :   false,  /* isMovable.  Not relevant for setters. */
    5789             :   false, /* isEliminatable.  Not relevant for setters. */
    5790             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5791             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5792             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5793             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5794             : };
    5795             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5796             : static_assert(0 < 1, "There is no slot for us");
    5797             : 
    5798             : static bool
    5799           0 : measureText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    5800             : {
    5801           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    5802           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.measureText");
    5803             :   }
    5804           0 :   binding_detail::FakeString arg0;
    5805           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5806           0 :     return false;
    5807             :   }
    5808           0 :   binding_detail::FastErrorResult rv;
    5809           0 :   auto result(StrongOrRawPtr<mozilla::dom::TextMetrics>(self->MeasureText(NonNullHelper(Constify(arg0)), rv)));
    5810           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5811           0 :     return false;
    5812             :   }
    5813           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5814             :   static_assert(!IsPointer<decltype(result)>::value,
    5815             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    5816           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
    5817           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    5818           0 :     return false;
    5819             :   }
    5820           0 :   return true;
    5821             : }
    5822             : 
    5823             : static const JSJitInfo measureText_methodinfo = {
    5824             :   { (JSJitGetterOp)measureText },
    5825             :   { prototypes::id::CanvasRenderingContext2D },
    5826             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5827             :   JSJitInfo::Method,
    5828             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5829             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    5830             :   false,  /* isInfallible. False in setters. */
    5831             :   false,  /* isMovable.  Not relevant for setters. */
    5832             :   false, /* isEliminatable.  Not relevant for setters. */
    5833             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5834             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5835             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5836             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5837             : };
    5838             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5839             : static_assert(0 < 1, "There is no slot for us");
    5840             : 
    5841             : static bool
    5842           0 : get_font(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5843             : {
    5844           0 :   DOMString result;
    5845           0 :   self->GetFont(result);
    5846           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5847           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    5848           0 :     return false;
    5849             :   }
    5850           0 :   return true;
    5851             : }
    5852             : 
    5853             : static bool
    5854           0 : set_font(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5855             : {
    5856           0 :   binding_detail::FakeString arg0;
    5857           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5858           0 :     return false;
    5859             :   }
    5860           0 :   binding_detail::FastErrorResult rv;
    5861           0 :   self->SetFont(NonNullHelper(Constify(arg0)), rv);
    5862           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5863           0 :     return false;
    5864             :   }
    5865           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5866             : 
    5867           0 :   return true;
    5868             : }
    5869             : 
    5870             : static const JSJitInfo font_getterinfo = {
    5871             :   { (JSJitGetterOp)get_font },
    5872             :   { prototypes::id::CanvasRenderingContext2D },
    5873             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5874             :   JSJitInfo::Getter,
    5875             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5876             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    5877             :   false,  /* isInfallible. False in setters. */
    5878             :   false,  /* isMovable.  Not relevant for setters. */
    5879             :   false, /* isEliminatable.  Not relevant for setters. */
    5880             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5881             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5882             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5883             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5884             : };
    5885             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5886             : static_assert(0 < 1, "There is no slot for us");
    5887             : static const JSJitInfo font_setterinfo = {
    5888             :   { (JSJitGetterOp)set_font },
    5889             :   { prototypes::id::CanvasRenderingContext2D },
    5890             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5891             :   JSJitInfo::Setter,
    5892             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5893             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5894             :   false,  /* isInfallible. False in setters. */
    5895             :   false,  /* isMovable.  Not relevant for setters. */
    5896             :   false, /* isEliminatable.  Not relevant for setters. */
    5897             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5898             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5899             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5900             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5901             : };
    5902             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5903             : static_assert(0 < 1, "There is no slot for us");
    5904             : 
    5905             : static bool
    5906           0 : get_textAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5907             : {
    5908           0 :   DOMString result;
    5909           0 :   self->GetTextAlign(result);
    5910           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5911           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    5912           0 :     return false;
    5913             :   }
    5914           0 :   return true;
    5915             : }
    5916             : 
    5917             : static bool
    5918           0 : set_textAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5919             : {
    5920           0 :   binding_detail::FakeString arg0;
    5921           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5922           0 :     return false;
    5923             :   }
    5924           0 :   self->SetTextAlign(NonNullHelper(Constify(arg0)));
    5925           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5926             : 
    5927           0 :   return true;
    5928             : }
    5929             : 
    5930             : static const JSJitInfo textAlign_getterinfo = {
    5931             :   { (JSJitGetterOp)get_textAlign },
    5932             :   { prototypes::id::CanvasRenderingContext2D },
    5933             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5934             :   JSJitInfo::Getter,
    5935             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5936             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    5937             :   false,  /* isInfallible. False in setters. */
    5938             :   false,  /* isMovable.  Not relevant for setters. */
    5939             :   false, /* isEliminatable.  Not relevant for setters. */
    5940             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5941             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5942             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5943             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5944             : };
    5945             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5946             : static_assert(0 < 1, "There is no slot for us");
    5947             : static const JSJitInfo textAlign_setterinfo = {
    5948             :   { (JSJitGetterOp)set_textAlign },
    5949             :   { prototypes::id::CanvasRenderingContext2D },
    5950             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5951             :   JSJitInfo::Setter,
    5952             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5953             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    5954             :   false,  /* isInfallible. False in setters. */
    5955             :   false,  /* isMovable.  Not relevant for setters. */
    5956             :   false, /* isEliminatable.  Not relevant for setters. */
    5957             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5958             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5959             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5960             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5961             : };
    5962             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5963             : static_assert(0 < 1, "There is no slot for us");
    5964             : 
    5965             : static bool
    5966           0 : get_textBaseline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
    5967             : {
    5968           0 :   DOMString result;
    5969           0 :   self->GetTextBaseline(result);
    5970           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5971           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    5972           0 :     return false;
    5973             :   }
    5974           0 :   return true;
    5975             : }
    5976             : 
    5977             : static bool
    5978           0 : set_textBaseline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
    5979             : {
    5980           0 :   binding_detail::FakeString arg0;
    5981           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    5982           0 :     return false;
    5983             :   }
    5984           0 :   self->SetTextBaseline(NonNullHelper(Constify(arg0)));
    5985           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5986             : 
    5987           0 :   return true;
    5988             : }
    5989             : 
    5990             : static const JSJitInfo textBaseline_getterinfo = {
    5991             :   { (JSJitGetterOp)get_textBaseline },
    5992             :   { prototypes::id::CanvasRenderingContext2D },
    5993             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    5994             :   JSJitInfo::Getter,
    5995             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5996             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    5997             :   false,  /* isInfallible. False in setters. */
    5998             :   false,  /* isMovable.  Not relevant for setters. */
    5999             :   false, /* isEliminatable.  Not relevant for setters. */
    6000             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6001             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6002             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6003             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6004             : };
    6005             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6006             : static_assert(0 < 1, "There is no slot for us");
    6007             : static const JSJitInfo textBaseline_setterinfo = {
    6008             :   { (JSJitGetterOp)set_textBaseline },
    6009             :   { prototypes::id::CanvasRenderingContext2D },
    6010             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6011             :   JSJitInfo::Setter,
    6012             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6013             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6014             :   false,  /* isInfallible. False in setters. */
    6015             :   false,  /* isMovable.  Not relevant for setters. */
    6016             :   false, /* isEliminatable.  Not relevant for setters. */
    6017             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6018             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6019             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6020             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6021             : };
    6022             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6023             : static_assert(0 < 1, "There is no slot for us");
    6024             : 
    6025             : static bool
    6026           0 : scale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6027             : {
    6028           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    6029           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.scale");
    6030             :   }
    6031           0 :   bool foundNonFiniteFloat = false;
    6032             :   double arg0;
    6033           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    6034           0 :     return false;
    6035           0 :   } else if (!mozilla::IsFinite(arg0)) {
    6036           0 :     foundNonFiniteFloat = true;
    6037             :   }
    6038             :   double arg1;
    6039           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    6040           0 :     return false;
    6041           0 :   } else if (!mozilla::IsFinite(arg1)) {
    6042           0 :     foundNonFiniteFloat = true;
    6043             :   }
    6044           0 :   if (foundNonFiniteFloat) {
    6045           0 :     args.rval().setUndefined();
    6046           0 :     return true;
    6047             :   }
    6048           0 :   binding_detail::FastErrorResult rv;
    6049           0 :   self->Scale(arg0, arg1, rv);
    6050           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6051           0 :     return false;
    6052             :   }
    6053           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6054           0 :   args.rval().setUndefined();
    6055           0 :   return true;
    6056             : }
    6057             : 
    6058             : static const JSJitInfo scale_methodinfo = {
    6059             :   { (JSJitGetterOp)scale },
    6060             :   { prototypes::id::CanvasRenderingContext2D },
    6061             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6062             :   JSJitInfo::Method,
    6063             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6064             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6065             :   false,  /* isInfallible. False in setters. */
    6066             :   false,  /* isMovable.  Not relevant for setters. */
    6067             :   false, /* isEliminatable.  Not relevant for setters. */
    6068             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6069             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6070             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6071             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6072             : };
    6073             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6074             : static_assert(0 < 1, "There is no slot for us");
    6075             : 
    6076             : static bool
    6077           0 : rotate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6078             : {
    6079           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    6080           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.rotate");
    6081             :   }
    6082           0 :   bool foundNonFiniteFloat = false;
    6083             :   double arg0;
    6084           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    6085           0 :     return false;
    6086           0 :   } else if (!mozilla::IsFinite(arg0)) {
    6087           0 :     foundNonFiniteFloat = true;
    6088             :   }
    6089           0 :   if (foundNonFiniteFloat) {
    6090           0 :     args.rval().setUndefined();
    6091           0 :     return true;
    6092             :   }
    6093           0 :   binding_detail::FastErrorResult rv;
    6094           0 :   self->Rotate(arg0, rv);
    6095           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6096           0 :     return false;
    6097             :   }
    6098           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6099           0 :   args.rval().setUndefined();
    6100           0 :   return true;
    6101             : }
    6102             : 
    6103             : static const JSJitInfo rotate_methodinfo = {
    6104             :   { (JSJitGetterOp)rotate },
    6105             :   { prototypes::id::CanvasRenderingContext2D },
    6106             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6107             :   JSJitInfo::Method,
    6108             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6109             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6110             :   false,  /* isInfallible. False in setters. */
    6111             :   false,  /* isMovable.  Not relevant for setters. */
    6112             :   false, /* isEliminatable.  Not relevant for setters. */
    6113             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6114             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6115             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6116             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6117             : };
    6118             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6119             : static_assert(0 < 1, "There is no slot for us");
    6120             : 
    6121             : static bool
    6122           0 : translate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6123             : {
    6124           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    6125           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.translate");
    6126             :   }
    6127           0 :   bool foundNonFiniteFloat = false;
    6128             :   double arg0;
    6129           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    6130           0 :     return false;
    6131           0 :   } else if (!mozilla::IsFinite(arg0)) {
    6132           0 :     foundNonFiniteFloat = true;
    6133             :   }
    6134             :   double arg1;
    6135           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    6136           0 :     return false;
    6137           0 :   } else if (!mozilla::IsFinite(arg1)) {
    6138           0 :     foundNonFiniteFloat = true;
    6139             :   }
    6140           0 :   if (foundNonFiniteFloat) {
    6141           0 :     args.rval().setUndefined();
    6142           0 :     return true;
    6143             :   }
    6144           0 :   binding_detail::FastErrorResult rv;
    6145           0 :   self->Translate(arg0, arg1, rv);
    6146           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6147           0 :     return false;
    6148             :   }
    6149           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6150           0 :   args.rval().setUndefined();
    6151           0 :   return true;
    6152             : }
    6153             : 
    6154             : static const JSJitInfo translate_methodinfo = {
    6155             :   { (JSJitGetterOp)translate },
    6156             :   { prototypes::id::CanvasRenderingContext2D },
    6157             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6158             :   JSJitInfo::Method,
    6159             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6160             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6161             :   false,  /* isInfallible. False in setters. */
    6162             :   false,  /* isMovable.  Not relevant for setters. */
    6163             :   false, /* isEliminatable.  Not relevant for setters. */
    6164             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6165             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6166             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6167             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6168             : };
    6169             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6170             : static_assert(0 < 1, "There is no slot for us");
    6171             : 
    6172             : static bool
    6173           0 : transform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6174             : {
    6175           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    6176           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.transform");
    6177             :   }
    6178           0 :   bool foundNonFiniteFloat = false;
    6179             :   double arg0;
    6180           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    6181           0 :     return false;
    6182           0 :   } else if (!mozilla::IsFinite(arg0)) {
    6183           0 :     foundNonFiniteFloat = true;
    6184             :   }
    6185             :   double arg1;
    6186           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    6187           0 :     return false;
    6188           0 :   } else if (!mozilla::IsFinite(arg1)) {
    6189           0 :     foundNonFiniteFloat = true;
    6190             :   }
    6191             :   double arg2;
    6192           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    6193           0 :     return false;
    6194           0 :   } else if (!mozilla::IsFinite(arg2)) {
    6195           0 :     foundNonFiniteFloat = true;
    6196             :   }
    6197             :   double arg3;
    6198           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    6199           0 :     return false;
    6200           0 :   } else if (!mozilla::IsFinite(arg3)) {
    6201           0 :     foundNonFiniteFloat = true;
    6202             :   }
    6203             :   double arg4;
    6204           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    6205           0 :     return false;
    6206           0 :   } else if (!mozilla::IsFinite(arg4)) {
    6207           0 :     foundNonFiniteFloat = true;
    6208             :   }
    6209             :   double arg5;
    6210           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    6211           0 :     return false;
    6212           0 :   } else if (!mozilla::IsFinite(arg5)) {
    6213           0 :     foundNonFiniteFloat = true;
    6214             :   }
    6215           0 :   if (foundNonFiniteFloat) {
    6216           0 :     args.rval().setUndefined();
    6217           0 :     return true;
    6218             :   }
    6219           0 :   binding_detail::FastErrorResult rv;
    6220           0 :   self->Transform(arg0, arg1, arg2, arg3, arg4, arg5, rv);
    6221           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6222           0 :     return false;
    6223             :   }
    6224           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6225           0 :   args.rval().setUndefined();
    6226           0 :   return true;
    6227             : }
    6228             : 
    6229             : static const JSJitInfo transform_methodinfo = {
    6230             :   { (JSJitGetterOp)transform },
    6231             :   { prototypes::id::CanvasRenderingContext2D },
    6232             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6233             :   JSJitInfo::Method,
    6234             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6235             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6236             :   false,  /* isInfallible. False in setters. */
    6237             :   false,  /* isMovable.  Not relevant for setters. */
    6238             :   false, /* isEliminatable.  Not relevant for setters. */
    6239             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6240             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6241             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6242             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6243             : };
    6244             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6245             : static_assert(0 < 1, "There is no slot for us");
    6246             : 
    6247             : static bool
    6248           0 : setTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6249             : {
    6250           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    6251           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.setTransform");
    6252             :   }
    6253           0 :   bool foundNonFiniteFloat = false;
    6254             :   double arg0;
    6255           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    6256           0 :     return false;
    6257           0 :   } else if (!mozilla::IsFinite(arg0)) {
    6258           0 :     foundNonFiniteFloat = true;
    6259             :   }
    6260             :   double arg1;
    6261           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    6262           0 :     return false;
    6263           0 :   } else if (!mozilla::IsFinite(arg1)) {
    6264           0 :     foundNonFiniteFloat = true;
    6265             :   }
    6266             :   double arg2;
    6267           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    6268           0 :     return false;
    6269           0 :   } else if (!mozilla::IsFinite(arg2)) {
    6270           0 :     foundNonFiniteFloat = true;
    6271             :   }
    6272             :   double arg3;
    6273           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    6274           0 :     return false;
    6275           0 :   } else if (!mozilla::IsFinite(arg3)) {
    6276           0 :     foundNonFiniteFloat = true;
    6277             :   }
    6278             :   double arg4;
    6279           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    6280           0 :     return false;
    6281           0 :   } else if (!mozilla::IsFinite(arg4)) {
    6282           0 :     foundNonFiniteFloat = true;
    6283             :   }
    6284             :   double arg5;
    6285           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    6286           0 :     return false;
    6287           0 :   } else if (!mozilla::IsFinite(arg5)) {
    6288           0 :     foundNonFiniteFloat = true;
    6289             :   }
    6290           0 :   if (foundNonFiniteFloat) {
    6291           0 :     args.rval().setUndefined();
    6292           0 :     return true;
    6293             :   }
    6294           0 :   binding_detail::FastErrorResult rv;
    6295           0 :   self->SetTransform(arg0, arg1, arg2, arg3, arg4, arg5, rv);
    6296           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6297           0 :     return false;
    6298             :   }
    6299           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6300           0 :   args.rval().setUndefined();
    6301           0 :   return true;
    6302             : }
    6303             : 
    6304             : static const JSJitInfo setTransform_methodinfo = {
    6305             :   { (JSJitGetterOp)setTransform },
    6306             :   { prototypes::id::CanvasRenderingContext2D },
    6307             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6308             :   JSJitInfo::Method,
    6309             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6310             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6311             :   false,  /* isInfallible. False in setters. */
    6312             :   false,  /* isMovable.  Not relevant for setters. */
    6313             :   false, /* isEliminatable.  Not relevant for setters. */
    6314             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6315             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6316             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6317             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6318             : };
    6319             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6320             : static_assert(0 < 1, "There is no slot for us");
    6321             : 
    6322             : static bool
    6323           0 : resetTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6324             : {
    6325           0 :   binding_detail::FastErrorResult rv;
    6326           0 :   self->ResetTransform(rv);
    6327           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6328           0 :     return false;
    6329             :   }
    6330           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6331           0 :   args.rval().setUndefined();
    6332           0 :   return true;
    6333             : }
    6334             : 
    6335             : static const JSJitInfo resetTransform_methodinfo = {
    6336             :   { (JSJitGetterOp)resetTransform },
    6337             :   { prototypes::id::CanvasRenderingContext2D },
    6338             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6339             :   JSJitInfo::Method,
    6340             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6341             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6342             :   false,  /* isInfallible. False in setters. */
    6343             :   false,  /* isMovable.  Not relevant for setters. */
    6344             :   false, /* isEliminatable.  Not relevant for setters. */
    6345             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6346             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6347             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6348             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6349             : };
    6350             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6351             : static_assert(0 < 1, "There is no slot for us");
    6352             : 
    6353             : static bool
    6354           0 : drawFocusIfNeeded(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6355             : {
    6356           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    6357           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawFocusIfNeeded");
    6358             :   }
    6359           0 :   NonNull<mozilla::dom::Element> arg0;
    6360           0 :   if (args[0].isObject()) {
    6361             :     {
    6362           0 :       nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
    6363           0 :       if (NS_FAILED(rv)) {
    6364           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawFocusIfNeeded", "Element");
    6365           0 :         return false;
    6366             :       }
    6367             :     }
    6368             :   } else {
    6369           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawFocusIfNeeded");
    6370           0 :     return false;
    6371             :   }
    6372           0 :   binding_detail::FastErrorResult rv;
    6373           0 :   self->DrawFocusIfNeeded(NonNullHelper(arg0), rv);
    6374           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    6375           0 :     return false;
    6376             :   }
    6377           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6378           0 :   args.rval().setUndefined();
    6379           0 :   return true;
    6380             : }
    6381             : 
    6382             : static const JSJitInfo drawFocusIfNeeded_methodinfo = {
    6383             :   { (JSJitGetterOp)drawFocusIfNeeded },
    6384             :   { prototypes::id::CanvasRenderingContext2D },
    6385             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6386             :   JSJitInfo::Method,
    6387             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6388             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    6389             :   false,  /* isInfallible. False in setters. */
    6390             :   false,  /* isMovable.  Not relevant for setters. */
    6391             :   false, /* isEliminatable.  Not relevant for setters. */
    6392             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6393             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6394             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6395             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6396             : };
    6397             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6398             : static_assert(0 < 1, "There is no slot for us");
    6399             : 
    6400             : static bool
    6401           0 : drawCustomFocusRing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
    6402             : {
    6403           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    6404           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawCustomFocusRing");
    6405             :   }
    6406           0 :   NonNull<mozilla::dom::Element> arg0;
    6407           0 :   if (args[0].isObject()) {
    6408             :     {
    6409           0 :       nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
    6410           0 :       if (NS_FAILED(rv)) {
    6411           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawCustomFocusRing", "Element");
    6412           0 :         return false;
    6413             :       }
    6414             :     }
    6415             :   } else {
    6416           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawCustomFocusRing");
    6417           0 :     return false;
    6418             :   }
    6419           0 :   bool result(self->DrawCustomFocusRing(NonNullHelper(arg0)));
    6420           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    6421           0 :   args.rval().setBoolean(result);
    6422           0 :   return true;
    6423             : }
    6424             : 
    6425             : static const JSJitInfo drawCustomFocusRing_methodinfo = {
    6426             :   { (JSJitGetterOp)drawCustomFocusRing },
    6427             :   { prototypes::id::CanvasRenderingContext2D },
    6428             :   { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
    6429             :   JSJitInfo::Method,
    6430             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    6431             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    6432             :   false,  /* isInfallible. False in setters. */
    6433             :   false,  /* isMovable.  Not relevant for setters. */
    6434             :   false, /* isEliminatable.  Not relevant for setters. */
    6435             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    6436             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    6437             :   false,  /* isTypedMethod.  Only relevant for methods. */
    6438             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    6439             : };
    6440             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    6441             : static_assert(0 < 1, "There is no slot for us");
    6442             : 
    6443             : static bool
    6444           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    6445             : {
    6446           0 :   mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
    6447             :   // We don't want to preserve if we don't have a wrapper, and we
    6448             :   // obviously can't preserve if we're not initialized.
    6449           0 :   if (self && self->GetWrapperPreserveColor()) {
    6450           0 :     PreserveWrapper(self);
    6451             :   }
    6452           0 :   return true;
    6453             : }
    6454             : 
    6455             : static void
    6456           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    6457             : {
    6458           0 :   mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
    6459           0 :   if (self) {
    6460           0 :     ClearWrapper(self, self, obj);
    6461           0 :     AddForDeferredFinalization<mozilla::dom::CanvasRenderingContext2D>(self);
    6462             :   }
    6463           0 : }
    6464             : 
    6465             : static void
    6466           0 : _objectMoved(JSObject* obj, const JSObject* old)
    6467             : {
    6468           0 :   mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
    6469           0 :   if (self) {
    6470           0 :     UpdateWrapper(self, self, obj, old);
    6471             :   }
    6472           0 : }
    6473             : 
    6474             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    6475             : #if defined(__clang__)
    6476             : #pragma clang diagnostic push
    6477             : #pragma clang diagnostic ignored "-Wmissing-braces"
    6478             : #endif
    6479             : static const JSFunctionSpec sMethods_specs[] = {
    6480             :   JS_FNSPEC("drawWindow", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&drawWindow_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    6481             :   JS_FS_END,
    6482             :   JS_FNSPEC("drawImage", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&drawImage_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
    6483             :   JS_FNSPEC("beginPath", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&beginPath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6484             :   JS_FNSPEC("fill", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&fill_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6485             :   JS_FNSPEC("stroke", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&stroke_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6486             :   JS_FNSPEC("clip", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clip_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6487             :   JS_FNSPEC("isPointInPath", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&isPointInPath_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6488             :   JS_FNSPEC("isPointInStroke", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&isPointInStroke_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6489             :   JS_FNSPEC("createLinearGradient", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createLinearGradient_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6490             :   JS_FNSPEC("createRadialGradient", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createRadialGradient_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    6491             :   JS_FNSPEC("createPattern", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createPattern_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6492             :   JS_FS_END,
    6493             :   JS_FNSPEC("addHitRegion", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addHitRegion_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6494             :   JS_FNSPEC("removeHitRegion", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeHitRegion_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6495             :   JS_FNSPEC("clearHitRegions", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clearHitRegions_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6496             :   JS_FS_END,
    6497             :   JS_FNSPEC("createImageData", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createImageData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6498             :   JS_FNSPEC("getImageData", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getImageData_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6499             :   JS_FNSPEC("putImageData", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&putImageData_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
    6500             :   JS_FNSPEC("setLineDash", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setLineDash_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6501             :   JS_FNSPEC("getLineDash", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getLineDash_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6502             :   JS_FNSPEC("closePath", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&closePath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6503             :   JS_FNSPEC("moveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&moveTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6504             :   JS_FNSPEC("lineTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&lineTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6505             :   JS_FNSPEC("quadraticCurveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&quadraticCurveTo_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6506             :   JS_FNSPEC("bezierCurveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&bezierCurveTo_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    6507             :   JS_FNSPEC("arcTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&arcTo_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
    6508             :   JS_FNSPEC("rect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&rect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6509             :   JS_FNSPEC("arc", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&arc_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
    6510             :   JS_FNSPEC("ellipse", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&ellipse_methodinfo), 7, JSPROP_ENUMERATE, nullptr),
    6511             :   JS_FNSPEC("clearRect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clearRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6512             :   JS_FNSPEC("fillRect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&fillRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6513             :   JS_FNSPEC("strokeRect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&strokeRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    6514             :   JS_FNSPEC("save", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&save_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6515             :   JS_FNSPEC("restore", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&restore_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6516             :   JS_FNSPEC("fillText", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&fillText_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
    6517             :   JS_FNSPEC("strokeText", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&strokeText_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
    6518             :   JS_FNSPEC("measureText", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&measureText_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6519             :   JS_FNSPEC("scale", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&scale_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6520             :   JS_FNSPEC("rotate", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&rotate_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6521             :   JS_FNSPEC("translate", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&translate_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    6522             :   JS_FNSPEC("transform", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&transform_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    6523             :   JS_FNSPEC("setTransform", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setTransform_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    6524             :   JS_FNSPEC("resetTransform", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resetTransform_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6525             :   JS_FS_END,
    6526             :   JS_FNSPEC("drawFocusIfNeeded", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&drawFocusIfNeeded_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6527             :   JS_FS_END,
    6528             :   JS_FNSPEC("drawCustomFocusRing", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&drawCustomFocusRing_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    6529             :   JS_FS_END
    6530             : };
    6531             : #if defined(__clang__)
    6532             : #pragma clang diagnostic pop
    6533             : #endif
    6534             : 
    6535             : static PrefableDisablers sMethods_disablers0 = {
    6536             :   true, false, 0, &CanvasUtils::HasDrawWindowPrivilege
    6537             : };
    6538             : 
    6539             : static PrefableDisablers sMethods_disablers13 = {
    6540             :   true, false, 0, nullptr
    6541             : };
    6542             : 
    6543             : static PrefableDisablers sMethods_disablers46 = {
    6544             :   true, false, 0, nullptr
    6545             : };
    6546             : 
    6547             : static PrefableDisablers sMethods_disablers48 = {
    6548             :   true, false, 0, nullptr
    6549             : };
    6550             : 
    6551             : // Can't be const because the pref-enabled boolean needs to be writable
    6552             : static Prefable<const JSFunctionSpec> sMethods[] = {
    6553             :   { &sMethods_disablers0, &sMethods_specs[0] },
    6554             :   { nullptr, &sMethods_specs[2] },
    6555             :   { &sMethods_disablers13, &sMethods_specs[13] },
    6556             :   { nullptr, &sMethods_specs[17] },
    6557             :   { &sMethods_disablers46, &sMethods_specs[46] },
    6558             :   { &sMethods_disablers48, &sMethods_specs[48] },
    6559             :   { nullptr, nullptr }
    6560             : };
    6561             : 
    6562             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    6563             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    6564             : static_assert(28 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    6565             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    6566             : 
    6567             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    6568             : #if defined(__clang__)
    6569             : #pragma clang diagnostic push
    6570             : #pragma clang diagnostic ignored "-Wmissing-braces"
    6571             : #endif
    6572             : static const JSFunctionSpec sChromeMethods_specs[] = {
    6573             :   JS_FNSPEC("demote", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&demote_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    6574             :   JS_FS_END
    6575             : };
    6576             : #if defined(__clang__)
    6577             : #pragma clang diagnostic pop
    6578             : #endif
    6579             : 
    6580             : 
    6581             : // Can't be const because the pref-enabled boolean needs to be writable
    6582             : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
    6583             :   { nullptr, &sChromeMethods_specs[0] },
    6584             :   { nullptr, nullptr }
    6585             : };
    6586             : 
    6587             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    6588             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    6589             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    6590             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    6591             : 
    6592             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    6593             : #if defined(__clang__)
    6594             : #pragma clang diagnostic push
    6595             : #pragma clang diagnostic ignored "-Wmissing-braces"
    6596             : #endif
    6597             : static const JSPropertySpec sAttributes_specs[] = {
    6598             :   { "canvas", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &canvas_getterinfo, nullptr, nullptr },
    6599             :   { "mozCurrentTransform", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozCurrentTransform_getterinfo, GenericBindingSetter, &mozCurrentTransform_setterinfo },
    6600             :   { "mozCurrentTransformInverse", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozCurrentTransformInverse_getterinfo, GenericBindingSetter, &mozCurrentTransformInverse_setterinfo },
    6601             :   { "mozTextStyle", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozTextStyle_getterinfo, GenericBindingSetter, &mozTextStyle_setterinfo },
    6602             :   { "mozImageSmoothingEnabled", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozImageSmoothingEnabled_getterinfo, GenericBindingSetter, &mozImageSmoothingEnabled_setterinfo },
    6603             :   { "globalAlpha", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &globalAlpha_getterinfo, GenericBindingSetter, &globalAlpha_setterinfo },
    6604             :   { "globalCompositeOperation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &globalCompositeOperation_getterinfo, GenericBindingSetter, &globalCompositeOperation_setterinfo },
    6605             :   { "strokeStyle", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &strokeStyle_getterinfo, GenericBindingSetter, &strokeStyle_setterinfo },
    6606             :   { "fillStyle", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &fillStyle_getterinfo, GenericBindingSetter, &fillStyle_setterinfo },
    6607             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    6608             :   { "filter", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &filter_getterinfo, GenericBindingSetter, &filter_setterinfo },
    6609             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    6610             :   { "imageSmoothingEnabled", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &imageSmoothingEnabled_getterinfo, GenericBindingSetter, &imageSmoothingEnabled_setterinfo },
    6611             :   { "lineWidth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineWidth_getterinfo, GenericBindingSetter, &lineWidth_setterinfo },
    6612             :   { "lineCap", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineCap_getterinfo, GenericBindingSetter, &lineCap_setterinfo },
    6613             :   { "lineJoin", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineJoin_getterinfo, GenericBindingSetter, &lineJoin_setterinfo },
    6614             :   { "miterLimit", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &miterLimit_getterinfo, GenericBindingSetter, &miterLimit_setterinfo },
    6615             :   { "lineDashOffset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lineDashOffset_getterinfo, GenericBindingSetter, &lineDashOffset_setterinfo },
    6616             :   { "shadowOffsetX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shadowOffsetX_getterinfo, GenericBindingSetter, &shadowOffsetX_setterinfo },
    6617             :   { "shadowOffsetY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shadowOffsetY_getterinfo, GenericBindingSetter, &shadowOffsetY_setterinfo },
    6618             :   { "shadowBlur", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shadowBlur_getterinfo, GenericBindingSetter, &shadowBlur_setterinfo },
    6619             :   { "shadowColor", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shadowColor_getterinfo, GenericBindingSetter, &shadowColor_setterinfo },
    6620             :   { "font", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &font_getterinfo, GenericBindingSetter, &font_setterinfo },
    6621             :   { "textAlign", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &textAlign_getterinfo, GenericBindingSetter, &textAlign_setterinfo },
    6622             :   { "textBaseline", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &textBaseline_getterinfo, GenericBindingSetter, &textBaseline_setterinfo },
    6623             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    6624             : };
    6625             : #if defined(__clang__)
    6626             : #pragma clang diagnostic pop
    6627             : #endif
    6628             : 
    6629             : static PrefableDisablers sAttributes_disablers10 = {
    6630             :   true, false, 0, nullptr
    6631             : };
    6632             : 
    6633             : // Can't be const because the pref-enabled boolean needs to be writable
    6634             : static Prefable<const JSPropertySpec> sAttributes[] = {
    6635             :   { nullptr, &sAttributes_specs[0] },
    6636             :   { &sAttributes_disablers10, &sAttributes_specs[10] },
    6637             :   { nullptr, &sAttributes_specs[12] },
    6638             :   { nullptr, nullptr }
    6639             : };
    6640             : 
    6641             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    6642             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    6643             : static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    6644             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    6645             : 
    6646             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    6647             : #if defined(__clang__)
    6648             : #pragma clang diagnostic push
    6649             : #pragma clang diagnostic ignored "-Wmissing-braces"
    6650             : #endif
    6651             : static const ConstantSpec sConstants_specs[] = {
    6652             :   { "DRAWWINDOW_DRAW_CARET", JS::NumberValue(1U) },
    6653             :   { "DRAWWINDOW_DO_NOT_FLUSH", JS::NumberValue(2U) },
    6654             :   { "DRAWWINDOW_DRAW_VIEW", JS::NumberValue(4U) },
    6655             :   { "DRAWWINDOW_USE_WIDGET_LAYERS", JS::NumberValue(8U) },
    6656             :   { "DRAWWINDOW_ASYNC_DECODE_IMAGES", JS::NumberValue(16U) },
    6657             :   { 0, JS::UndefinedValue() }
    6658             : };
    6659             : #if defined(__clang__)
    6660             : #pragma clang diagnostic pop
    6661             : #endif
    6662             : 
    6663             : static PrefableDisablers sConstants_disablers0 = {
    6664             :   true, false, 0, &CanvasUtils::HasDrawWindowPrivilege
    6665             : };
    6666             : 
    6667             : // Can't be const because the pref-enabled boolean needs to be writable
    6668             : static Prefable<const ConstantSpec> sConstants[] = {
    6669             :   { &sConstants_disablers0, &sConstants_specs[0] },
    6670             :   { nullptr, nullptr }
    6671             : };
    6672             : 
    6673             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    6674             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    6675             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    6676             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    6677             : 
    6678             : 
    6679             : static uint16_t sNativeProperties_sortedPropertyIndices[72];
    6680             : static PropertyInfo sNativeProperties_propertyInfos[72];
    6681             : 
    6682             : static const NativePropertiesN<3> sNativeProperties = {
    6683             :   false, 0,
    6684             :   false, 0,
    6685             :   true,  0 /* sMethods */,
    6686             :   true,  1 /* sAttributes */,
    6687             :   false, 0,
    6688             :   false, 0,
    6689             :   true,  2 /* sConstants */,
    6690             :   -1,
    6691             :   72,
    6692             :   sNativeProperties_sortedPropertyIndices,
    6693             :   {
    6694             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    6695             :     { sAttributes, &sNativeProperties_propertyInfos[44] },
    6696             :     { sConstants, &sNativeProperties_propertyInfos[67] }
    6697             :   }
    6698             : };
    6699             : static_assert(72 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    6700             :     "We have a property info count that is oversized");
    6701             : 
    6702             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    6703             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    6704             : 
    6705             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    6706             :   false, 0,
    6707             :   false, 0,
    6708             :   true,  0 /* sChromeMethods */,
    6709             :   false, 0,
    6710             :   false, 0,
    6711             :   false, 0,
    6712             :   false, 0,
    6713             :   -1,
    6714             :   1,
    6715             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    6716             :   {
    6717             :     { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
    6718             :   }
    6719             : };
    6720             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    6721             :     "We have a property info count that is oversized");
    6722             : 
    6723             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    6724             :   {
    6725             :     "Function",
    6726             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    6727             :     &sBoringInterfaceObjectClassClassOps,
    6728             :     JS_NULL_CLASS_SPEC,
    6729             :     JS_NULL_CLASS_EXT,
    6730             :     &sInterfaceObjectClassObjectOps
    6731             :   },
    6732             :   eInterface,
    6733             :   true,
    6734             :   prototypes::id::CanvasRenderingContext2D,
    6735             :   PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth,
    6736             :   sNativePropertyHooks,
    6737             :   "function CanvasRenderingContext2D() {\n    [native code]\n}",
    6738             :   JS::GetRealmFunctionPrototype
    6739             : };
    6740             : 
    6741             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    6742             :   {
    6743             :     "CanvasRenderingContext2DPrototype",
    6744             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    6745             :     JS_NULL_CLASS_OPS,
    6746             :     JS_NULL_CLASS_SPEC,
    6747             :     JS_NULL_CLASS_EXT,
    6748             :     JS_NULL_OBJECT_OPS
    6749             :   },
    6750             :   eInterfacePrototype,
    6751             :   false,
    6752             :   prototypes::id::CanvasRenderingContext2D,
    6753             :   PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth,
    6754             :   sNativePropertyHooks,
    6755             :   "[object CanvasRenderingContext2DPrototype]",
    6756             :   JS::GetRealmObjectPrototype
    6757             : };
    6758             : 
    6759             : JSObject*
    6760           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    6761             : {
    6762           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    6763             : }
    6764             : 
    6765             : static const js::ClassOps sClassOps = {
    6766             :   _addProperty, /* addProperty */
    6767             :   nullptr,               /* delProperty */
    6768             :   nullptr,               /* getProperty */
    6769             :   nullptr,               /* setProperty */
    6770             :   nullptr,               /* enumerate */
    6771             :   nullptr, /* newEnumerate */
    6772             :   nullptr, /* resolve */
    6773             :   nullptr, /* mayResolve */
    6774             :   _finalize, /* finalize */
    6775             :   nullptr, /* call */
    6776             :   nullptr,               /* hasInstance */
    6777             :   nullptr,               /* construct */
    6778             :   nullptr, /* trace */
    6779             : };
    6780             : 
    6781             : static const js::ClassExtension sClassExtension = {
    6782             :   nullptr, /* weakmapKeyDelegateOp */
    6783             :   _objectMoved /* objectMovedOp */
    6784             : };
    6785             : 
    6786             : static const DOMJSClass sClass = {
    6787             :   { "CanvasRenderingContext2D",
    6788             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    6789             :     &sClassOps,
    6790             :     JS_NULL_CLASS_SPEC,
    6791             :     &sClassExtension,
    6792             :     JS_NULL_OBJECT_OPS
    6793             :   },
    6794             :   { prototypes::id::CanvasRenderingContext2D, 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 },
    6795             :   IsBaseOf<nsISupports, mozilla::dom::CanvasRenderingContext2D >::value,
    6796             :   sNativePropertyHooks,
    6797             :   FindAssociatedGlobalForNative<mozilla::dom::CanvasRenderingContext2D>::Get,
    6798             :   GetProtoObjectHandle,
    6799             :   GetCCParticipant<mozilla::dom::CanvasRenderingContext2D>::Get()
    6800             : };
    6801             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    6802             :               "Must have the right minimal number of reserved slots.");
    6803             : static_assert(1 >= 1,
    6804             :               "Must have enough reserved slots.");
    6805             : 
    6806             : const JSClass*
    6807           0 : GetJSClass()
    6808             : {
    6809           0 :   return sClass.ToJSClass();
    6810             : }
    6811             : 
    6812             : bool
    6813           0 : Wrap(JSContext* aCx, mozilla::dom::CanvasRenderingContext2D* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    6814             : {
    6815             :   MOZ_ASSERT(static_cast<mozilla::dom::CanvasRenderingContext2D*>(aObject) ==
    6816             :              reinterpret_cast<mozilla::dom::CanvasRenderingContext2D*>(aObject),
    6817             :              "Multiple inheritance for mozilla::dom::CanvasRenderingContext2D is broken.");
    6818           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    6819           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    6820           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    6821             :              "You should probably not be using Wrap() directly; use "
    6822             :              "GetOrCreateDOMReflector instead");
    6823             : 
    6824           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    6825             :              "nsISupports must be on our primary inheritance chain");
    6826             : 
    6827           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    6828           0 :   if (!global) {
    6829           0 :     return false;
    6830             :   }
    6831           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    6832           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    6833             : 
    6834             :   // That might have ended up wrapping us already, due to the wonders
    6835             :   // of XBL.  Check for that, and bail out as needed.
    6836           0 :   aReflector.set(aCache->GetWrapper());
    6837           0 :   if (aReflector) {
    6838             : #ifdef DEBUG
    6839           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    6840             : #endif // DEBUG
    6841           0 :     return true;
    6842             :   }
    6843             : 
    6844           0 :   JSAutoCompartment ac(aCx, global);
    6845           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    6846           0 :   if (!canonicalProto) {
    6847           0 :     return false;
    6848             :   }
    6849           0 :   JS::Rooted<JSObject*> proto(aCx);
    6850           0 :   if (aGivenProto) {
    6851           0 :     proto = aGivenProto;
    6852             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    6853             :     // coming in, we changed compartments to that of "parent" so may need
    6854             :     // to wrap the proto here.
    6855           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    6856           0 :       if (!JS_WrapObject(aCx, &proto)) {
    6857           0 :         return false;
    6858             :       }
    6859             :     }
    6860             :   } else {
    6861           0 :     proto = canonicalProto;
    6862             :   }
    6863             : 
    6864           0 :   BindingJSObjectCreator<mozilla::dom::CanvasRenderingContext2D> creator(aCx);
    6865           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    6866           0 :   if (!aReflector) {
    6867           0 :     return false;
    6868             :   }
    6869             : 
    6870           0 :   aCache->SetWrapper(aReflector);
    6871           0 :   creator.InitializationSucceeded();
    6872             : 
    6873           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    6874             :              aCache->GetWrapperPreserveColor() == aReflector);
    6875             :   // If proto != canonicalProto, we have to preserve our wrapper;
    6876             :   // otherwise we won't be able to properly recreate it later, since
    6877             :   // we won't know what proto to use.  Note that we don't check
    6878             :   // aGivenProto here, since it's entirely possible (and even
    6879             :   // somewhat common) to have a non-null aGivenProto which is the
    6880             :   // same as canonicalProto.
    6881           0 :   if (proto != canonicalProto) {
    6882           0 :     PreserveWrapper(aObject);
    6883             :   }
    6884             : 
    6885           0 :   return true;
    6886             : }
    6887             : 
    6888             : const NativePropertyHooks sNativePropertyHooks[] = { {
    6889             :   nullptr,
    6890             :   nullptr,
    6891             :   nullptr,
    6892             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    6893             :   prototypes::id::CanvasRenderingContext2D,
    6894             :   constructors::id::CanvasRenderingContext2D,
    6895             :   nullptr,
    6896             :   &DefaultXrayExpandoObjectClass
    6897             : } };
    6898             : 
    6899             : void
    6900           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    6901             : {
    6902           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    6903           0 :   if (!parentProto) {
    6904           0 :     return;
    6905             :   }
    6906             : 
    6907           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    6908           0 :   if (!constructorProto) {
    6909           0 :     return;
    6910             :   }
    6911             : 
    6912             :   static bool sIdsInited = false;
    6913           0 :   if (!sIdsInited && NS_IsMainThread()) {
    6914           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    6915           0 :       return;
    6916             :     }
    6917           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    6918           0 :       return;
    6919             :     }
    6920           0 :     sIdsInited = true;
    6921             :   }
    6922             : 
    6923             :   static bool sPrefCachesInited = false;
    6924           0 :   if (!sPrefCachesInited && NS_IsMainThread()) {
    6925           0 :     sPrefCachesInited = true;
    6926           0 :     Preferences::AddBoolVarCache(&sMethods[2].disablers->enabled, "canvas.hitregions.enabled");
    6927           0 :     Preferences::AddBoolVarCache(&sMethods[4].disablers->enabled, "canvas.focusring.enabled");
    6928           0 :     Preferences::AddBoolVarCache(&sMethods[5].disablers->enabled, "canvas.customfocusring.enabled");
    6929           0 :     Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "canvas.filters.enabled");
    6930             :   }
    6931             : 
    6932           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasRenderingContext2D);
    6933           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasRenderingContext2D);
    6934           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    6935             :                               &sPrototypeClass.mBase, protoCache,
    6936             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    6937             :                               interfaceCache,
    6938             :                               sNativeProperties.Upcast(),
    6939           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    6940             :                               "CanvasRenderingContext2D", aDefineOnGlobal,
    6941             :                               nullptr,
    6942           0 :                               false);
    6943             : }
    6944             : 
    6945             : JS::Handle<JSObject*>
    6946           0 : GetProtoObjectHandle(JSContext* aCx)
    6947             : {
    6948             :   /* Get the interface prototype object for this class.  This will create the
    6949             :      object as needed. */
    6950           0 :   bool aDefineOnGlobal = true;
    6951             : 
    6952             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    6953           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    6954           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    6955           0 :     return nullptr;
    6956             :   }
    6957             : 
    6958             :   /* Check to see whether the interface objects are already installed */
    6959           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    6960           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CanvasRenderingContext2D)) {
    6961           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    6962           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    6963             :   }
    6964             : 
    6965             :   /*
    6966             :    * The object might _still_ be null, but that's OK.
    6967             :    *
    6968             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    6969             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    6970             :    * changed after they have been set.
    6971             :    *
    6972             :    * Calling address() avoids the read read barrier that does gray
    6973             :    * unmarking, but it's not possible for the object to be gray here.
    6974             :    */
    6975             : 
    6976           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CanvasRenderingContext2D);
    6977           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    6978           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    6979             : }
    6980             : 
    6981             : JS::Handle<JSObject*>
    6982           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    6983             : {
    6984             :   /* Get the interface object for this class.  This will create the object as
    6985             :      needed. */
    6986             : 
    6987             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    6988           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    6989           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    6990           0 :     return nullptr;
    6991             :   }
    6992             : 
    6993             :   /* Check to see whether the interface objects are already installed */
    6994           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    6995           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CanvasRenderingContext2D)) {
    6996           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    6997           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    6998             :   }
    6999             : 
    7000             :   /*
    7001             :    * The object might _still_ be null, but that's OK.
    7002             :    *
    7003             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    7004             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    7005             :    * changed after they have been set.
    7006             :    *
    7007             :    * Calling address() avoids the read read barrier that does gray
    7008             :    * unmarking, but it's not possible for the object to be gray here.
    7009             :    */
    7010             : 
    7011           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CanvasRenderingContext2D);
    7012           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    7013           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    7014             : }
    7015             : 
    7016             : JSObject*
    7017           0 : GetConstructorObject(JSContext* aCx)
    7018             : {
    7019           0 :   return GetConstructorObjectHandle(aCx);
    7020             : }
    7021             : 
    7022             : } // namespace CanvasRenderingContext2DBinding
    7023             : 
    7024             : 
    7025             : 
    7026             : namespace Path2DBinding {
    7027             : 
    7028             : static bool
    7029           0 : addPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7030             : {
    7031           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    7032           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.addPath");
    7033             :   }
    7034           0 :   NonNull<mozilla::dom::CanvasPath> arg0;
    7035           0 :   if (args[0].isObject()) {
    7036             :     {
    7037           0 :       nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    7038           0 :       if (NS_FAILED(rv)) {
    7039           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Path2D.addPath", "Path2D");
    7040           0 :         return false;
    7041             :       }
    7042             :     }
    7043             :   } else {
    7044           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Path2D.addPath");
    7045           0 :     return false;
    7046             :   }
    7047           0 :   Optional<NonNull<mozilla::dom::SVGMatrix>> arg1;
    7048           0 :   if (args.hasDefined(1)) {
    7049           0 :     arg1.Construct();
    7050           0 :     if (args[1].isObject()) {
    7051             :       {
    7052           0 :         nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[1], arg1.Value());
    7053           0 :         if (NS_FAILED(rv)) {
    7054           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Path2D.addPath", "SVGMatrix");
    7055           0 :           return false;
    7056             :         }
    7057             :       }
    7058             :     } else {
    7059           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Path2D.addPath");
    7060           0 :       return false;
    7061             :     }
    7062             :   }
    7063           0 :   self->AddPath(NonNullHelper(arg0), NonNullHelper(Constify(arg1)));
    7064           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7065           0 :   args.rval().setUndefined();
    7066           0 :   return true;
    7067             : }
    7068             : 
    7069             : static const JSJitInfo addPath_methodinfo = {
    7070             :   { (JSJitGetterOp)addPath },
    7071             :   { prototypes::id::Path2D },
    7072             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7073             :   JSJitInfo::Method,
    7074             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7075             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7076             :   false,  /* isInfallible. False in setters. */
    7077             :   false,  /* isMovable.  Not relevant for setters. */
    7078             :   false, /* isEliminatable.  Not relevant for setters. */
    7079             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7080             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7081             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7082             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7083             : };
    7084             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7085             : static_assert(0 < 1, "There is no slot for us");
    7086             : 
    7087             : static bool
    7088           0 : closePath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7089             : {
    7090           0 :   self->ClosePath();
    7091           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7092           0 :   args.rval().setUndefined();
    7093           0 :   return true;
    7094             : }
    7095             : 
    7096             : static const JSJitInfo closePath_methodinfo = {
    7097             :   { (JSJitGetterOp)closePath },
    7098             :   { prototypes::id::Path2D },
    7099             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7100             :   JSJitInfo::Method,
    7101             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7102             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7103             :   true,  /* isInfallible. False in setters. */
    7104             :   false,  /* isMovable.  Not relevant for setters. */
    7105             :   false, /* isEliminatable.  Not relevant for setters. */
    7106             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7107             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7108             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7109             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7110             : };
    7111             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7112             : static_assert(0 < 1, "There is no slot for us");
    7113             : 
    7114             : static bool
    7115           0 : moveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7116             : {
    7117           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    7118           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.moveTo");
    7119             :   }
    7120           0 :   bool foundNonFiniteFloat = false;
    7121             :   double arg0;
    7122           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7123           0 :     return false;
    7124           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7125           0 :     foundNonFiniteFloat = true;
    7126             :   }
    7127             :   double arg1;
    7128           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7129           0 :     return false;
    7130           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7131           0 :     foundNonFiniteFloat = true;
    7132             :   }
    7133           0 :   if (foundNonFiniteFloat) {
    7134           0 :     args.rval().setUndefined();
    7135           0 :     return true;
    7136             :   }
    7137           0 :   self->MoveTo(arg0, arg1);
    7138           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7139           0 :   args.rval().setUndefined();
    7140           0 :   return true;
    7141             : }
    7142             : 
    7143             : static const JSJitInfo moveTo_methodinfo = {
    7144             :   { (JSJitGetterOp)moveTo },
    7145             :   { prototypes::id::Path2D },
    7146             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7147             :   JSJitInfo::Method,
    7148             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7149             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7150             :   false,  /* isInfallible. False in setters. */
    7151             :   false,  /* isMovable.  Not relevant for setters. */
    7152             :   false, /* isEliminatable.  Not relevant for setters. */
    7153             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7154             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7155             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7156             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7157             : };
    7158             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7159             : static_assert(0 < 1, "There is no slot for us");
    7160             : 
    7161             : static bool
    7162           0 : lineTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7163             : {
    7164           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
    7165           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.lineTo");
    7166             :   }
    7167           0 :   bool foundNonFiniteFloat = false;
    7168             :   double arg0;
    7169           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7170           0 :     return false;
    7171           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7172           0 :     foundNonFiniteFloat = true;
    7173             :   }
    7174             :   double arg1;
    7175           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7176           0 :     return false;
    7177           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7178           0 :     foundNonFiniteFloat = true;
    7179             :   }
    7180           0 :   if (foundNonFiniteFloat) {
    7181           0 :     args.rval().setUndefined();
    7182           0 :     return true;
    7183             :   }
    7184           0 :   self->LineTo(arg0, arg1);
    7185           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7186           0 :   args.rval().setUndefined();
    7187           0 :   return true;
    7188             : }
    7189             : 
    7190             : static const JSJitInfo lineTo_methodinfo = {
    7191             :   { (JSJitGetterOp)lineTo },
    7192             :   { prototypes::id::Path2D },
    7193             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7194             :   JSJitInfo::Method,
    7195             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7196             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7197             :   false,  /* isInfallible. False in setters. */
    7198             :   false,  /* isMovable.  Not relevant for setters. */
    7199             :   false, /* isEliminatable.  Not relevant for setters. */
    7200             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7201             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7202             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7203             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7204             : };
    7205             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7206             : static_assert(0 < 1, "There is no slot for us");
    7207             : 
    7208             : static bool
    7209           0 : quadraticCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7210             : {
    7211           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    7212           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.quadraticCurveTo");
    7213             :   }
    7214           0 :   bool foundNonFiniteFloat = false;
    7215             :   double arg0;
    7216           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7217           0 :     return false;
    7218           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7219           0 :     foundNonFiniteFloat = true;
    7220             :   }
    7221             :   double arg1;
    7222           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7223           0 :     return false;
    7224           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7225           0 :     foundNonFiniteFloat = true;
    7226             :   }
    7227             :   double arg2;
    7228           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7229           0 :     return false;
    7230           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7231           0 :     foundNonFiniteFloat = true;
    7232             :   }
    7233             :   double arg3;
    7234           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7235           0 :     return false;
    7236           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7237           0 :     foundNonFiniteFloat = true;
    7238             :   }
    7239           0 :   if (foundNonFiniteFloat) {
    7240           0 :     args.rval().setUndefined();
    7241           0 :     return true;
    7242             :   }
    7243           0 :   self->QuadraticCurveTo(arg0, arg1, arg2, arg3);
    7244           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7245           0 :   args.rval().setUndefined();
    7246           0 :   return true;
    7247             : }
    7248             : 
    7249             : static const JSJitInfo quadraticCurveTo_methodinfo = {
    7250             :   { (JSJitGetterOp)quadraticCurveTo },
    7251             :   { prototypes::id::Path2D },
    7252             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7253             :   JSJitInfo::Method,
    7254             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7255             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7256             :   false,  /* isInfallible. False in setters. */
    7257             :   false,  /* isMovable.  Not relevant for setters. */
    7258             :   false, /* isEliminatable.  Not relevant for setters. */
    7259             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7260             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7261             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7262             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7263             : };
    7264             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7265             : static_assert(0 < 1, "There is no slot for us");
    7266             : 
    7267             : static bool
    7268           0 : bezierCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7269             : {
    7270           0 :   if (MOZ_UNLIKELY(args.length() < 6)) {
    7271           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.bezierCurveTo");
    7272             :   }
    7273           0 :   bool foundNonFiniteFloat = false;
    7274             :   double arg0;
    7275           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7276           0 :     return false;
    7277           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7278           0 :     foundNonFiniteFloat = true;
    7279             :   }
    7280             :   double arg1;
    7281           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7282           0 :     return false;
    7283           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7284           0 :     foundNonFiniteFloat = true;
    7285             :   }
    7286             :   double arg2;
    7287           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7288           0 :     return false;
    7289           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7290           0 :     foundNonFiniteFloat = true;
    7291             :   }
    7292             :   double arg3;
    7293           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7294           0 :     return false;
    7295           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7296           0 :     foundNonFiniteFloat = true;
    7297             :   }
    7298             :   double arg4;
    7299           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    7300           0 :     return false;
    7301           0 :   } else if (!mozilla::IsFinite(arg4)) {
    7302           0 :     foundNonFiniteFloat = true;
    7303             :   }
    7304             :   double arg5;
    7305           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    7306           0 :     return false;
    7307           0 :   } else if (!mozilla::IsFinite(arg5)) {
    7308           0 :     foundNonFiniteFloat = true;
    7309             :   }
    7310           0 :   if (foundNonFiniteFloat) {
    7311           0 :     args.rval().setUndefined();
    7312           0 :     return true;
    7313             :   }
    7314           0 :   self->BezierCurveTo(arg0, arg1, arg2, arg3, arg4, arg5);
    7315           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7316           0 :   args.rval().setUndefined();
    7317           0 :   return true;
    7318             : }
    7319             : 
    7320             : static const JSJitInfo bezierCurveTo_methodinfo = {
    7321             :   { (JSJitGetterOp)bezierCurveTo },
    7322             :   { prototypes::id::Path2D },
    7323             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7324             :   JSJitInfo::Method,
    7325             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7326             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7327             :   false,  /* isInfallible. False in setters. */
    7328             :   false,  /* isMovable.  Not relevant for setters. */
    7329             :   false, /* isEliminatable.  Not relevant for setters. */
    7330             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7331             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7332             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7333             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7334             : };
    7335             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7336             : static_assert(0 < 1, "There is no slot for us");
    7337             : 
    7338             : static bool
    7339           0 : arcTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7340             : {
    7341           0 :   if (MOZ_UNLIKELY(args.length() < 5)) {
    7342           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.arcTo");
    7343             :   }
    7344           0 :   bool foundNonFiniteFloat = false;
    7345             :   double arg0;
    7346           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7347           0 :     return false;
    7348           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7349           0 :     foundNonFiniteFloat = true;
    7350             :   }
    7351             :   double arg1;
    7352           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7353           0 :     return false;
    7354           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7355           0 :     foundNonFiniteFloat = true;
    7356             :   }
    7357             :   double arg2;
    7358           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7359           0 :     return false;
    7360           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7361           0 :     foundNonFiniteFloat = true;
    7362             :   }
    7363             :   double arg3;
    7364           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7365           0 :     return false;
    7366           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7367           0 :     foundNonFiniteFloat = true;
    7368             :   }
    7369             :   double arg4;
    7370           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    7371           0 :     return false;
    7372           0 :   } else if (!mozilla::IsFinite(arg4)) {
    7373           0 :     foundNonFiniteFloat = true;
    7374             :   }
    7375           0 :   if (foundNonFiniteFloat) {
    7376           0 :     args.rval().setUndefined();
    7377           0 :     return true;
    7378             :   }
    7379           0 :   binding_detail::FastErrorResult rv;
    7380           0 :   self->ArcTo(arg0, arg1, arg2, arg3, arg4, rv);
    7381           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7382           0 :     return false;
    7383             :   }
    7384           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7385           0 :   args.rval().setUndefined();
    7386           0 :   return true;
    7387             : }
    7388             : 
    7389             : static const JSJitInfo arcTo_methodinfo = {
    7390             :   { (JSJitGetterOp)arcTo },
    7391             :   { prototypes::id::Path2D },
    7392             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7393             :   JSJitInfo::Method,
    7394             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7395             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7396             :   false,  /* isInfallible. False in setters. */
    7397             :   false,  /* isMovable.  Not relevant for setters. */
    7398             :   false, /* isEliminatable.  Not relevant for setters. */
    7399             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7400             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7401             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7402             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7403             : };
    7404             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7405             : static_assert(0 < 1, "There is no slot for us");
    7406             : 
    7407             : static bool
    7408           0 : rect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7409             : {
    7410           0 :   if (MOZ_UNLIKELY(args.length() < 4)) {
    7411           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.rect");
    7412             :   }
    7413           0 :   bool foundNonFiniteFloat = false;
    7414             :   double arg0;
    7415           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7416           0 :     return false;
    7417           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7418           0 :     foundNonFiniteFloat = true;
    7419             :   }
    7420             :   double arg1;
    7421           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7422           0 :     return false;
    7423           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7424           0 :     foundNonFiniteFloat = true;
    7425             :   }
    7426             :   double arg2;
    7427           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7428           0 :     return false;
    7429           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7430           0 :     foundNonFiniteFloat = true;
    7431             :   }
    7432             :   double arg3;
    7433           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7434           0 :     return false;
    7435           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7436           0 :     foundNonFiniteFloat = true;
    7437             :   }
    7438           0 :   if (foundNonFiniteFloat) {
    7439           0 :     args.rval().setUndefined();
    7440           0 :     return true;
    7441             :   }
    7442           0 :   self->Rect(arg0, arg1, arg2, arg3);
    7443           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7444           0 :   args.rval().setUndefined();
    7445           0 :   return true;
    7446             : }
    7447             : 
    7448             : static const JSJitInfo rect_methodinfo = {
    7449             :   { (JSJitGetterOp)rect },
    7450             :   { prototypes::id::Path2D },
    7451             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7452             :   JSJitInfo::Method,
    7453             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7454             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7455             :   false,  /* isInfallible. False in setters. */
    7456             :   false,  /* isMovable.  Not relevant for setters. */
    7457             :   false, /* isEliminatable.  Not relevant for setters. */
    7458             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7459             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7460             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7461             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7462             : };
    7463             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7464             : static_assert(0 < 1, "There is no slot for us");
    7465             : 
    7466             : static bool
    7467           0 : arc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7468             : {
    7469           0 :   if (MOZ_UNLIKELY(args.length() < 5)) {
    7470           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.arc");
    7471             :   }
    7472           0 :   bool foundNonFiniteFloat = false;
    7473             :   double arg0;
    7474           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7475           0 :     return false;
    7476           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7477           0 :     foundNonFiniteFloat = true;
    7478             :   }
    7479             :   double arg1;
    7480           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7481           0 :     return false;
    7482           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7483           0 :     foundNonFiniteFloat = true;
    7484             :   }
    7485             :   double arg2;
    7486           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7487           0 :     return false;
    7488           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7489           0 :     foundNonFiniteFloat = true;
    7490             :   }
    7491             :   double arg3;
    7492           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7493           0 :     return false;
    7494           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7495           0 :     foundNonFiniteFloat = true;
    7496             :   }
    7497             :   double arg4;
    7498           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    7499           0 :     return false;
    7500           0 :   } else if (!mozilla::IsFinite(arg4)) {
    7501           0 :     foundNonFiniteFloat = true;
    7502             :   }
    7503             :   bool arg5;
    7504           0 :   if (args.hasDefined(5)) {
    7505           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
    7506           0 :       return false;
    7507             :     }
    7508             :   } else {
    7509           0 :     arg5 = false;
    7510             :   }
    7511           0 :   if (foundNonFiniteFloat) {
    7512           0 :     args.rval().setUndefined();
    7513           0 :     return true;
    7514             :   }
    7515           0 :   binding_detail::FastErrorResult rv;
    7516           0 :   self->Arc(arg0, arg1, arg2, arg3, arg4, arg5, rv);
    7517           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7518           0 :     return false;
    7519             :   }
    7520           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7521           0 :   args.rval().setUndefined();
    7522           0 :   return true;
    7523             : }
    7524             : 
    7525             : static const JSJitInfo arc_methodinfo = {
    7526             :   { (JSJitGetterOp)arc },
    7527             :   { prototypes::id::Path2D },
    7528             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7529             :   JSJitInfo::Method,
    7530             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7531             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7532             :   false,  /* isInfallible. False in setters. */
    7533             :   false,  /* isMovable.  Not relevant for setters. */
    7534             :   false, /* isEliminatable.  Not relevant for setters. */
    7535             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7536             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7537             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7538             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7539             : };
    7540             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7541             : static_assert(0 < 1, "There is no slot for us");
    7542             : 
    7543             : static bool
    7544           0 : ellipse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
    7545             : {
    7546           0 :   if (MOZ_UNLIKELY(args.length() < 7)) {
    7547           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.ellipse");
    7548             :   }
    7549           0 :   bool foundNonFiniteFloat = false;
    7550             :   double arg0;
    7551           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
    7552           0 :     return false;
    7553           0 :   } else if (!mozilla::IsFinite(arg0)) {
    7554           0 :     foundNonFiniteFloat = true;
    7555             :   }
    7556             :   double arg1;
    7557           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
    7558           0 :     return false;
    7559           0 :   } else if (!mozilla::IsFinite(arg1)) {
    7560           0 :     foundNonFiniteFloat = true;
    7561             :   }
    7562             :   double arg2;
    7563           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
    7564           0 :     return false;
    7565           0 :   } else if (!mozilla::IsFinite(arg2)) {
    7566           0 :     foundNonFiniteFloat = true;
    7567             :   }
    7568             :   double arg3;
    7569           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
    7570           0 :     return false;
    7571           0 :   } else if (!mozilla::IsFinite(arg3)) {
    7572           0 :     foundNonFiniteFloat = true;
    7573             :   }
    7574             :   double arg4;
    7575           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
    7576           0 :     return false;
    7577           0 :   } else if (!mozilla::IsFinite(arg4)) {
    7578           0 :     foundNonFiniteFloat = true;
    7579             :   }
    7580             :   double arg5;
    7581           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
    7582           0 :     return false;
    7583           0 :   } else if (!mozilla::IsFinite(arg5)) {
    7584           0 :     foundNonFiniteFloat = true;
    7585             :   }
    7586             :   double arg6;
    7587           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
    7588           0 :     return false;
    7589           0 :   } else if (!mozilla::IsFinite(arg6)) {
    7590           0 :     foundNonFiniteFloat = true;
    7591             :   }
    7592             :   bool arg7;
    7593           0 :   if (args.hasDefined(7)) {
    7594           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
    7595           0 :       return false;
    7596             :     }
    7597             :   } else {
    7598           0 :     arg7 = false;
    7599             :   }
    7600           0 :   if (foundNonFiniteFloat) {
    7601           0 :     args.rval().setUndefined();
    7602           0 :     return true;
    7603             :   }
    7604           0 :   binding_detail::FastErrorResult rv;
    7605           0 :   self->Ellipse(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, rv);
    7606           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7607           0 :     return false;
    7608             :   }
    7609           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7610           0 :   args.rval().setUndefined();
    7611           0 :   return true;
    7612             : }
    7613             : 
    7614             : static const JSJitInfo ellipse_methodinfo = {
    7615             :   { (JSJitGetterOp)ellipse },
    7616             :   { prototypes::id::Path2D },
    7617             :   { PrototypeTraits<prototypes::id::Path2D>::Depth },
    7618             :   JSJitInfo::Method,
    7619             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    7620             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    7621             :   false,  /* isInfallible. False in setters. */
    7622             :   false,  /* isMovable.  Not relevant for setters. */
    7623             :   false, /* isEliminatable.  Not relevant for setters. */
    7624             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    7625             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    7626             :   false,  /* isTypedMethod.  Only relevant for methods. */
    7627             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    7628             : };
    7629             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    7630             : static_assert(0 < 1, "There is no slot for us");
    7631             : 
    7632             : static bool
    7633           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    7634             : {
    7635           0 :   mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
    7636             :   // We don't want to preserve if we don't have a wrapper, and we
    7637             :   // obviously can't preserve if we're not initialized.
    7638           0 :   if (self && self->GetWrapperPreserveColor()) {
    7639           0 :     PreserveWrapper(self);
    7640             :   }
    7641           0 :   return true;
    7642             : }
    7643             : 
    7644             : static void
    7645           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    7646             : {
    7647           0 :   mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
    7648           0 :   if (self) {
    7649           0 :     ClearWrapper(self, self, obj);
    7650           0 :     AddForDeferredFinalization<mozilla::dom::CanvasPath>(self);
    7651             :   }
    7652           0 : }
    7653             : 
    7654             : static void
    7655           0 : _objectMoved(JSObject* obj, const JSObject* old)
    7656             : {
    7657           0 :   mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
    7658           0 :   if (self) {
    7659           0 :     UpdateWrapper(self, self, obj, old);
    7660             :   }
    7661           0 : }
    7662             : 
    7663             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    7664             : #if defined(__clang__)
    7665             : #pragma clang diagnostic push
    7666             : #pragma clang diagnostic ignored "-Wmissing-braces"
    7667             : #endif
    7668             : static const JSFunctionSpec sMethods_specs[] = {
    7669             :   JS_FNSPEC("addPath", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addPath_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    7670             :   JS_FNSPEC("closePath", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&closePath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    7671             :   JS_FNSPEC("moveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&moveTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    7672             :   JS_FNSPEC("lineTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&lineTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    7673             :   JS_FNSPEC("quadraticCurveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&quadraticCurveTo_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    7674             :   JS_FNSPEC("bezierCurveTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&bezierCurveTo_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
    7675             :   JS_FNSPEC("arcTo", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&arcTo_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
    7676             :   JS_FNSPEC("rect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&rect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
    7677             :   JS_FNSPEC("arc", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&arc_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
    7678             :   JS_FNSPEC("ellipse", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&ellipse_methodinfo), 7, JSPROP_ENUMERATE, nullptr),
    7679             :   JS_FS_END
    7680             : };
    7681             : #if defined(__clang__)
    7682             : #pragma clang diagnostic pop
    7683             : #endif
    7684             : 
    7685             : 
    7686             : // Can't be const because the pref-enabled boolean needs to be writable
    7687             : static Prefable<const JSFunctionSpec> sMethods[] = {
    7688             :   { nullptr, &sMethods_specs[0] },
    7689             :   { nullptr, nullptr }
    7690             : };
    7691             : 
    7692             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    7693             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    7694             : static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    7695             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    7696             : 
    7697             : 
    7698             : static uint16_t sNativeProperties_sortedPropertyIndices[10];
    7699             : static PropertyInfo sNativeProperties_propertyInfos[10];
    7700             : 
    7701             : static const NativePropertiesN<1> sNativeProperties = {
    7702             :   false, 0,
    7703             :   false, 0,
    7704             :   true,  0 /* sMethods */,
    7705             :   false, 0,
    7706             :   false, 0,
    7707             :   false, 0,
    7708             :   false, 0,
    7709             :   -1,
    7710             :   10,
    7711             :   sNativeProperties_sortedPropertyIndices,
    7712             :   {
    7713             :     { sMethods, &sNativeProperties_propertyInfos[0] }
    7714             :   }
    7715             : };
    7716             : static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    7717             :     "We have a property info count that is oversized");
    7718             : 
    7719             : static bool
    7720           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    7721             : {
    7722           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    7723           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    7724           0 :   if (!args.isConstructing()) {
    7725             :     // XXXbz wish I could get the name from the callee instead of
    7726             :     // Adding more relocations
    7727           0 :     return ThrowConstructorWithoutNew(cx, "Path2D");
    7728             :   }
    7729             : 
    7730           0 :   GlobalObject global(cx, obj);
    7731           0 :   if (global.Failed()) {
    7732           0 :     return false;
    7733             :   }
    7734             : 
    7735           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    7736           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    7737           0 :     return false;
    7738             :   }
    7739             : 
    7740           0 :   unsigned argcount = std::min(args.length(), 1u);
    7741           0 :   switch (argcount) {
    7742             :     case 0: {
    7743           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    7744           0 :       Maybe<JSAutoCompartment> ac;
    7745           0 :       if (objIsXray) {
    7746           0 :         obj = js::CheckedUnwrap(obj);
    7747           0 :         if (!obj) {
    7748           0 :           return false;
    7749             :         }
    7750           0 :         ac.emplace(cx, obj);
    7751           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    7752           0 :           return false;
    7753             :         }
    7754             :       }
    7755           0 :       binding_detail::FastErrorResult rv;
    7756           0 :       auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, rv)));
    7757           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7758           0 :         return false;
    7759             :       }
    7760           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7761             :       static_assert(!IsPointer<decltype(result)>::value,
    7762             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    7763           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    7764           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    7765           0 :         return false;
    7766             :       }
    7767           0 :       return true;
    7768             :       break;
    7769             :     }
    7770             :     case 1: {
    7771           0 :       if (args[0].isObject()) {
    7772             :         do {
    7773           0 :           NonNull<mozilla::dom::CanvasPath> arg0;
    7774             :           {
    7775           0 :             nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
    7776           0 :             if (NS_FAILED(rv)) {
    7777           0 :               break;
    7778             :             }
    7779             :           }
    7780           0 :           bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    7781           0 :           Maybe<JSAutoCompartment> ac;
    7782           0 :           if (objIsXray) {
    7783           0 :             obj = js::CheckedUnwrap(obj);
    7784           0 :             if (!obj) {
    7785           0 :               return false;
    7786             :             }
    7787           0 :             ac.emplace(cx, obj);
    7788           0 :             if (!JS_WrapObject(cx, &desiredProto)) {
    7789           0 :               return false;
    7790             :             }
    7791             :           }
    7792           0 :           binding_detail::FastErrorResult rv;
    7793           0 :           auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, NonNullHelper(arg0), rv)));
    7794           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7795           0 :             return false;
    7796             :           }
    7797           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7798             :           static_assert(!IsPointer<decltype(result)>::value,
    7799             :                         "NewObject implies that we need to keep the object alive with a strong reference.");
    7800           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    7801           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    7802           0 :             return false;
    7803             :           }
    7804           0 :           return true;
    7805             :         } while (0);
    7806             :       }
    7807           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    7808           0 :       binding_detail::FakeString arg0;
    7809           0 :       if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    7810           0 :         return false;
    7811             :       }
    7812           0 :       Maybe<JSAutoCompartment> ac;
    7813           0 :       if (objIsXray) {
    7814           0 :         obj = js::CheckedUnwrap(obj);
    7815           0 :         if (!obj) {
    7816           0 :           return false;
    7817             :         }
    7818           0 :         ac.emplace(cx, obj);
    7819           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    7820           0 :           return false;
    7821             :         }
    7822             :       }
    7823           0 :       binding_detail::FastErrorResult rv;
    7824           0 :       auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
    7825           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    7826           0 :         return false;
    7827             :       }
    7828           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    7829             :       static_assert(!IsPointer<decltype(result)>::value,
    7830             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    7831           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    7832           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    7833           0 :         return false;
    7834             :       }
    7835           0 :       return true;
    7836             :       break;
    7837             :     }
    7838             :     default: {
    7839           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D");
    7840             :       break;
    7841             :     }
    7842             :   }
    7843             :   MOZ_CRASH("We have an always-returning default case");
    7844             :   return false;
    7845             : }
    7846             : 
    7847             : static const js::ClassOps sInterfaceObjectClassOps = {
    7848             :     nullptr,               /* addProperty */
    7849             :     nullptr,               /* delProperty */
    7850             :     nullptr,               /* getProperty */
    7851             :     nullptr,               /* setProperty */
    7852             :     nullptr,               /* enumerate */
    7853             :     nullptr,               /* newEnumerate */
    7854             :     nullptr,               /* resolve */
    7855             :     nullptr,               /* mayResolve */
    7856             :     nullptr,               /* finalize */
    7857             :     _constructor, /* call */
    7858             :     nullptr,               /* hasInstance */
    7859             :     _constructor, /* construct */
    7860             :     nullptr,               /* trace */
    7861             : };
    7862             : 
    7863             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    7864             :   {
    7865             :     "Function",
    7866             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    7867             :     &sInterfaceObjectClassOps,
    7868             :     JS_NULL_CLASS_SPEC,
    7869             :     JS_NULL_CLASS_EXT,
    7870             :     &sInterfaceObjectClassObjectOps
    7871             :   },
    7872             :   eInterface,
    7873             :   true,
    7874             :   prototypes::id::Path2D,
    7875             :   PrototypeTraits<prototypes::id::Path2D>::Depth,
    7876             :   sNativePropertyHooks,
    7877             :   "function Path2D() {\n    [native code]\n}",
    7878             :   JS::GetRealmFunctionPrototype
    7879             : };
    7880             : 
    7881             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    7882             :   {
    7883             :     "Path2DPrototype",
    7884             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    7885             :     JS_NULL_CLASS_OPS,
    7886             :     JS_NULL_CLASS_SPEC,
    7887             :     JS_NULL_CLASS_EXT,
    7888             :     JS_NULL_OBJECT_OPS
    7889             :   },
    7890             :   eInterfacePrototype,
    7891             :   false,
    7892             :   prototypes::id::Path2D,
    7893             :   PrototypeTraits<prototypes::id::Path2D>::Depth,
    7894             :   sNativePropertyHooks,
    7895             :   "[object Path2DPrototype]",
    7896             :   JS::GetRealmObjectPrototype
    7897             : };
    7898             : 
    7899             : bool
    7900           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    7901             : {
    7902             :   static bool sPrefValue;
    7903             :   static bool sPrefCacheSetUp = false;
    7904           0 :   if (!sPrefCacheSetUp) {
    7905           0 :     sPrefCacheSetUp = true;
    7906           0 :     Preferences::AddBoolVarCache(&sPrefValue, "canvas.path.enabled");
    7907             :   }
    7908             : 
    7909           0 :   return sPrefValue;
    7910             : }
    7911             : 
    7912             : JSObject*
    7913           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    7914             : {
    7915           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    7916             : }
    7917             : 
    7918             : static const js::ClassOps sClassOps = {
    7919             :   _addProperty, /* addProperty */
    7920             :   nullptr,               /* delProperty */
    7921             :   nullptr,               /* getProperty */
    7922             :   nullptr,               /* setProperty */
    7923             :   nullptr,               /* enumerate */
    7924             :   nullptr, /* newEnumerate */
    7925             :   nullptr, /* resolve */
    7926             :   nullptr, /* mayResolve */
    7927             :   _finalize, /* finalize */
    7928             :   nullptr, /* call */
    7929             :   nullptr,               /* hasInstance */
    7930             :   nullptr,               /* construct */
    7931             :   nullptr, /* trace */
    7932             : };
    7933             : 
    7934             : static const js::ClassExtension sClassExtension = {
    7935             :   nullptr, /* weakmapKeyDelegateOp */
    7936             :   _objectMoved /* objectMovedOp */
    7937             : };
    7938             : 
    7939             : static const DOMJSClass sClass = {
    7940             :   { "Path2D",
    7941             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    7942             :     &sClassOps,
    7943             :     JS_NULL_CLASS_SPEC,
    7944             :     &sClassExtension,
    7945             :     JS_NULL_OBJECT_OPS
    7946             :   },
    7947             :   { prototypes::id::Path2D, 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 },
    7948             :   IsBaseOf<nsISupports, mozilla::dom::CanvasPath >::value,
    7949             :   sNativePropertyHooks,
    7950             :   FindAssociatedGlobalForNative<mozilla::dom::CanvasPath>::Get,
    7951             :   GetProtoObjectHandle,
    7952             :   GetCCParticipant<mozilla::dom::CanvasPath>::Get()
    7953             : };
    7954             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    7955             :               "Must have the right minimal number of reserved slots.");
    7956             : static_assert(1 >= 1,
    7957             :               "Must have enough reserved slots.");
    7958             : 
    7959             : const JSClass*
    7960           0 : GetJSClass()
    7961             : {
    7962           0 :   return sClass.ToJSClass();
    7963             : }
    7964             : 
    7965             : bool
    7966           0 : Wrap(JSContext* aCx, mozilla::dom::CanvasPath* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    7967             : {
    7968             :   MOZ_ASSERT(static_cast<mozilla::dom::CanvasPath*>(aObject) ==
    7969             :              reinterpret_cast<mozilla::dom::CanvasPath*>(aObject),
    7970             :              "Multiple inheritance for mozilla::dom::CanvasPath is broken.");
    7971           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    7972           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    7973           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    7974             :              "You should probably not be using Wrap() directly; use "
    7975             :              "GetOrCreateDOMReflector instead");
    7976             : 
    7977           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    7978             :              "nsISupports must be on our primary inheritance chain");
    7979             : 
    7980           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    7981           0 :   if (!global) {
    7982           0 :     return false;
    7983             :   }
    7984           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    7985           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    7986             : 
    7987             :   // That might have ended up wrapping us already, due to the wonders
    7988             :   // of XBL.  Check for that, and bail out as needed.
    7989           0 :   aReflector.set(aCache->GetWrapper());
    7990           0 :   if (aReflector) {
    7991             : #ifdef DEBUG
    7992           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    7993             : #endif // DEBUG
    7994           0 :     return true;
    7995             :   }
    7996             : 
    7997           0 :   JSAutoCompartment ac(aCx, global);
    7998           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    7999           0 :   if (!canonicalProto) {
    8000           0 :     return false;
    8001             :   }
    8002           0 :   JS::Rooted<JSObject*> proto(aCx);
    8003           0 :   if (aGivenProto) {
    8004           0 :     proto = aGivenProto;
    8005             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    8006             :     // coming in, we changed compartments to that of "parent" so may need
    8007             :     // to wrap the proto here.
    8008           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    8009           0 :       if (!JS_WrapObject(aCx, &proto)) {
    8010           0 :         return false;
    8011             :       }
    8012             :     }
    8013             :   } else {
    8014           0 :     proto = canonicalProto;
    8015             :   }
    8016             : 
    8017           0 :   BindingJSObjectCreator<mozilla::dom::CanvasPath> creator(aCx);
    8018           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    8019           0 :   if (!aReflector) {
    8020           0 :     return false;
    8021             :   }
    8022             : 
    8023           0 :   aCache->SetWrapper(aReflector);
    8024           0 :   creator.InitializationSucceeded();
    8025             : 
    8026           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    8027             :              aCache->GetWrapperPreserveColor() == aReflector);
    8028             :   // If proto != canonicalProto, we have to preserve our wrapper;
    8029             :   // otherwise we won't be able to properly recreate it later, since
    8030             :   // we won't know what proto to use.  Note that we don't check
    8031             :   // aGivenProto here, since it's entirely possible (and even
    8032             :   // somewhat common) to have a non-null aGivenProto which is the
    8033             :   // same as canonicalProto.
    8034           0 :   if (proto != canonicalProto) {
    8035           0 :     PreserveWrapper(aObject);
    8036             :   }
    8037             : 
    8038           0 :   return true;
    8039             : }
    8040             : 
    8041             : const NativePropertyHooks sNativePropertyHooks[] = { {
    8042             :   nullptr,
    8043             :   nullptr,
    8044             :   nullptr,
    8045             :   { sNativeProperties.Upcast(), nullptr },
    8046             :   prototypes::id::Path2D,
    8047             :   constructors::id::Path2D,
    8048             :   nullptr,
    8049             :   &DefaultXrayExpandoObjectClass
    8050             : } };
    8051             : 
    8052             : void
    8053           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    8054             : {
    8055           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    8056           0 :   if (!parentProto) {
    8057           0 :     return;
    8058             :   }
    8059             : 
    8060           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    8061           0 :   if (!constructorProto) {
    8062           0 :     return;
    8063             :   }
    8064             : 
    8065             :   static bool sIdsInited = false;
    8066           0 :   if (!sIdsInited && NS_IsMainThread()) {
    8067           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    8068           0 :       return;
    8069             :     }
    8070           0 :     sIdsInited = true;
    8071             :   }
    8072             : 
    8073           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Path2D);
    8074           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Path2D);
    8075           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    8076             :                               &sPrototypeClass.mBase, protoCache,
    8077             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    8078             :                               interfaceCache,
    8079             :                               sNativeProperties.Upcast(),
    8080             :                               nullptr,
    8081             :                               "Path2D", aDefineOnGlobal,
    8082             :                               nullptr,
    8083           0 :                               false);
    8084             : }
    8085             : 
    8086             : JS::Handle<JSObject*>
    8087           0 : GetProtoObjectHandle(JSContext* aCx)
    8088             : {
    8089             :   /* Get the interface prototype object for this class.  This will create the
    8090             :      object as needed. */
    8091           0 :   bool aDefineOnGlobal = true;
    8092             : 
    8093             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    8094           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    8095           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    8096           0 :     return nullptr;
    8097             :   }
    8098             : 
    8099             :   /* Check to see whether the interface objects are already installed */
    8100           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    8101           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Path2D)) {
    8102           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    8103           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    8104             :   }
    8105             : 
    8106             :   /*
    8107             :    * The object might _still_ be null, but that's OK.
    8108             :    *
    8109             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    8110             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    8111             :    * changed after they have been set.
    8112             :    *
    8113             :    * Calling address() avoids the read read barrier that does gray
    8114             :    * unmarking, but it's not possible for the object to be gray here.
    8115             :    */
    8116             : 
    8117           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Path2D);
    8118           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    8119           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    8120             : }
    8121             : 
    8122             : JS::Handle<JSObject*>
    8123           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    8124             : {
    8125             :   /* Get the interface object for this class.  This will create the object as
    8126             :      needed. */
    8127             : 
    8128             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    8129           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    8130           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    8131           0 :     return nullptr;
    8132             :   }
    8133             : 
    8134             :   /* Check to see whether the interface objects are already installed */
    8135           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    8136           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Path2D)) {
    8137           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    8138           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    8139             :   }
    8140             : 
    8141             :   /*
    8142             :    * The object might _still_ be null, but that's OK.
    8143             :    *
    8144             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    8145             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    8146             :    * changed after they have been set.
    8147             :    *
    8148             :    * Calling address() avoids the read read barrier that does gray
    8149             :    * unmarking, but it's not possible for the object to be gray here.
    8150             :    */
    8151             : 
    8152           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Path2D);
    8153           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    8154           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    8155             : }
    8156             : 
    8157             : JSObject*
    8158           0 : GetConstructorObject(JSContext* aCx)
    8159             : {
    8160           0 :   return GetConstructorObjectHandle(aCx);
    8161             : }
    8162             : 
    8163             : } // namespace Path2DBinding
    8164             : 
    8165             : 
    8166             : 
    8167             : namespace TextMetricsBinding {
    8168             : 
    8169             : static bool
    8170           0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextMetrics* self, JSJitGetterCallArgs args)
    8171             : {
    8172           0 :   double result(self->Width());
    8173           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    8174           0 :   args.rval().set(JS_NumberValue(double(result)));
    8175           0 :   return true;
    8176             : }
    8177             : 
    8178             : static const JSJitInfo width_getterinfo = {
    8179             :   { (JSJitGetterOp)get_width },
    8180             :   { prototypes::id::TextMetrics },
    8181             :   { PrototypeTraits<prototypes::id::TextMetrics>::Depth },
    8182             :   JSJitInfo::Getter,
    8183             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    8184             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    8185             :   true,  /* isInfallible. False in setters. */
    8186             :   false,  /* isMovable.  Not relevant for setters. */
    8187             :   false, /* isEliminatable.  Not relevant for setters. */
    8188             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    8189             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    8190             :   false,  /* isTypedMethod.  Only relevant for methods. */
    8191             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    8192             : };
    8193             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    8194             : static_assert(0 < 1, "There is no slot for us");
    8195             : 
    8196             : static void
    8197           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    8198             : {
    8199           0 :   mozilla::dom::TextMetrics* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextMetrics>(obj);
    8200           0 :   if (self) {
    8201           0 :     AddForDeferredFinalization<mozilla::dom::TextMetrics>(self);
    8202             :   }
    8203           0 : }
    8204             : 
    8205             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    8206             : #if defined(__clang__)
    8207             : #pragma clang diagnostic push
    8208             : #pragma clang diagnostic ignored "-Wmissing-braces"
    8209             : #endif
    8210             : static const JSPropertySpec sAttributes_specs[] = {
    8211             :   { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, nullptr, nullptr },
    8212             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    8213             : };
    8214             : #if defined(__clang__)
    8215             : #pragma clang diagnostic pop
    8216             : #endif
    8217             : 
    8218             : 
    8219             : // Can't be const because the pref-enabled boolean needs to be writable
    8220             : static Prefable<const JSPropertySpec> sAttributes[] = {
    8221             :   { nullptr, &sAttributes_specs[0] },
    8222             :   { nullptr, nullptr }
    8223             : };
    8224             : 
    8225             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    8226             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    8227             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    8228             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    8229             : 
    8230             : 
    8231             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
    8232             : static PropertyInfo sNativeProperties_propertyInfos[1];
    8233             : 
    8234             : static const NativePropertiesN<1> sNativeProperties = {
    8235             :   false, 0,
    8236             :   false, 0,
    8237             :   false, 0,
    8238             :   true,  0 /* sAttributes */,
    8239             :   false, 0,
    8240             :   false, 0,
    8241             :   false, 0,
    8242             :   -1,
    8243             :   1,
    8244             :   sNativeProperties_sortedPropertyIndices,
    8245             :   {
    8246             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    8247             :   }
    8248             : };
    8249             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    8250             :     "We have a property info count that is oversized");
    8251             : 
    8252             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    8253             :   {
    8254             :     "Function",
    8255             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    8256             :     &sBoringInterfaceObjectClassClassOps,
    8257             :     JS_NULL_CLASS_SPEC,
    8258             :     JS_NULL_CLASS_EXT,
    8259             :     &sInterfaceObjectClassObjectOps
    8260             :   },
    8261             :   eInterface,
    8262             :   true,
    8263             :   prototypes::id::TextMetrics,
    8264             :   PrototypeTraits<prototypes::id::TextMetrics>::Depth,
    8265             :   sNativePropertyHooks,
    8266             :   "function TextMetrics() {\n    [native code]\n}",
    8267             :   JS::GetRealmFunctionPrototype
    8268             : };
    8269             : 
    8270             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    8271             :   {
    8272             :     "TextMetricsPrototype",
    8273             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    8274             :     JS_NULL_CLASS_OPS,
    8275             :     JS_NULL_CLASS_SPEC,
    8276             :     JS_NULL_CLASS_EXT,
    8277             :     JS_NULL_OBJECT_OPS
    8278             :   },
    8279             :   eInterfacePrototype,
    8280             :   false,
    8281             :   prototypes::id::TextMetrics,
    8282             :   PrototypeTraits<prototypes::id::TextMetrics>::Depth,
    8283             :   sNativePropertyHooks,
    8284             :   "[object TextMetricsPrototype]",
    8285             :   JS::GetRealmObjectPrototype
    8286             : };
    8287             : 
    8288             : JSObject*
    8289           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    8290             : {
    8291           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    8292             : }
    8293             : 
    8294             : static const js::ClassOps sClassOps = {
    8295             :   nullptr, /* addProperty */
    8296             :   nullptr,               /* delProperty */
    8297             :   nullptr,               /* getProperty */
    8298             :   nullptr,               /* setProperty */
    8299             :   nullptr,               /* enumerate */
    8300             :   nullptr, /* newEnumerate */
    8301             :   nullptr, /* resolve */
    8302             :   nullptr, /* mayResolve */
    8303             :   _finalize, /* finalize */
    8304             :   nullptr, /* call */
    8305             :   nullptr,               /* hasInstance */
    8306             :   nullptr,               /* construct */
    8307             :   nullptr, /* trace */
    8308             : };
    8309             : 
    8310             : static const js::ClassExtension sClassExtension = {
    8311             :   nullptr, /* weakmapKeyDelegateOp */
    8312             :   nullptr /* objectMovedOp */
    8313             : };
    8314             : 
    8315             : static const DOMJSClass sClass = {
    8316             :   { "TextMetrics",
    8317             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    8318             :     &sClassOps,
    8319             :     JS_NULL_CLASS_SPEC,
    8320             :     &sClassExtension,
    8321             :     JS_NULL_OBJECT_OPS
    8322             :   },
    8323             :   { prototypes::id::TextMetrics, 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 },
    8324             :   IsBaseOf<nsISupports, mozilla::dom::TextMetrics >::value,
    8325             :   sNativePropertyHooks,
    8326             :   FindAssociatedGlobalForNative<mozilla::dom::TextMetrics>::Get,
    8327             :   GetProtoObjectHandle,
    8328             :   GetCCParticipant<mozilla::dom::TextMetrics>::Get()
    8329             : };
    8330             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    8331             :               "Must have the right minimal number of reserved slots.");
    8332             : static_assert(1 >= 1,
    8333             :               "Must have enough reserved slots.");
    8334             : 
    8335             : const JSClass*
    8336           0 : GetJSClass()
    8337             : {
    8338           0 :   return sClass.ToJSClass();
    8339             : }
    8340             : 
    8341             : bool
    8342           0 : Wrap(JSContext* aCx, mozilla::dom::TextMetrics* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    8343             : {
    8344             :   MOZ_ASSERT(static_cast<mozilla::dom::TextMetrics*>(aObject) ==
    8345             :              reinterpret_cast<mozilla::dom::TextMetrics*>(aObject),
    8346             :              "Multiple inheritance for mozilla::dom::TextMetrics is broken.");
    8347           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    8348           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    8349             : 
    8350           0 :   JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
    8351           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    8352           0 :   if (!canonicalProto) {
    8353           0 :     return false;
    8354             :   }
    8355           0 :   JS::Rooted<JSObject*> proto(aCx);
    8356           0 :   if (aGivenProto) {
    8357           0 :     proto = aGivenProto;
    8358             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    8359             :     // coming in, we changed compartments to that of "parent" so may need
    8360             :     // to wrap the proto here.
    8361           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    8362           0 :       if (!JS_WrapObject(aCx, &proto)) {
    8363           0 :         return false;
    8364             :       }
    8365             :     }
    8366             :   } else {
    8367           0 :     proto = canonicalProto;
    8368             :   }
    8369             : 
    8370           0 :   BindingJSObjectCreator<mozilla::dom::TextMetrics> creator(aCx);
    8371           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    8372           0 :   if (!aReflector) {
    8373           0 :     return false;
    8374             :   }
    8375             : 
    8376             : 
    8377             : 
    8378           0 :   creator.InitializationSucceeded();
    8379           0 :   return true;
    8380             : }
    8381             : 
    8382             : const NativePropertyHooks sNativePropertyHooks[] = { {
    8383             :   nullptr,
    8384             :   nullptr,
    8385             :   nullptr,
    8386             :   { sNativeProperties.Upcast(), nullptr },
    8387             :   prototypes::id::TextMetrics,
    8388             :   constructors::id::TextMetrics,
    8389             :   nullptr,
    8390             :   &DefaultXrayExpandoObjectClass
    8391             : } };
    8392             : 
    8393             : void
    8394           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    8395             : {
    8396           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    8397           0 :   if (!parentProto) {
    8398           0 :     return;
    8399             :   }
    8400             : 
    8401           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    8402           0 :   if (!constructorProto) {
    8403           0 :     return;
    8404             :   }
    8405             : 
    8406             :   static bool sIdsInited = false;
    8407           0 :   if (!sIdsInited && NS_IsMainThread()) {
    8408           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    8409           0 :       return;
    8410             :     }
    8411           0 :     sIdsInited = true;
    8412             :   }
    8413             : 
    8414           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TextMetrics);
    8415           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TextMetrics);
    8416           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    8417             :                               &sPrototypeClass.mBase, protoCache,
    8418             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    8419             :                               interfaceCache,
    8420             :                               sNativeProperties.Upcast(),
    8421             :                               nullptr,
    8422             :                               "TextMetrics", aDefineOnGlobal,
    8423             :                               nullptr,
    8424           0 :                               false);
    8425             : }
    8426             : 
    8427             : JS::Handle<JSObject*>
    8428           0 : GetProtoObjectHandle(JSContext* aCx)
    8429             : {
    8430             :   /* Get the interface prototype object for this class.  This will create the
    8431             :      object as needed. */
    8432           0 :   bool aDefineOnGlobal = true;
    8433             : 
    8434             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    8435           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    8436           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    8437           0 :     return nullptr;
    8438             :   }
    8439             : 
    8440             :   /* Check to see whether the interface objects are already installed */
    8441           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    8442           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::TextMetrics)) {
    8443           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    8444           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    8445             :   }
    8446             : 
    8447             :   /*
    8448             :    * The object might _still_ be null, but that's OK.
    8449             :    *
    8450             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    8451             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    8452             :    * changed after they have been set.
    8453             :    *
    8454             :    * Calling address() avoids the read read barrier that does gray
    8455             :    * unmarking, but it's not possible for the object to be gray here.
    8456             :    */
    8457             : 
    8458           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::TextMetrics);
    8459           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    8460           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    8461             : }
    8462             : 
    8463             : JS::Handle<JSObject*>
    8464           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    8465             : {
    8466             :   /* Get the interface object for this class.  This will create the object as
    8467             :      needed. */
    8468             : 
    8469             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    8470           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    8471           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    8472           0 :     return nullptr;
    8473             :   }
    8474             : 
    8475             :   /* Check to see whether the interface objects are already installed */
    8476           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    8477           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::TextMetrics)) {
    8478           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    8479           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    8480             :   }
    8481             : 
    8482             :   /*
    8483             :    * The object might _still_ be null, but that's OK.
    8484             :    *
    8485             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    8486             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    8487             :    * changed after they have been set.
    8488             :    *
    8489             :    * Calling address() avoids the read read barrier that does gray
    8490             :    * unmarking, but it's not possible for the object to be gray here.
    8491             :    */
    8492             : 
    8493           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::TextMetrics);
    8494           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    8495           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    8496             : }
    8497             : 
    8498             : JSObject*
    8499           0 : GetConstructorObject(JSContext* aCx)
    8500             : {
    8501           0 :   return GetConstructorObjectHandle(aCx);
    8502             : }
    8503             : 
    8504             : } // namespace TextMetricsBinding
    8505             : 
    8506             : 
    8507             : 
    8508             : } // namespace dom
    8509             : } // namespace mozilla

Generated by: LCOV version 1.13