dom/plugins/base/nsJSNPRuntime.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsJSNPRuntime_h_
     7 #define nsJSNPRuntime_h_
     9 #include "nscore.h"
    10 #include "npapi.h"
    11 #include "npruntime.h"
    12 #include "pldhash.h"
    14 class nsJSNPRuntime
    15 {
    16 public:
    17   static void OnPluginDestroy(NPP npp);
    18 };
    20 class nsJSObjWrapperKey
    21 {
    22 public:
    23   nsJSObjWrapperKey(JSObject *obj, NPP npp)
    24     : mJSObj(obj), mNpp(npp)
    25   {
    26   }
    28   bool operator==(const nsJSObjWrapperKey& other) const {
    29     return mJSObj == other.mJSObj && mNpp == other.mNpp;
    30   }
    31   bool operator!=(const nsJSObjWrapperKey& other) const {
    32     return !(*this == other);
    33   }
    35   JSObject * mJSObj;
    36   const NPP mNpp;
    37 };
    39 extern const JSClass sNPObjectJSWrapperClass;
    41 class nsJSObjWrapper : public NPObject
    42 {
    43 public:
    44   JS::PersistentRooted<JSObject *> mJSObj;
    45   const NPP mNpp;
    47   static NPObject *GetNewOrUsed(NPP npp, JSContext *cx,
    48                                 JS::Handle<JSObject*> obj);
    50 protected:
    51   nsJSObjWrapper(NPP npp);
    52   ~nsJSObjWrapper();
    54   static NPObject * NP_Allocate(NPP npp, NPClass *aClass);
    55   static void NP_Deallocate(NPObject *obj);
    56   static void NP_Invalidate(NPObject *obj);
    57   static bool NP_HasMethod(NPObject *, NPIdentifier identifier);
    58   static bool NP_Invoke(NPObject *obj, NPIdentifier method,
    59                         const NPVariant *args, uint32_t argCount,
    60                         NPVariant *result);
    61   static bool NP_InvokeDefault(NPObject *obj, const NPVariant *args,
    62                                uint32_t argCount, NPVariant *result);
    63   static bool NP_HasProperty(NPObject * obj, NPIdentifier property);
    64   static bool NP_GetProperty(NPObject *obj, NPIdentifier property,
    65                              NPVariant *result);
    66   static bool NP_SetProperty(NPObject *obj, NPIdentifier property,
    67                              const NPVariant *value);
    68   static bool NP_RemoveProperty(NPObject *obj, NPIdentifier property);
    69   static bool NP_Enumerate(NPObject *npobj, NPIdentifier **identifier,
    70                            uint32_t *count);
    71   static bool NP_Construct(NPObject *obj, const NPVariant *args,
    72                            uint32_t argCount, NPVariant *result);
    74 public:
    75   static NPClass sJSObjWrapperNPClass;
    76 };
    78 class nsNPObjWrapper
    79 {
    80 public:
    81   static void OnDestroy(NPObject *npobj);
    82   static JSObject *GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj);
    83 };
    85 bool
    86 JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant);
    89 #endif // nsJSNPRuntime_h_

mercurial